all: use the elvis operator wherever possible

Coccinelle:

  @@
  expression a, b;
  @@
  -a ? a : b
  +a ?: b

Applied with:

  spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .

With some manual adjustments on spots that Cocci didn't catch for
reasons unknown.

Thanks to the marvelous effort of the GNU compiler developer we can now
spare a couple of bits that could be used for more important things,
like this commit message. Standards commitees yet have to catch up.
This commit is contained in:
Lubomir Rintel 2018-04-24 11:20:03 +02:00
parent f0c1efbf42
commit e69d386975
62 changed files with 139 additions and 141 deletions

View file

@ -1275,7 +1275,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
arr = nmc_dup_fields_array (tmpl, NMC_OF_FLAG_SECTION_PREFIX);
set_val_strc (arr, 0, nmc_fields_con_active_details_groups[5]->name);
set_val_str (arr, 1, type_str);
set_val_strc (arr, 2, username ? username : get_vpn_data_item (con, VPN_DATA_ITEM_USERNAME));
set_val_strc (arr, 2, username ?: get_vpn_data_item (con, VPN_DATA_ITEM_USERNAME));
set_val_strc (arr, 3, get_vpn_data_item (con, VPN_DATA_ITEM_GATEWAY));
set_val_str (arr, 4, banner_str);
set_val_str (arr, 5, vpn_state_str);
@ -4248,7 +4248,7 @@ nmc_read_connection_properties (NmCli *nmc,
return FALSE;
if (!*argc && nmc->complete)
complete_property (setting, strv[1], value ? value : "", connection);
complete_property (setting, strv[1], value ?: "", connection);
if (!set_property (connection, setting_name, strv[1], value, modifier, error))
return FALSE;
@ -4329,7 +4329,7 @@ nmc_read_connection_properties (NmCli *nmc,
return FALSE;
if (!*argc && nmc->complete)
complete_option (chosen, value ? value : "", connection);
complete_option (chosen, value ?: "", connection);
if (!set_option (nmc, connection, chosen, value, error))
return FALSE;
@ -7014,7 +7014,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* in top level - no setting selected yet */
const char *setting_name;
NMSetting *setting;
const char *user_arg = cmd_arg_s ? cmd_arg_s : cmd_arg_p;
const char *user_arg = cmd_arg_s ?: cmd_arg_p;
setting_name = ask_check_setting (user_arg,
valid_settings_main,
@ -7106,7 +7106,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* cmd_arg_s != NULL means argument is "setting.property" */
descr_all = !cmd_arg_s && !menu_ctx.curr_setting;
user_s = descr_all ? cmd_arg_p : cmd_arg_s ? cmd_arg_s : NULL;
user_s = descr_all ? cmd_arg_p : cmd_arg_s;
if (user_s) {
ss = is_setting_valid (connection,
valid_settings_main,
@ -7199,7 +7199,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* cmd_arg_s != NULL means argument is "setting.property" */
descr_all = !cmd_arg_s && !menu_ctx.curr_setting;
user_s = descr_all ? cmd_arg_p : cmd_arg_s ? cmd_arg_s : NULL;
user_s = descr_all ? cmd_arg_p : cmd_arg_s;
if (user_s) {
ss = is_setting_valid (connection,
valid_settings_main,
@ -7265,7 +7265,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
/* cmd_arg_s != NULL means argument is "setting.property" */
whole_setting = !cmd_arg_s && !menu_ctx.curr_setting;
user_s = whole_setting ? cmd_arg_p : cmd_arg_s ? cmd_arg_s : NULL;
user_s = whole_setting ? cmd_arg_p : cmd_arg_s;
if (user_s) {
const char *s_name;
@ -7583,7 +7583,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
nmc->editor_prompt_color);
} else
g_print (_("Invalid configuration option '%s'; allowed [%s]\n"),
cmd_arg_v ? cmd_arg_v : "", "status-line, save-confirmation, show-secrets, prompt-color");
cmd_arg_v ?: "", "status-line, save-confirmation, show-secrets, prompt-color");
break;
@ -7654,7 +7654,7 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection, const char *sl
g_object_set (s_con,
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
NM_SETTING_CONNECTION_MASTER, dev_ifname ? dev_ifname : "eth0",
NM_SETTING_CONNECTION_MASTER, dev_ifname ?: "eth0",
NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type,
NULL);
} else {
@ -7675,7 +7675,7 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection, const char *sl
const char *dev_ifname = get_ethernet_device_name (nmc);
g_object_set (NM_SETTING_VLAN (base_setting),
NM_SETTING_VLAN_PARENT, dev_ifname ? dev_ifname : "eth0",
NM_SETTING_VLAN_PARENT, dev_ifname ?: "eth0",
NULL);
}

View file

@ -1160,7 +1160,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
set_val_strc (arr, 6, nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)"));
set_val_strc (arr, 7, nm_device_get_driver_version (device));
set_val_strc (arr, 8, nm_device_get_firmware_version (device));
set_val_strc (arr, 9, hwaddr ? hwaddr : _("(unknown)"));
set_val_strc (arr, 9, hwaddr ?: _("(unknown)"));
set_val_str (arr, 10, mtu_str);
set_val_str (arr, 11, state_str);
set_val_str (arr, 12, reason_str);
@ -1268,7 +1268,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
}
tmpl = (const NMMetaAbstractInfo *const*) nmc_fields_dev_wifi_list;
out_indices = parse_output_fields (section_fld ? section_fld : NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST,
out_indices = parse_output_fields (section_fld ?: NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST,
tmpl, FALSE, NULL, NULL);
arr = nmc_dup_fields_array (tmpl, NMC_OF_FLAG_FIELD_NAMES);
g_ptr_array_add (out.output_data, arr);
@ -2906,7 +2906,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
if (nmc->ask) {
ssid_ask = nmc_readline (_("SSID or BSSID: "));
param_user = ssid_ask ? ssid_ask : "";
param_user = ssid_ask ?: "";
bssid1_arr = nm_utils_hwaddr_atoba (param_user, ETH_ALEN);
}
if (!ssid_ask) {

View file

@ -516,8 +516,8 @@ show_nm_status (NmCli *nmc, const char *pretty_header_name, const char *print_fl
{
gs_free_error GError *error = NULL;
const char *fields_str;
const char *fields_all = print_flds ? print_flds : NMC_FIELDS_NM_STATUS_ALL;
const char *fields_common = print_flds ? print_flds : NMC_FIELDS_NM_STATUS_COMMON;
const char *fields_all = print_flds ?: NMC_FIELDS_NM_STATUS_ALL;
const char *fields_common = print_flds ?: NMC_FIELDS_NM_STATUS_COMMON;
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
fields_str = fields_common;

View file

@ -749,9 +749,9 @@ nmc_setting_get_property_desc (NMSetting *setting, const char *prop)
return g_strdup_printf ("%s\n%s\n%s%s%s%s",
setting_desc_title,
setting_desc ? setting_desc : "",
setting_desc ?: "",
nmcli_nl, nmcli_desc_title, nmcli_nl,
nmcli_desc ? nmcli_desc : "");
nmcli_desc ?: "");
}
/*

View file

@ -390,7 +390,7 @@ nmc_terminal_show_progress (const char *str)
const char slashes[4] = {'|', '/', '-', '\\'};
nmc_terminal_erase_line ();
g_print ("%c %s", slashes[idx++], str ? str : "");
g_print ("%c %s", slashes[idx++], str ?: "");
fflush (stdout);
if (idx == 4)
idx = 0;

View file

@ -2891,7 +2891,7 @@ dcb_parse_uint_array (const char *val,
*iter = g_strstrip (*iter);
num = _nm_utils_ascii_str_to_int64 (*iter, 10, 0, other ? other : max, -1);
num = _nm_utils_ascii_str_to_int64 (*iter, 10, 0, other ?: max, -1);
/* If number is greater than 'max' it must equal 'other' */
if ( num == -1

View file

@ -238,7 +238,7 @@ nm_vpn_openconnect_authenticate_helper (const char *host,
* HOST='1.2.3.4'
* FINGERPRINT='sha1:32bac90cf09a722e10ecc1942c67fe2ac8c21e2e'
*/
strv = g_strsplit_set (output ? output : "", "\r\n", 0);
strv = g_strsplit_set (output ?: "", "\r\n", 0);
for (iter = strv; iter && *iter; iter++) {
_extract_variable_value (*iter, "COOKIE=", cookie);
_extract_variable_value (*iter, "HOST=", gateway);

View file

@ -65,9 +65,9 @@ nmt_newt_dialog_g_log_handler (const char *log_domain,
}
full_message = g_strdup_printf ("%s%s%s%s%s",
log_domain ? log_domain : "",
log_domain ?: "",
log_domain && level_name ? " " : "",
level_name ? level_name : "",
level_name ?: "",
log_domain || level_name ? ": " : "",
message);
@ -87,7 +87,7 @@ nmt_newt_dialog_g_log_handler (const char *log_domain,
newtGridSetField (grid, 0, 1, NEWT_GRID_COMPONENT, ok, 0, 1, 0, 0,
NEWT_ANCHOR_RIGHT, 0);
newtGridWrappedWindow (grid, (char *) (level_name ? level_name : ""));
newtGridWrappedWindow (grid, (char *) (level_name ?: ""));
newtGridFree (grid, TRUE);
form = newtForm (NULL, NULL, 0);

View file

@ -307,7 +307,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev,
}
if (!nmtconn->name)
nmtconn->name = nmtconn->ssid ? nmtconn->ssid : "<unknown>";
nmtconn->name = nmtconn->ssid ?: "<unknown>";
nmtdev->conns = g_slist_prepend (nmtdev->conns, nmtconn);
}
@ -376,7 +376,7 @@ append_nmt_devices_for_virtual_devices (GSList *nmt_devices,
g_free (name);
else {
nmtdev = g_slice_new0 (NmtConnectDevice);
nmtdev->name = name ? name : g_strdup ("Unknown");
nmtdev->name = name ?: g_strdup("Unknown");
nmtdev->sort_order = sort_order;
g_hash_table_insert (devices_by_name, nmtdev->name, nmtdev);
@ -533,7 +533,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list)
nmtconn->name,
(int)(max_width - nmt_newt_text_width (nmtconn->name)), "",
strength_col ? " " : "",
strength_col ? strength_col : "");
strength_col ?: "");
nmt_newt_listbox_append (listbox, row, nmtconn);
g_free (row);

View file

@ -144,7 +144,7 @@ struct Request {
(_request)->request_id, \
(_request)->action, \
(_request)->iface ? " [" : "", \
(_request)->iface ? (_request)->iface : "", \
(_request)->iface ?: "", \
(_request)->iface ? "]" : "", \
(_script) ? ", \"" : "", \
(_script) ? (_script)->script : "", \
@ -297,7 +297,7 @@ complete_request (Request *request)
g_variant_builder_add (&results, "(sus)",
script->script,
script->result,
script->error ? script->error : "");
script->error ?: "");
}
ret = g_variant_new ("(a(sus))", &results);
@ -537,9 +537,7 @@ script_dispatch (ScriptInfo *script)
script->dispatched = TRUE;
argv[0] = script->script;
argv[1] = request->iface
? request->iface
: (!strcmp (request->action, NMD_ACTION_HOSTNAME) ? "none" : "");
argv[1] = request->iface ?: (!strcmp(request->action, NMD_ACTION_HOSTNAME) ? "none" : "");
argv[2] = request->action;
argv[3] = NULL;

View file

@ -543,7 +543,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
device_dhcp4_props,
device_dhcp6_props,
connectivity_change,
override_vpn_ip_iface ? override_vpn_ip_iface : vpn_ip_iface,
override_vpn_ip_iface ?: vpn_ip_iface,
vpn_proxy_props,
vpn_ip4_props,
vpn_ip6_props,

View file

@ -180,7 +180,7 @@ show_wifi_device_info (NMDevice *device)
speed /= 1000;
printf ("Device: %s ---- Driver: %s ---- Speed: %d Mbit/s ---- Active AP: %s\n",
iface, driver, speed, active_ssid_str ? active_ssid_str : "none");
iface, driver, speed, active_ssid_str ?: "none");
printf ("=================================================================================\n");
g_free (active_ssid_str);

View file

@ -1530,7 +1530,7 @@ nm_connection_update_secrets (NMConnection *connection,
g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
success_detail = _nm_setting_update_secrets (setting,
setting_dict ? setting_dict : secrets,
setting_dict ?: secrets,
error);
g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);

View file

@ -106,7 +106,7 @@ nm_keyfile_plugin_kf_set_##stype##_list (GKeyFile *kf, \
const char *alias; \
\
alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \
g_key_file_set_##stype##_list (kf, alias ? alias : group, key, list, length); \
g_key_file_set_##stype##_list (kf, alias ?: group, key, list, length); \
}
DEFINE_KF_LIST_WRAPPER(integer, gint*, gint);
@ -170,7 +170,7 @@ nm_keyfile_plugin_kf_set_##stype (GKeyFile *kf, \
const char *alias; \
\
alias = nm_keyfile_plugin_get_alias_for_setting_name (group); \
g_key_file_set_##stype (kf, alias ? alias : group, key, value); \
g_key_file_set_##stype (kf, alias ?: group, key, value); \
}
DEFINE_KF_WRAPPER(string, gchar*, const gchar*);

View file

@ -112,7 +112,7 @@ setting_alias_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *k
if (s) {
key_setting_name = nm_keyfile_plugin_get_setting_name_for_alias (s);
g_object_set (G_OBJECT (setting),
key, key_setting_name ? key_setting_name : s,
key, key_setting_name ?: s,
NULL);
g_free (s);
}
@ -358,7 +358,7 @@ read_one_ip_address_or_route (KeyfileReaderInfo *info,
gs_free char *value = NULL;
gs_free char *value_orig = NULL;
#define VALUE_ORIG() (value_orig ? value_orig : (value_orig = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, key_name, NULL)))
#define VALUE_ORIG() (value_orig ?: (value_orig = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, key_name, NULL)))
value = nm_keyfile_plugin_kf_get_string (info->keyfile, setting_name, key_name, NULL);
if (!value)
@ -1363,7 +1363,7 @@ parity_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key)
default:
handle_warn (info, key, NM_KEYFILE_WARN_SEVERITY_WARN,
_("invalid parity value '%s'"),
str_val ? str_val : "");
str_val ?: "");
return;
}
@ -1506,7 +1506,7 @@ setting_alias_writer (KeyfileWriterInfo *info,
nm_keyfile_plugin_kf_set_string (info->keyfile,
nm_setting_get_name (setting),
key,
alias ? alias : str);
alias ?: str);
}
static void

