Commit e69d3869 authored by Lubomir Rintel's avatar Lubomir Rintel 🥕

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.
parent f0c1efbf
......@@ -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);
}
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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 ?: "");
}
/*
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......
......@@ -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);
......
......@@ -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);
......
......@@ -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*);
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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));
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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)));
}
}
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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,
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
}
......
......@@ -2147,9 +2147,9 @@ supplicant_iface_notify_current_bss (NMSupplicantInterface *iface,
}
_LOGD (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)",
old_bssid ?