View file

@ -206,7 +206,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("'%s' is not a valid value for the property"),
priv->protocol ? priv->protocol : "(null)");
priv->protocol ?: "(null)");
g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PROTOCOL);
return FALSE;
}

View file

@ -4318,7 +4318,7 @@ nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst)
s = inet_ntop (addr_family,
addr,
dst ? dst : _nm_utils_inet_ntop_buffer,
dst ?: _nm_utils_inet_ntop_buffer,
addr_family == AF_INET6 ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN);
nm_assert (s);
return s;
@ -4344,7 +4344,7 @@ nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst)
const char *
nm_utils_inet4_ntop (in_addr_t inaddr, char *dst)
{
return inet_ntop (AF_INET, &inaddr, dst ? dst : _nm_utils_inet_ntop_buffer,
return inet_ntop (AF_INET, &inaddr, dst ?: _nm_utils_inet_ntop_buffer,
INET_ADDRSTRLEN);
}
@ -4370,7 +4370,7 @@ const char *
nm_utils_inet6_ntop (const struct in6_addr *in6addr, char *dst)
{
g_return_val_if_fail (in6addr, NULL);
return inet_ntop (AF_INET6, in6addr, dst ? dst : _nm_utils_inet_ntop_buffer,
return inet_ntop (AF_INET6, in6addr, dst ?: _nm_utils_inet_ntop_buffer,
INET6_ADDRSTRLEN);
}

View file

@ -674,7 +674,7 @@ nm_client_activate_connection (NMClient *client,
activate_cb, info, NULL,
DBUS_TYPE_G_OBJECT_PATH, connection ? nm_connection_get_path (connection) : "/",
DBUS_TYPE_G_OBJECT_PATH, device ? nm_object_get_path (NM_OBJECT (device)) : "/",
DBUS_TYPE_G_OBJECT_PATH, specific_object ? specific_object : "/",
DBUS_TYPE_G_OBJECT_PATH, specific_object ?: "/",
G_TYPE_INVALID);
}
@ -762,7 +762,7 @@ nm_client_add_and_activate_connection (NMClient *client,
add_activate_cb, info, NULL,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, hash,
DBUS_TYPE_G_OBJECT_PATH, nm_object_get_path (NM_OBJECT (device)),
DBUS_TYPE_G_OBJECT_PATH, specific_object ? specific_object : "/",
DBUS_TYPE_G_OBJECT_PATH, specific_object ?: "/",
G_TYPE_INVALID);
} else
info->idle_id = g_idle_add (activate_nm_not_running, info);
@ -1257,8 +1257,8 @@ nm_client_set_logging (NMClient *client, const char *level, const char *domains,
return TRUE;
return dbus_g_proxy_call (priv->client_proxy, "SetLogging", error,
G_TYPE_STRING, level ? level : "",
G_TYPE_STRING, domains ? domains : "",
G_TYPE_STRING, level ?: "",
G_TYPE_STRING, domains ?: "",
G_TYPE_INVALID,
G_TYPE_INVALID);
}

View file

@ -1328,7 +1328,7 @@ _nm_object_register_properties (NMObject *object,
}
pi = g_malloc0 (sizeof (PropertyInfo));
pi->func = tmp->func ? tmp->func : demarshal_generic;
pi->func = tmp->func ?: demarshal_generic;
pi->object_type = tmp->object_type;
pi->field = tmp->field;
pi->signal_prefix = tmp->signal_prefix;
@ -1572,5 +1572,5 @@ _nm_object_new_proxy (NMObject *self, const char *path, const char *interface)
{
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (self);
return _nm_dbus_new_proxy_for_connection (priv->connection, path ? path : priv->path, interface);
return _nm_dbus_new_proxy_for_connection (priv->connection, path ?: priv->path, interface);
}

View file

@ -576,7 +576,7 @@ fetch_connections_done (DBusGProxy *proxy,
&& priv->service_running) {
g_warning ("%s: error fetching connections: %s.",
__func__,
error->message ? error->message : "(unknown)");
error->message ?: "(unknown)");
}
g_clear_error (&error);
@ -964,7 +964,7 @@ nm_remote_settings_save_hostname (NMRemoteSettings *settings,
save_hostname_cb,
info,
g_free,
G_TYPE_STRING, hostname ? hostname : "",
G_TYPE_STRING, hostname ?: "",
G_TYPE_INVALID);
return TRUE;
}

View file

@ -1020,7 +1020,7 @@ nm_connection_update_secrets (NMConnection *connection,
g_signal_handlers_block_by_func (setting, (GCallback) setting_changed_cb, connection);
success_detail = _nm_setting_update_secrets (setting,
setting_hash ? setting_hash : secrets,
setting_hash ?: secrets,
error);
g_signal_handlers_unblock_by_func (setting, (GCallback) setting_changed_cb, connection);

View file

@ -226,7 +226,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NM_SETTING_ADSL_ERROR,
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
_("'%s' is not a valid value for the property"),
priv->protocol ? priv->protocol : "(null)");
priv->protocol ?: "(null)");
g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PROTOCOL);
return FALSE;
}

View file

@ -2474,7 +2474,7 @@ static char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN];
const char *
nm_utils_inet4_ntop (in_addr_t inaddr, char *dst)
{
return inet_ntop (AF_INET, &inaddr, dst ? dst : _nm_utils_inet_ntop_buffer,
return inet_ntop (AF_INET, &inaddr, dst ?: _nm_utils_inet_ntop_buffer,
INET_ADDRSTRLEN);
}
@ -2502,7 +2502,7 @@ const char *
nm_utils_inet6_ntop (const struct in6_addr *in6addr, char *dst)
{
g_return_val_if_fail (in6addr, NULL);
return inet_ntop (AF_INET6, in6addr, dst ? dst : _nm_utils_inet_ntop_buffer,
return inet_ntop (AF_INET6, in6addr, dst ?: _nm_utils_inet_ntop_buffer,
INET6_ADDRSTRLEN);
}

View file

@ -104,7 +104,7 @@ _nm_utils_convert_string_list_to_string (const GValue *src_value, GValue *dest_v
for (iter = strings; iter; iter = iter->next) {
if (iter != strings)
g_string_append_c (printable, ',');
g_string_append (printable, iter->data ? iter->data : "(null)");
g_string_append (printable, iter->data ?: "(null)");
}
g_value_take_string (dest_value, g_string_free (printable, FALSE));

View file

@ -1049,7 +1049,7 @@ nm_manager_activate_connection_async (NMManager *manager,
nmdbus_manager_call_activate_connection (priv->proxy,
connection ? nm_connection_get_path (connection) : "/",
device ? nm_object_get_path (NM_OBJECT (device)) : "/",
specific_object ? specific_object : "/",
specific_object ?: "/",
cancellable,
activate_cb, info);
}
@ -1133,7 +1133,7 @@ nm_manager_add_and_activate_connection_async (NMManager *manager,
nmdbus_manager_call_add_and_activate_connection (priv->proxy,
dict,
nm_object_get_path (NM_OBJECT (device)),
specific_object ? specific_object : "/",
specific_object ?: "/",
cancellable,
add_activate_cb, info);
}

View file

@ -968,7 +968,7 @@ _nm_object_register_properties (NMObject *object,
}
pi = g_malloc0 (sizeof (PropertyInfo));
pi->func = tmp->func ? tmp->func : demarshal_generic;
pi->func = tmp->func ?: demarshal_generic;
pi->object_type = tmp->object_type;
pi->field = tmp->field;
pi->signal_prefix = tmp->signal_prefix;

View file

@ -538,7 +538,7 @@ nm_remote_settings_save_hostname (NMRemoteSettings *settings,
priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings);
ret = nmdbus_settings_call_save_hostname_sync (priv->proxy,
hostname ? hostname : "",
hostname ?: "",
cancellable, error);
if (error && *error)
g_dbus_error_strip_remote_error (*error);
@ -583,7 +583,7 @@ nm_remote_settings_save_hostname_async (NMRemoteSettings *settings,
g_simple_async_result_set_check_cancellable (simple, cancellable);
nmdbus_settings_call_save_hostname (priv->proxy,
hostname ? hostname : "",
hostname ?: "",
cancellable, save_hostname_cb, simple);
}

View file

@ -224,7 +224,7 @@ verify_sender (NMSecretAgentOld *self,
NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_PERMISSION_DENIED,
"Failed to request unix user: (%s) %s.",
remote_error ? remote_error : "",
remote_error ?: "",
local->message);
g_free (remote_error);
g_error_free (local);

View file

@ -1138,7 +1138,7 @@ _nmtst_assert_ip4_address (const char *file, int line, in_addr_t addr, const cha
char buf[100];
g_error ("%s:%d: Unexpected IPv4 address: expected %s, got %s",
file, line, str_expected ? str_expected : "0.0.0.0",
file, line, str_expected ?: "0.0.0.0",
inet_ntop (AF_INET, &addr, buf, sizeof (buf)));
}
}
@ -1156,7 +1156,7 @@ _nmtst_assert_ip6_address (const char *file, int line, const struct in6_addr *ad
char buf[100];
g_error ("%s:%d: Unexpected IPv6 address: expected %s, got %s",
file, line, str_expected ? str_expected : "::",
file, line, str_expected ?: "::",
inet_ntop (AF_INET6, addr, buf, sizeof (buf)));
}
}

View file

@ -236,7 +236,7 @@ handle_uevent (NMUdevClient *client,
ifindex = udev_device_get_property_value (device, "IFINDEX");
seqnum = udev_device_get_seqnum (device);
nm_log_dbg (LOGD_PLATFORM, "UDEV event: action '%s' subsys '%s' device '%s' (%s); seqnum=%" G_GUINT64_FORMAT,
action, subsys, udev_device_get_sysname (device), ifindex ? ifindex : "unknown", seqnum);
action, subsys, udev_device_get_sysname (device), ifindex ?: "unknown", seqnum);
if (!strcmp (action, "add"))
adsl_add (self, device);

View file

@ -194,7 +194,7 @@ br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl)
_LOGD (LOGD_ADSL, "assigning address %d.%d.%d encapsulation %s",
priv->atm_index, addr.sap_addr.vpi, addr.sap_addr.vci,
encapsulation ? encapsulation : "(none)");
encapsulation ?: "(none)");
err = connect (priv->brfd, (struct sockaddr*) &addr, sizeof (addr));
if (err != 0) {

View file

@ -494,7 +494,7 @@ nm_bluez_device_disconnect (NMBluezDevice *self)
priv->path,
dbus_iface,
"Disconnect",
args ? args : g_variant_new ("()"),
args ?: g_variant_new("()"),
NULL,
G_DBUS_CALL_FLAGS_NONE,
10000,

View file

@ -314,7 +314,7 @@ apply_bonding_config (NMDevice *device)
/* Primary */
value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_PRIMARY);
set_bond_attr (device, mode, NM_SETTING_BOND_OPTION_PRIMARY, value ? value : "");
set_bond_attr (device, mode, NM_SETTING_BOND_OPTION_PRIMARY, value ?: "");
/* ARP targets: clear and initialize the list */
contents = nm_platform_sysctl_master_get_option (nm_device_get_platform (device), ifindex,
@ -591,7 +591,7 @@ reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_n
/* Primary */
value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_PRIMARY);
set_bond_attr (device, mode, NM_SETTING_BOND_OPTION_PRIMARY, value ? value : "");
set_bond_attr (device, mode, NM_SETTING_BOND_OPTION_PRIMARY, value ?: "");
/* Active slave */
set_simple_option (device, mode, s_bond, NM_SETTING_BOND_OPTION_ACTIVE_SLAVE);

View file

@ -1357,7 +1357,7 @@ nm_device_get_ip_iface (NMDevice *self)
priv = NM_DEVICE_GET_PRIVATE (self);
/* If it's not set, default to iface */
return priv->ip_iface ? priv->ip_iface : priv->iface;
return priv->ip_iface ?: priv->iface;
}
int

View file

@ -363,7 +363,7 @@ _insert_interface (json_t *params, NMConnection *interface)
json_pack ("{s:s, s:s, s:{s:s, s:s, s:o, s:[s, [[s, s]]]}, s:s}",
"op", "insert", "table", "Interface", "row",
"name", nm_connection_get_interface_name (interface),
"type", type ? type : "",
"type", type ?: "",
"options", options,
"external_ids", "map", "NM.connection.uuid", nm_connection_get_uuid (interface),
"uuid-name", "rowInterface"));
@ -891,7 +891,7 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
_LOGT ("removed an '%s' interface: %s%s%s",
ovs_interface->type, ovs_interface->name,
ovs_interface->connection_uuid ? ", " : "",
ovs_interface->connection_uuid ? ovs_interface->connection_uuid : "");
ovs_interface->connection_uuid ?: "");
if (g_strcmp0 (ovs_interface->type, "internal") == 0) {
/* Currently the factory only creates NMDevices for
* internal interfaces. Ignore the rest. */
@ -910,14 +910,14 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
if (old) {
_LOGT ("changed an '%s' interface: %s%s%s", type, ovs_interface->name,
ovs_interface->connection_uuid ? ", " : "",
ovs_interface->connection_uuid ? ovs_interface->connection_uuid : "");
ovs_interface->connection_uuid ?: "");
g_signal_emit (self, signals[DEVICE_CHANGED], 0,
"ovs-interface", ovs_interface->name);
} else {
_LOGT ("added an '%s' interface: %s%s%s",
ovs_interface->type, ovs_interface->name,
ovs_interface->connection_uuid ? ", " : "",
ovs_interface->connection_uuid ? ovs_interface->connection_uuid : "");
ovs_interface->connection_uuid ?: "");
if (g_strcmp0 (ovs_interface->type, "internal") == 0) {
/* Currently the factory only creates NMDevices for
* internal interfaces. Ignore the rest. */
@ -949,7 +949,7 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
old = FALSE;
_LOGT ("removed a port: %s%s%s", ovs_port->name,
ovs_port->connection_uuid ? ", " : "",
ovs_port->connection_uuid ? ovs_port->connection_uuid : "");
ovs_port->connection_uuid ?: "");
g_signal_emit (self, signals[DEVICE_REMOVED], 0,
ovs_port->name, NM_DEVICE_TYPE_OVS_PORT);
}
@ -965,13 +965,13 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
if (old) {
_LOGT ("changed a port: %s%s%s", ovs_port->name,
ovs_port->connection_uuid ? ", " : "",
ovs_port->connection_uuid ? ovs_port->connection_uuid : "");
ovs_port->connection_uuid ?: "");
g_signal_emit (self, signals[DEVICE_CHANGED], 0,
NM_SETTING_OVS_PORT_SETTING_NAME, ovs_port->name);
} else {
_LOGT ("added a port: %s%s%s", ovs_port->name,
ovs_port->connection_uuid ? ", " : "",
ovs_port->connection_uuid ? ovs_port->connection_uuid : "");
ovs_port->connection_uuid ?: "");
g_signal_emit (self, signals[DEVICE_ADDED], 0,
ovs_port->name, NM_DEVICE_TYPE_OVS_PORT);
}
@ -999,7 +999,7 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
old = FALSE;
_LOGT ("removed a bridge: %s%s%s", ovs_bridge->name,
ovs_bridge->connection_uuid ? ", " : "",
ovs_bridge->connection_uuid ? ovs_bridge->connection_uuid : "");
ovs_bridge->connection_uuid ?: "");
g_signal_emit (self, signals[DEVICE_REMOVED], 0,
ovs_bridge->name, NM_DEVICE_TYPE_OVS_BRIDGE);
}
@ -1015,13 +1015,13 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg)
if (old) {
_LOGT ("changed a bridge: %s%s%s", ovs_bridge->name,
ovs_bridge->connection_uuid ? ", " : "",
ovs_bridge->connection_uuid ? ovs_bridge->connection_uuid : "");
ovs_bridge->connection_uuid ?: "");
g_signal_emit (self, signals[DEVICE_CHANGED], 0,
NM_SETTING_OVS_BRIDGE_SETTING_NAME, ovs_bridge->name);
} else {
_LOGT ("added a bridge: %s%s%s", ovs_bridge->name,
ovs_bridge->connection_uuid ? ", " : "",
ovs_bridge->connection_uuid ? ovs_bridge->connection_uuid : "");
ovs_bridge->connection_uuid ?: "");
g_signal_emit (self, signals[DEVICE_ADDED], 0,
ovs_bridge->name, NM_DEVICE_TYPE_OVS_BRIDGE);
}

View file

@ -2147,9 +2147,9 @@ supplicant_iface_notify_current_bss (NMSupplicantInterface *iface,
}
_LOGD (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)",
old_bssid ? old_bssid : "(none)",
old_bssid ?: "(none)",
old_ssid ? nm_utils_escape_ssid (old_ssid->data, old_ssid->len) : "(none)",
new_bssid ? new_bssid : "(none)",
new_bssid ?: "(none)",
new_ssid ? nm_utils_escape_ssid (new_ssid->data, new_ssid->len) : "(none)");
set_current_ap (self, new_ap, TRUE);

View file

@ -286,7 +286,7 @@ create_gsm_connect_properties (NMConnection *connection)
/* Blank APN ("") means the default subscription APN */
str = nm_setting_gsm_get_apn (setting);
mm_simple_connect_properties_set_apn (properties, str ? str : "");
mm_simple_connect_properties_set_apn (properties, str ?: "");
str = nm_setting_gsm_get_network_id (setting);
if (str)

View file

@ -205,7 +205,7 @@ nm_modem_set_state (NMModem *self,
_LOGI ("modem state changed, '%s' --> '%s' (reason: %s)",
nm_modem_state_to_string (old_state),
nm_modem_state_to_string (new_state),
reason ? reason : "none");
reason ?: "none");
priv->state = new_state;
_notify (self, PROP_STATE);

View file

@ -334,7 +334,7 @@ nm_dhcp_client_stop_pid (pid_t pid, const char *iface)
g_return_if_fail (pid > 1);
nm_utils_kill_child_sync (pid, SIGTERM, LOGD_DHCP, name ? name : "dhcp-client", NULL,
nm_utils_kill_child_sync (pid, SIGTERM, LOGD_DHCP, name ?: "dhcp-client", NULL,
1000 / 2, 1000 / 20);
g_free (name);
}

View file

@ -160,7 +160,7 @@ _method_call_handle (NMDhcpListener *self,
pid_str = get_option (options, "pid");
pid = _nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1);
if (pid == -1) {
_LOGW ("dhcp-event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
_LOGW ("dhcp-event: couldn't convert PID '%s' to an integer", pid_str ?: "(null)");
return;
}

View file

@ -311,7 +311,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
if (send_hostname) {
/* Always prefer the explicit dhcp-hostname if given */
hostname = dhcp_hostname ? dhcp_hostname : priv->default_hostname;
hostname = dhcp_hostname ?: priv->default_hostname;
}
return client_start (self, AF_INET6, multi_idx, iface, ifindex, hwaddr, uuid,
route_table, route_metric, ll_addr,

View file

@ -214,7 +214,7 @@ do_early_setup (int *argc, char **argv[], NMConfigCmdLineOptions *config_cli)
_("NetworkManager monitors all network connections and automatically\nchooses the best connection to use. It also allows the user to\nspecify wireless access points which wireless cards in the computer\nshould associate with.")))
exit (1);
global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup (NM_DEFAULT_PID_FILE);
global_opt.pidfile = global_opt.pidfile ?: g_strdup(NM_DEFAULT_PID_FILE);
}
/*

View file

@ -579,7 +579,7 @@ ignore_config_snippet (GKeyFile *keyfile, gboolean is_base_config)
const char *e;
e = g_getenv ("NM_CONFIG_ENABLE_TAG");
_nm_config_match_env = g_strdup (e ? e : "");
_nm_config_match_env = g_strdup (e ?: "");
}
/* second, interpret the value as match-spec. */
@ -2407,7 +2407,7 @@ _set_config_data (NMConfig *self, NMConfigData *new_data, NMConfigChangeFlags re
else
_LOGI ("signal: %s", nm_config_change_flags_to_string (changes, NULL, 0));
g_signal_emit (self, signals[SIGNAL_CONFIG_CHANGED], 0,
new_data ? new_data : old_data,
new_data ?: old_data,
changes, old_data);
if (new_data)
g_object_unref (old_data);

View file

@ -2044,8 +2044,8 @@ _log_connection_sort_hashes_fcn (gconstpointer a, gconstpointer b)
NMSettingPriority p1, p2;
NMSetting *s1, *s2;
s1 = v1->setting ? v1->setting : v1->diff_base_setting;
s2 = v2->setting ? v2->setting : v2->diff_base_setting;
s1 = v1->setting ?: v1->diff_base_setting;
s2 = v2->setting ?: v2->diff_base_setting;
g_assert (s1 && s2);
@ -2279,13 +2279,13 @@ nm_utils_log_connection_diff (NMConnection *connection,
g_string_printf (str1, "%s.%s", setting_data->name, item->item_name);
switch (item->diff_result & (NM_SETTING_DIFF_RESULT_IN_A | NM_SETTING_DIFF_RESULT_IN_B)) {
case NM_SETTING_DIFF_RESULT_IN_B:
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s < %s", prefix, str1->str, str_diff ? str_diff : "NULL");
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s < %s", prefix, str1->str, str_diff ?: "NULL");
break;
case NM_SETTING_DIFF_RESULT_IN_A:
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s = %s", prefix, str1->str, str_conn ? str_conn : "NULL");
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s = %s", prefix, str1->str, str_conn ?: "NULL");
break;
default:
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s = %s < %s", prefix, str1->str, str_conn ? str_conn : "NULL", str_diff ? str_diff : "NULL");
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s = %s < %s", prefix, str1->str, str_conn ?: "NULL", str_diff ?: "NULL");
break;
#undef _NM_LOG_ALIGN
}

View file

@ -158,7 +158,7 @@ double nm_utils_exp10 (gint16 e);
static inline guint32
nm_utils_ip6_route_metric_normalize (guint32 metric)
{
return metric ? metric : 1024 /*NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6*/;
return metric ?: 1024 /*NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6*/;
}
static inline guint32

View file

@ -547,7 +547,7 @@ _dispatcher_call (NMDispatcherAction action,
_LOGD ("(%u) (%s) dispatching action '%s'%s",
reqid,
vpn_iface ? vpn_iface : nm_device_get_iface (device),
vpn_iface ?: nm_device_get_iface(device),
action_to_string (action),
blocking
? " (blocking)"
@ -650,7 +650,7 @@ _dispatcher_call (NMDispatcherAction action,
device_dhcp4_props,
device_dhcp6_props,
connectivity_state_string,
vpn_iface ? vpn_iface : "",
vpn_iface ?: "",
&vpn_proxy_props,
&vpn_ip4_props,
&vpn_ip6_props,
@ -688,7 +688,7 @@ _dispatcher_call (NMDispatcherAction action,
device_dhcp4_props,
device_dhcp6_props,
connectivity_state_string,
vpn_iface ? vpn_iface : "",
vpn_iface ?: "",
&vpn_proxy_props,
&vpn_ip4_props,
&vpn_ip6_props,

View file

@ -174,7 +174,7 @@ _cb_info_create (NMFirewallManager *self,
if (priv->running || priv->proxy_cancellable) {
info->mode_mutable = CB_INFO_MODE_DBUS_WAITING;
info->dbus.arg = g_variant_new ("(ss)", zone ? zone : "", iface);
info->dbus.arg = g_variant_new ("(ss)", zone ?: "", iface);
} else
info->mode_mutable = CB_INFO_MODE_IDLE;

View file

@ -6977,7 +6977,7 @@ get_property (GObject *object, guint prop_id,
if (con)
type = nm_connection_get_connection_type (con);
}
g_value_set_string (value, type ? type : "");
g_value_set_string (value, type ?: "");
break;
case PROP_ACTIVATING_CONNECTION:
nm_dbus_utils_g_value_set_object_path (value, priv->activating_connection);

View file

@ -2119,7 +2119,7 @@ vpn_connection_retry_after_failure (NMVpnConnection *vpn, NMPolicy *self)
&error)) {
_LOGW (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
nm_settings_connection_get_id (connection),
error->message ? error->message : "unknown");
error->message ?: "unknown");
g_clear_error (&error);
}
}

View file

@ -296,7 +296,7 @@ add_one_killswitch (NMRfkillManager *self, struct udev_device *device)
rfkill_type_to_desc (rtype),
ks->path,
ks->platform ? "platform " : "",
ks->driver ? ks->driver : "<unknown>");
ks->driver ?: "<unknown>");
}
static void

View file

@ -6980,7 +6980,7 @@ handle_udev_event (NMUdevClient *udev_client,
seqnum = udev_device_get_seqnum (udevice);
_LOGD ("UDEV event: action '%s' subsys '%s' device '%s' (%s); seqnum=%" G_GUINT64_FORMAT,
action, subsys, udev_device_get_sysname (udevice),
ifindex ? ifindex : "unknown", seqnum);
ifindex ?: "unknown", seqnum);
if (NM_IN_STRSET (action, "add", "move"))
udev_device_added (platform, udevice);

View file

@ -4882,11 +4882,11 @@ nm_platform_link_to_string (const NMPlatformLink *link, char *buf, gsize len)
link->inet6_addr_gen_mode_inv ? " addrgenmode " : "",
link->inet6_addr_gen_mode_inv ? nm_platform_link_inet6_addrgenmode2str (_nm_platform_uint8_inv (link->inet6_addr_gen_mode_inv), str_addrmode, sizeof (str_addrmode)) : "",
str_addr ? " addr " : "",
str_addr ? str_addr : "",
str_addr ?: "",
link->inet6_token.id ? " inet6token " : "",
link->inet6_token.id ? nm_utils_inet6_interface_identifier_to_token (link->inet6_token, str_inet6_token) : "",
link->driver ? " driver " : "",
link->driver ? link->driver : "",
link->driver ?: "",
link->rx_packets, link->rx_bytes,
link->tx_packets, link->tx_bytes);
g_string_free (str_flags, TRUE);
@ -5298,7 +5298,7 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *bu
str_label[0] = 0;
str_lft_p = _lifetime_to_string (address->timestamp,
address->lifetime ? address->lifetime : NM_PLATFORM_LIFETIME_PERMANENT,
address->lifetime ?: NM_PLATFORM_LIFETIME_PERMANENT,
now, str_lft, sizeof (str_lft)),
str_pref_p = (address->lifetime == address->preferred)
? str_lft_p
@ -5310,7 +5310,7 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *bu
g_snprintf (buf, len,
"%s/%d lft %s pref %s%s%s%s%s%s src %s",
s_address, address->plen, str_lft_p, str_pref_p, str_time_p,
str_peer ? str_peer : "",
str_peer ?: "",
str_dev,
_to_string_ifa_flags (address->n_ifa_flags, s_flags, sizeof (s_flags)),
str_label,
@ -5405,7 +5405,7 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *bu
_to_string_dev (NULL, address->ifindex, str_dev, sizeof (str_dev));
str_lft_p = _lifetime_to_string (address->timestamp,
address->lifetime ? address->lifetime : NM_PLATFORM_LIFETIME_PERMANENT,
address->lifetime ?: NM_PLATFORM_LIFETIME_PERMANENT,
now, str_lft, sizeof (str_lft)),
str_pref_p = (address->lifetime == address->preferred)
? str_lft_p
@ -5417,7 +5417,7 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *bu
g_snprintf (buf, len,
"%s/%d lft %s pref %s%s%s%s%s src %s",
s_address, address->plen, str_lft_p, str_pref_p, str_time_p,
str_peer ? str_peer : "",
str_peer ?: "",
str_dev,
_to_string_ifa_flags (address->n_ifa_flags, s_flags, sizeof (s_flags)),
nmp_utils_ip_config_source_to_string (address->addr_source, s_source, sizeof (s_source)));

View file

@ -28,7 +28,7 @@
#include "test-common.h"
#define SIGNAL_DATA_FMT "'%s-%s' ifindex %d%s%s%s (%d times received)"
#define SIGNAL_DATA_ARG(data) (data)->name, nm_platform_signal_change_type_to_string ((data)->change_type), (data)->ifindex, (data)->ifname ? " ifname '" : "", (data)->ifname ? (data)->ifname : "", (data)->ifname ? "'" : "", (data)->received_count
#define SIGNAL_DATA_ARG(data) (data)->name, nm_platform_signal_change_type_to_string ((data)->change_type), (data)->ifindex, (data)->ifname ? " ifname '" : "", (data)->ifname ?: "", (data)->ifname ? "'" : "", (data)->received_count
int NMTSTP_ENV1_IFINDEX = -1;
int NMTSTP_ENV1_EX = -1;
@ -1258,7 +1258,7 @@ nmtstp_link_gre_add (NMPlatform *platform,
success = !nmtstp_run_command ("ip tunnel add %s mode gre %s local %s remote %s ttl %u tos %02x %s",
name,
dev ? dev : "",
dev ?: "",
nm_utils_inet4_ntop (lnk->local, NULL),
nm_utils_inet4_ntop (lnk->remote, buffer),
lnk->ttl,
@ -1568,7 +1568,7 @@ nmtstp_link_vxlan_add (NMPlatform *platform,
err = nmtstp_run_command ("ip link add %s type vxlan id %u %s local %s group %s ttl %u tos %02x dstport %u srcport %u %u ageing %u",
name,
lnk->id,
dev ? dev : "",
dev ?: "",
local,
remote,
lnk->ttl,

View file

@ -135,7 +135,7 @@ G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_D
const char *__uuid = (self) ? nm_settings_connection_get_uuid (self) : NULL; \
\
if (self) { \
g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, self, __uuid ? "," : "", __uuid ? __uuid : ""); \
g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, self, __uuid ? "," : "", __uuid ?: ""); \
__p_prefix = __prefix; \
} \
_nm_log (__level, _NMLOG_DOMAIN, 0, NULL, __uuid, \
@ -463,7 +463,7 @@ update_agent_secrets_cache (NMSettingsConnection *self, NMConnection *new)
if (priv->agent_secrets)
g_object_unref (priv->agent_secrets);
priv->agent_secrets = nm_simple_connection_new_clone (new ? new : NM_CONNECTION (self));
priv->agent_secrets = nm_simple_connection_new_clone (new ?: NM_CONNECTION(self));
/* Clear out non-system-owned secrets */
nm_connection_clear_secrets_with_flags (priv->agent_secrets,
@ -1883,7 +1883,7 @@ settings_connection_update (NMSettingsConnection *self,
* that's sending the update request. You can't make a connection
* invisible to yourself.
*/
if (!nm_auth_is_subject_in_acl_set_error (tmp ? tmp : NM_CONNECTION (self),
if (!nm_auth_is_subject_in_acl_set_error (tmp ?: NM_CONNECTION(self),
subject,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
@ -1899,7 +1899,7 @@ settings_connection_update (NMSettingsConnection *self,
info->new_settings = tmp;
permission = get_update_modify_permission (NM_CONNECTION (self),
tmp ? tmp : NM_CONNECTION (self));
tmp ?: NM_CONNECTION(self));
auth_start (self, context, subject, permission, update_auth_cb, info);
return;

View file

@ -128,7 +128,7 @@ nms_ibft_reader_load_blocks (const char *iscsiadm_path,
}
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"iBFT: %s exited with error %d. Message: '%s'",
iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)");
iscsiadm_path, WEXITSTATUS (status), err ?: "(none)");
goto done;
}
@ -392,15 +392,15 @@ connection_setting_add (const GPtrArray *block,
id = g_strdup_printf ("iBFT%s%s %s",
prefix ? " " : "",
prefix ? prefix : "",
prefix ?: "",
iface);
uuid = _nm_utils_uuid_generate_from_strings ("ibft",
s_hwaddr,
s_vlanid ? "V" : "v",
s_vlanid ? s_vlanid : "",
s_vlanid ?: "",
s_ip4addr ? "A" : "DHCP",
s_ip4addr ? s_ip4addr : "",
s_ip4addr ?: "",
NULL);
s_con = nm_setting_connection_new ();

View file

@ -418,7 +418,7 @@ ifcfg_dir_changed (GFileMonitor *monitor,
path = g_file_get_path (file);
ifcfg_path = utils_detect_ifcfg_path (path, FALSE);
_LOGD ("ifcfg_dir_changed(%s) = %d // %s", path, event_type, ifcfg_path ? ifcfg_path : "(none)");
_LOGD ("ifcfg_dir_changed(%s) = %d // %s", path, event_type, ifcfg_path ?: "(none)");
if (ifcfg_path) {
connection = find_by_path (plugin, ifcfg_path);
switch (event_type) {

View file

@ -386,7 +386,7 @@ is_any_ip4_address_defined (shvarFile *ifcfg, int *idx)
{
int i, ignore, *ret_idx;
ret_idx = idx ? idx : &ignore;
ret_idx = idx ?: &ignore;
for (i = -1; i <= 2; i++) {
gs_free char *value = NULL;
@ -1847,8 +1847,8 @@ make_ip6_setting (shvarFile *ifcfg,
ipv6addr_secondaries = svGetValueStr_cp (ifcfg, "IPV6ADDR_SECONDARIES");
value = g_strjoin (ipv6addr && ipv6addr_secondaries ? " " : NULL,
ipv6addr ? ipv6addr : "",
ipv6addr_secondaries ? ipv6addr_secondaries : "",
ipv6addr ?: "",
ipv6addr_secondaries ?: "",
NULL);
g_free (ipv6addr);
g_free (ipv6addr_secondaries);
@ -4524,9 +4524,9 @@ handle_bond_option (NMSettingBond *s_bond,
}
}
if (!nm_setting_bond_add_option (s_bond, key, sanitized ? sanitized : value))
if (!nm_setting_bond_add_option (s_bond, key, sanitized ?: value))
PARSE_WARNING ("invalid bonding option '%s' = %s",
key, sanitized ? sanitized : value);
key, sanitized ?: value);
g_free (sanitized);
}

View file

@ -4590,7 +4590,7 @@ test_write_wired_static_ip6_only_gw (gconstpointer user_data)
s_con = (NMSettingConnection *) nm_setting_connection_new ();
nm_connection_add_setting (connection, NM_SETTING (s_con));
id = g_strdup_printf ("Test Write Wired Static IP6 Only With Gateway %s", gateway6 ? gateway6 : "NULL");
id = g_strdup_printf ("Test Write Wired Static IP6 Only With Gateway %s", gateway6 ?: "NULL");
g_object_set (s_con,
NM_SETTING_CONNECTION_ID, id,
NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (),

View file

@ -338,7 +338,7 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
}
g_object_set(wireless_security_setting,
newkey, typed_property_value ? typed_property_value : property_value,
newkey, typed_property_value ?: property_value,
NULL);
security = TRUE;
@ -386,7 +386,7 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
}
g_object_set(wireless_security_setting,
newkey, typed_property_value ? typed_property_value : property_value,
newkey, typed_property_value ?: property_value,
NULL);
security = TRUE;

View file

@ -144,7 +144,7 @@ nm_supplicant_config_add_option_with_type (NMSupplicantConfig *self,
memset (&buf[0], 0, sizeof (buf));
memcpy (&buf[0], value, len > 254 ? 254 : len);
g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG,
"key '%s' and/or value '%s' invalid", key, hidden ? hidden : buf);
"key '%s' and/or value '%s' invalid", key, hidden ?: buf);
return FALSE;
}
}
@ -168,7 +168,7 @@ nm_supplicant_config_add_option_with_type (NMSupplicantConfig *self,
char buf[255];
memset (&buf[0], 0, sizeof (buf));
memcpy (&buf[0], opt->value, opt->len > 254 ? 254 : opt->len);
nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, hidden ? hidden : &buf[0]);
nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, hidden ?: &buf[0]);
}
g_hash_table_insert (priv->config, g_strdup (key), opt);
@ -979,7 +979,7 @@ add_pkcs11_uri_with_pin (NMSupplicantConfig *self,
tmp = g_strdup_printf ("%s%s%s", split[0],
(pin_qattr ? "?" : ""),
(pin_qattr ? pin_qattr : ""));
(pin_qattr ?: ""));
tmp_log = g_strdup_printf ("%s%s%s", split[0],
(pin_qattr ? "?" : ""),
@ -1171,7 +1171,7 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
/* CA path */
path = nm_setting_802_1x_get_ca_path (setting);
path = ca_path_override ? ca_path_override : path;
path = ca_path_override ?: path;
if (path) {
if (!add_string_val (self, path, "ca_path", FALSE, NULL, error))
return FALSE;
@ -1179,7 +1179,7 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self,
/* Phase2 CA path */
path = nm_setting_802_1x_get_phase2_ca_path (setting);
path = ca_path_override ? ca_path_override : path;
path = ca_path_override ?: path;
if (path) {
if (!add_string_val (self, path, "ca_path2", FALSE, NULL, error))
return FALSE;

View file

@ -187,7 +187,7 @@ validate_type_bytes (const struct Opt * opt,
g_return_val_if_fail (opt != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
check_len = opt->int_high ? opt->int_high : 255;
check_len = opt->int_high ?: 255;
if (len > check_len)
return FALSE;
@ -204,7 +204,7 @@ validate_type_utf8 (const struct Opt *opt,
g_return_val_if_fail (opt != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
check_len = opt->int_high ? opt->int_high : 255;
check_len = opt->int_high ?: 255;
/* Note that we deliberately don't validate the UTF-8, because
some "UTF-8" fields, such as 8021x.password, do not actually
have to be valid UTF-8 */

View file

@ -1022,7 +1022,7 @@ print_vpn_config (NMVpnConnection *self)
if (nm_ip4_config_get_num_domains (priv->ip4_config) > 0)
dns_domain = (char *) nm_ip4_config_get_domain (priv->ip4_config, 0);
_LOGI ("Data: DNS Domain: '%s'", dns_domain ? dns_domain : "(none)");
_LOGI ("Data: DNS Domain: '%s'", dns_domain ?: "(none)");
} else
_LOGI ("Data: No IPv4 configuration");
@ -1056,7 +1056,7 @@ print_vpn_config (NMVpnConnection *self)
if (nm_ip6_config_get_num_domains (priv->ip6_config) > 0)
dns_domain = (char *) nm_ip6_config_get_domain (priv->ip6_config, 0);
_LOGI ("Data: DNS Domain: '%s'", dns_domain ? dns_domain : "(none)");
_LOGI ("Data: DNS Domain: '%s'", dns_domain ?: "(none)");
} else
_LOGI ("Data: No IPv6 configuration");
@ -2821,7 +2821,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, _state_to_nm_vpn_state (priv->vpn_state));
break;
case PROP_BANNER:
g_value_set_string (value, priv->banner ? priv->banner : "");
g_value_set_string (value, priv->banner ?: "");
break;
case PROP_IP4_CONFIG:
nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->vpn_state) ? priv->ip4_config : NULL);