diff options
author | Thomas Haller <thaller@redhat.com> | 2016-02-28 16:25:36 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-03-03 18:54:20 +0100 |
commit | 01b9b4104c365002fae5e45b564956062fe146d4 (patch) | |
tree | de72d05b95706d94a8750d9870768b61edf8b98a | |
parent | 7871d850f50975b46f7909bc6bd3cce434c7c60e (diff) | |
download | NetworkManager-01b9b4104c365002fae5e45b564956062fe146d4.tar.gz |
all: clean-up usage of GError
Functions that take a GError** MUST fill it in on error. There is no
need to check whether error is NULL if the function it was passed to
had a failing return value.
Likewise, a proper GError must have a non-NULL message, so there's no
need to double-check that either.
Based-on-patch-by: Dan Winship <danw@gnome.org>
32 files changed, 79 insertions, 91 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index d263154d22..d9b90a18aa 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -2302,7 +2302,7 @@ nmc_activate_connection (NmCli *nmc, /* Virtual connection may not have their interfaces created yet */ if (!device_found && !nm_connection_is_virtual (connection)) { g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_CON_ACTIVATION, - "%s", local && local->message ? local->message : _("unknown error")); + "%s", local->message); g_clear_error (&local); return FALSE; } @@ -2450,8 +2450,8 @@ do_connection_up (NmCli *nmc, int argc, char **argv) if (!nmc_activate_connection (nmc, connection, ifname, ap, nsp, pwds, activate_connection_cb, &error)) { g_string_printf (nmc->return_text, _("Error: %s."), - error ? error->message : _("unknown error")); - nmc->return_value = error ? error->code : NMC_RESULT_ERROR_CON_ACTIVATION; + error->message); + nmc->return_value = error->code; g_clear_error (&error); nmc->should_wait--; goto error; @@ -10724,7 +10724,7 @@ do_connection_export (NmCli *nmc, int argc, char **argv) if (!nm_vpn_editor_plugin_export (plugin, path, connection, &error)) { g_string_printf (nmc->return_text, _("Error: failed to export '%s': %s."), - nm_connection_get_id (connection), error ? error->message : "(unknown)"); + nm_connection_get_id (connection), error->message); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; goto finish; } diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index fc105e53e7..3c0564684b 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -812,8 +812,8 @@ nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active) DBUS_TYPE_G_OBJECT_PATH, path, G_TYPE_INVALID, G_TYPE_INVALID)) { - g_warning ("Could not deactivate connection '%s': %s", - path, error ? error->message : "(unknown)"); + g_warning ("Could not deactivate connection '%s': %s", + path, NM_G_ERROR_MSG (error)); g_clear_error (&error); } } diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 312f970059..779f4b7c1c 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -2202,8 +2202,8 @@ device_operation_cb (DBusGProxy *proxy, __func__, nm_object_get_path (NM_OBJECT (info->device)), info->method, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->code, + NM_G_ERROR_MSG (error)); } g_clear_error (&error); diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 2031b27f11..e043fdb1a8 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -457,8 +457,7 @@ replace_settings (NMRemoteConnection *self, GHashTable *new_settings) g_warning ("%s: error updating connection %s settings: (%d) %s", __func__, nm_connection_get_path (NM_CONNECTION (self)), - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + error->code, error->message); g_clear_error (&error); g_signal_emit (self, signals[REMOVED], 0); diff --git a/libnm-glib/nm-secret-agent.c b/libnm-glib/nm-secret-agent.c index a0966f9f6c..073729da5d 100644 --- a/libnm-glib/nm-secret-agent.c +++ b/libnm-glib/nm-secret-agent.c @@ -331,8 +331,7 @@ verify_request (NMSecretAgent *self, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, "Invalid connection: (%d) %s", - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + local->code, local->message); g_clear_error (&local); } diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index 7c9def1da2..e9f20a1c77 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -1515,8 +1515,7 @@ nm_utils_uuid_generate_from_string (const char *s) if (!nm_utils_init (&error)) { g_warning ("error initializing crypto: (%d) %s", - error ? error->code : 0, - error ? error->message : "unknown"); + error->code, error->message); if (error) g_error_free (error); return NULL; @@ -1524,8 +1523,7 @@ nm_utils_uuid_generate_from_string (const char *s) if (!crypto_md5_hash (NULL, 0, s, strlen (s), (char *) uuid, sizeof (uuid), &error)) { g_warning ("error generating UUID: (%d) %s", - error ? error->code : 0, - error ? error->message : "unknown"); + error->code, error->message); if (error) g_error_free (error); return NULL; diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index d2b55bd84f..7a739e2cb1 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -567,8 +567,8 @@ replace_settings (NMRemoteConnection *self, GVariant *new_settings) g_warning ("%s: error updating connection %s settings: (%d) %s", __func__, nm_connection_get_path (NM_CONNECTION (self)), - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + error->code, + error->message); g_clear_error (&error); } } diff --git a/shared/nm-test-utils.h b/shared/nm-test-utils.h index 542081b891..4b1c5d2436 100644 --- a/shared/nm-test-utils.h +++ b/shared/nm-test-utils.h @@ -154,7 +154,7 @@ inline static void _nmtst_assert_success (gboolean success, GError *error, const char *file, int line) { if (!success || error) - g_error ("(%s:%d) FAILURE success=%d, error=%s", file, line, success, error && error->message ? error->message : "(no error)"); + g_error ("(%s:%d) FAILURE success=%d, error=%s", file, line, success, error ? error->message : "(no error)"); } #define nmtst_assert_success(success, error) _nmtst_assert_success ((success), (error), __FILE__, __LINE__) diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index 71226813de..231fd9a114 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -247,8 +247,7 @@ pan_connection_check_create (NMBluezDevice *self) nm_log_dbg (LOGD_BT, "bluez[%s] added new Bluetooth connection for NAP device: '%s' (%s)", priv->path, id, uuid); } else { nm_log_warn (LOGD_BT, "bluez[%s] couldn't add new Bluetooth connection for NAP device: '%s' (%s): %d / %s", - priv->path, id, uuid, error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + priv->path, id, uuid, error->code, error->message); g_clear_error (&error); } diff --git a/src/devices/bluetooth/nm-bluez5-manager.c b/src/devices/bluetooth/nm-bluez5-manager.c index e44e87d8a9..8fcfaedf5b 100644 --- a/src/devices/bluetooth/nm-bluez5-manager.c +++ b/src/devices/bluetooth/nm-bluez5-manager.c @@ -231,8 +231,7 @@ on_proxy_acquired (GObject *object, priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error); if (!priv->proxy) { - nm_log_warn (LOGD_BT, "Couldn't acquire object manager proxy: %s", - error && error->message ? error->message : "(unknown)"); + nm_log_warn (LOGD_BT, "Couldn't acquire object manager proxy: %s", error->message); g_clear_error (&error); return; } diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index e151b79559..9ac791faf3 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -498,7 +498,7 @@ modem_ip4_config_result (NMModem *modem, if (error) { _LOGW (LOGD_MB | LOGD_IP4 | LOGD_BT, "retrieving IP4 configuration failed: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + error->code, error->message); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } else @@ -728,8 +728,7 @@ bluez_connect_cb (GObject *object, res, &error); if (!device) { - _LOGW (LOGD_BT, "Error connecting with bluez: %s", - error && error->message ? error->message : "(unknown)"); + _LOGW (LOGD_BT, "Error connecting with bluez: %s", error->message); g_clear_error (&error); nm_device_state_changed (NM_DEVICE (self), diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 84f10abf4b..37b48b3a11 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -177,7 +177,7 @@ _update_s390_subchannels (NMDeviceEthernet *self) dir = g_dir_open (parent_path, 0, &error); if (!dir) { _LOGW (LOGD_DEVICE | LOGD_HW, "failed to open directory '%s': %s", - parent_path, error && error->message ? error->message : "(unknown)"); + parent_path, error->message); g_clear_error (&error); goto out; } @@ -597,13 +597,13 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, if (!success) { _LOGE (LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) couldn't send security configuration to the supplicant: %s", - error ? error->message : "<BUG>"); + error->message); g_clear_error (&error); } } else { _LOGE (LOGD_DEVICE | LOGD_ETHER, "Activation: (ethernet) couldn't build security configuration: %s", - error ? error->message : "<BUG>"); + error->message); g_clear_error (&error); } diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c index bd0ec002ec..5ce4333f58 100644 --- a/src/devices/nm-device-factory.c +++ b/src/devices/nm-device-factory.c @@ -355,7 +355,7 @@ read_device_factory_paths (void) if (!dir) { nm_log_warn (LOGD_HW, "device plugin: failed to open directory %s: %s", NMPLUGINDIR, - (error && error->message) ? error->message : "(unknown)"); + error->message); g_clear_error (&error); return NULL; } @@ -499,7 +499,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call factory = create_func (&error); if (!factory) { nm_log_warn (LOGD_HW, "(%s): failed to initialize device factory: %s", - item, error ? error->message : "unknown"); + item, NM_G_ERROR_MSG (error)); g_clear_error (&error); g_module_close (plugin); continue; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index cdd3f7cb1a..0897b27e55 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2883,7 +2883,7 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master) &error)) { _LOGE (LOGD_DEVICE, "master device '%s' failed to update slave connection: %s", - nm_device_get_iface (master), error ? error->message : "(unknown error)"); + nm_device_get_iface (master), error->message); g_error_free (error); g_object_unref (connection); return NULL; @@ -6631,7 +6631,7 @@ start_sharing (NMDevice *self, NMIP4Config *config) if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, config, &error)) { _LOGE (LOGD_SHARING, "share: (%s) failed to start dnsmasq: %s", - ip_iface, (error && error->message) ? error->message : "(unknown)"); + ip_iface, error->message); g_error_free (error); nm_act_request_set_shared (req, FALSE); return FALSE; diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index da2a0f4a89..2bf3b56a16 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -2491,7 +2491,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) if (config == NULL) { _LOGE (LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) couldn't build wireless configuration: %s", - error ? error->message : "<BUG>"); + error->message); g_clear_error (&error); *reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; goto out; @@ -2506,7 +2506,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) if (!nm_supplicant_interface_set_config (priv->sup_iface, config, &error)) { _LOGE (LOGD_DEVICE | LOGD_WIFI, "Activation: (wifi) couldn't send wireless configuration to the supplicant: %s", - error ? error->message : "<BUG>"); + error->message); g_clear_error (&error); *reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; goto out; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index e9c4f02e20..8bc631f238 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -158,7 +158,7 @@ modem_ip4_config_result (NMModem *modem, if (error) { _LOGW (LOGD_MB | LOGD_IP4, "retrieving IPv4 configuration failed: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + error->code, error->message); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } else { @@ -185,7 +185,7 @@ modem_ip6_config_result (NMModem *modem, if (error) { _LOGW (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + error->code, error->message); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); return; diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 6343416cbd..363a878af1 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -464,7 +464,7 @@ connect_context_step (NMModemBroadband *self) nm_log_warn (LOGD_MB, "(%s): Failed to connect '%s': %s", nm_modem_get_uid (NM_MODEM (self)), nm_connection_get_id (ctx->connection), - error ? error->message : "unknown error"); + error->message); g_clear_error (&error); g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED); @@ -734,7 +734,7 @@ set_power_state_low_ready (MMModem *modem, /* Log but ignore errors; not all modems support low power state */ nm_log_dbg (LOGD_MB, "(%s): failed to set modem low power state: %s", nm_modem_get_uid (NM_MODEM (self)), - error && error->message ? error->message : "(unknown)"); + NM_G_ERROR_MSG (error)); g_clear_error (&error); } @@ -759,7 +759,7 @@ modem_disable_ready (MMModem *modem_iface, } else { nm_log_warn (LOGD_MB, "(%s): failed to disable modem: %s", nm_modem_get_uid (NM_MODEM (self)), - error && error->message ? error->message : "(unknown)"); + NM_G_ERROR_MSG (error)); nm_modem_set_prev_state (NM_MODEM (self), "disable failed"); g_clear_error (&error); } @@ -778,7 +778,7 @@ modem_enable_ready (MMModem *modem_iface, if (!mm_modem_enable_finish (modem_iface, res, &error)) { nm_log_warn (LOGD_MB, "(%s) failed to enable modem: %s", nm_modem_get_uid (NM_MODEM (self)), - error && error->message ? error->message : "(unknown)"); + NM_G_ERROR_MSG (error)); nm_modem_set_prev_state (NM_MODEM (self), "enable failed"); g_clear_error (&error); } @@ -1259,7 +1259,7 @@ get_sim_ready (MMModem *modem, } else { nm_log_warn (LOGD_MB, "(%s): failed to retrieve SIM object: %s", nm_modem_get_uid (NM_MODEM (self)), - error && error->message ? error->message : "(unknown)"); + NM_G_ERROR_MSG (error)); } g_clear_error (&error); g_object_unref (self); diff --git a/src/devices/wwan/nm-modem-manager.c b/src/devices/wwan/nm-modem-manager.c index 79082c410c..e26321b0a4 100644 --- a/src/devices/wwan/nm-modem-manager.c +++ b/src/devices/wwan/nm-modem-manager.c @@ -145,7 +145,7 @@ modem_object_added (MMManager *modem_manager, handle_new_modem (self, modem); else { nm_log_warn (LOGD_MB, "failed to create modem: %s", - error ? error->message : "(unknown)"); + error->message); } g_clear_error (&error); } diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index c1736ecf84..b01f0139d0 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -547,8 +547,8 @@ ppp_stage3_ip_config_start (NMModem *self, } else { nm_log_err (LOGD_PPP, "(%s): error starting PPP: (%d) %s", nm_modem_get_uid (self), - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->code, + error->message); g_error_free (error); nm_exported_object_clear_and_unexport (&priv->ppp_manager); diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c index bc4345fe6c..feeada62b6 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient.c +++ b/src/dhcp-manager/nm-dhcp-dhclient.c @@ -380,8 +380,8 @@ dhclient_start (NMDhcpClient *client, if (!success) { nm_log_warn (log_domain, "(%s): failed to save DUID to %s: (%d) %s.", iface, priv->lease_file, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->code, + error->message); g_free (pid_file); return FALSE; } @@ -591,8 +591,8 @@ get_duid (NMDhcpClient *client) if (error) { nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': (%d) %s", priv->def_leasefile, - error ? error->code : -1, - error ? error->message : "(unknown)"); + error->code, + error->message); g_clear_error (&error); } } diff --git a/src/dns-manager/nm-dns-dnsmasq.c b/src/dns-manager/nm-dns-dnsmasq.c index 8663dfd81c..1a9b71587a 100644 --- a/src/dns-manager/nm-dns-dnsmasq.c +++ b/src/dns-manager/nm-dns-dnsmasq.c @@ -285,8 +285,7 @@ update (NMDnsPlugin *plugin, if (!g_file_set_contents (CONFFILE, conf->str, -1, &error)) { nm_log_warn (LOGD_DNS, "Failed to write dnsmasq config file %s: (%d) %s", CONFFILE, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->code, error->message); g_clear_error (&error); goto out; } diff --git a/src/dns-manager/nm-dns-plugin.c b/src/dns-manager/nm-dns-plugin.c index 8313ed13cd..0bfd94abd3 100644 --- a/src/dns-manager/nm-dns-plugin.c +++ b/src/dns-manager/nm-dns-plugin.c @@ -176,8 +176,7 @@ nm_dns_plugin_child_spawn (NMDnsPlugin *self, priv->watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) watch_cb, self); } else { nm_log_warn (LOGD_DNS, "Failed to spawn %s: (%d) %s", - priv->progname, error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + priv->progname, error->code, error->message); g_clear_error (&error); } diff --git a/src/main.c b/src/main.c index 9495a9eff1..4657ffe250 100644 --- a/src/main.c +++ b/src/main.c @@ -216,8 +216,7 @@ print_config (NMConfigCmdLineOptions *config_cli) config = nm_config_new (config_cli, NULL, &error); if (config == NULL) { - fprintf (stderr, _("Failed to read configuration: %s\n"), - (error && error->message) ? error->message : _("unknown")); + fprintf (stderr, _("Failed to read configuration: %s\n"), error->message); return 7; } @@ -360,8 +359,8 @@ main (int argc, char *argv[]) config_cli = NULL; if (config == NULL) { fprintf (stderr, _("Failed to read configuration: (%d) %s\n"), - error ? error->code : -1, - (error && error->message) ? error->message : _("unknown")); + error->code, + error->message); exit (1); } @@ -415,8 +414,8 @@ main (int argc, char *argv[]) if (!parse_state_file (global_opt.state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &error)) { nm_log_err (LOGD_CORE, "State file %s parsing failed: (%d) %s", global_opt.state_file, - error ? error->code : -1, - (error && error->message) ? error->message : _("unknown")); + error->code, + error->message); /* Not a hard failure */ } g_clear_error (&error); diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index 17b1d75dca..ed539b6898 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -304,8 +304,7 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared) if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, &status, &error)) { nm_log_warn (LOGD_SHARING, "Error executing command: (%d) %s", - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + error->code, error->message); g_clear_error (&error); } else if (WEXITSTATUS (status)) { nm_log_warn (LOGD_SHARING, "** Command returned exit status %d.", diff --git a/src/nm-manager.c b/src/nm-manager.c index a99d77fffb..e463fc025f 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1627,7 +1627,7 @@ get_existing_connection (NMManager *self, NMDevice *device, gboolean *out_genera _LOGW (LOGD_SETTINGS, "(%s) Couldn't save generated connection '%s': %s", nm_device_get_iface (device), nm_connection_get_id (connection), - (error && error->message) ? error->message : "(unknown)"); + error->message); g_clear_error (&error); } g_object_unref (connection); @@ -1660,8 +1660,8 @@ assume_connection (NMManager *self, NMDevice *device, NMSettingsConnection *conn if (!active) { _LOGW (LOGD_DEVICE, "assumed connection %s failed to activate: (%d) %s", nm_connection_get_path (NM_CONNECTION (connection)), - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->code, + error->message); g_error_free (error); return FALSE; } @@ -3671,7 +3671,6 @@ deactivate_net_auth_done_cb (NMAuthChain *chain, path = nm_auth_chain_get_data (chain, "path"); result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL); - active = active_connection_get_by_path (self, path); if (auth_error) { _LOGD (LOGD_CORE, "Disconnect request failed: %s", auth_error->message); @@ -3689,9 +3688,10 @@ deactivate_net_auth_done_cb (NMAuthChain *chain, path, NM_DEVICE_STATE_REASON_USER_REQUESTED, &error)) - g_assert (error); + nm_assert (error); } + active = active_connection_get_by_path (self, path); if (active) { nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DEACTIVATE, nm_active_connection_get_settings_connection (active), @@ -4011,8 +4011,8 @@ _internal_enable (NMManager *self, gboolean enable) /* Not a hard error */ _LOGW (LOGD_SUSPEND, "writing to state file %s failed: (%d) %s.", priv->state_file, - err ? err->code : -1, - (err && err->message) ? err->message : "unknown"); + err->code, + err->message); } } @@ -4973,8 +4973,8 @@ manager_radio_user_toggled (NMManager *self, &error)) { _LOGW (LOGD_CORE, "writing to state file %s failed: (%d) %s.", priv->state_file, - error ? error->code : -1, - (error && error->message) ? error->message : "unknown"); + error->code, + error->message); g_clear_error (&error); } } diff --git a/src/nm-policy.c b/src/nm-policy.c index 68e50a1c1a..b54468167c 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -697,8 +697,8 @@ auto_activate_device (gpointer user_data) &error)) { nm_log_info (LOGD_DEVICE, "Connection '%s' auto-activation failed: (%d) %s", nm_settings_connection_get_id (best_connection), - error ? error->code : -1, - error ? error->message : "(none)"); + error->code, + error->message); g_error_free (error); } g_object_unref (subject); @@ -1090,8 +1090,8 @@ activate_secondary_connections (NMPolicy *policy, else { nm_log_warn (LOGD_DEVICE, "Secondary connection '%s (%s)' auto-activation failed: (%d) %s", nm_settings_connection_get_id (settings_con), sec_uuid, - error ? error->code : 0, - (error && error->message) ? error->message : "unknown"); + error->code, + error->message); g_clear_error (&error); success = FALSE; break; diff --git a/src/ppp-manager/nm-pppd-plugin.c b/src/ppp-manager/nm-pppd-plugin.c index be4dd1855b..a4dd4af7c1 100644 --- a/src/ppp-manager/nm-pppd-plugin.c +++ b/src/ppp-manager/nm-pppd-plugin.c @@ -304,8 +304,8 @@ get_credentials (char *username, char *password) if (!ret) { g_warning ("nm-ppp-plugin: (%s): could not get secrets: (%d) %s", __func__, - err ? err->code : -1, - err->message ? err->message : "(unknown)"); + err->code, + err->message); g_error_free (err); return -1; } diff --git a/src/settings/nm-agent-manager.c b/src/settings/nm-agent-manager.c index bc09e03167..a165f87fcd 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -989,7 +989,7 @@ _con_get_request_start_validated (NMAuthChain *chain, if (error) { _LOGD (req->current, "agent "LOG_REQ_FMT" MODIFY check error: (%d) %s", LOG_REQ_ARG (req), - error->code, error->message ? error->message : "(unknown)"); + error->code, error->message); /* Try the next agent */ request_next_agent (req); } else { diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index a1695b3461..72f571fb52 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -885,7 +885,7 @@ new_secrets_commit_cb (NMSettingsConnection *self, { if (error) { _LOGW ("Error saving new secrets to backing storage: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + error->code, error->message); } } @@ -1089,16 +1089,16 @@ get_secrets_done_cb (NMAgentManager *manager, _LOGD ("(%s:%p) failed to update with agent secrets: (%d) %s", setting_name, info, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + local->code, + local->message); } g_variant_unref (filtered_secrets); } else { _LOGD ("(%s:%p) failed to update with existing secrets: (%d) %s", setting_name, info, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + local->code, + local->message); } applied_connection = info->applied_connection; diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index ee48e7119f..07a8c2e642 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -1120,7 +1120,7 @@ nm_settings_add_connection (NMSettings *self, nm_log_dbg (LOGD_SETTINGS, "Failed to add %s/'%s': %s", nm_connection_get_uuid (connection), nm_connection_get_id (connection), - add_error ? add_error->message : "(unknown)"); + add_error->message); g_clear_error (&add_error); } @@ -1211,7 +1211,7 @@ pk_add_cb (NMAuthChain *chain, error = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Error checking authorization: %s", - chain_error->message ? chain_error->message : "(unknown)"); + chain_error->message); } else if (result != NM_AUTH_CALL_RESULT_YES) { error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_PERMISSION_DENIED, @@ -1294,7 +1294,7 @@ nm_settings_add_connection_dbus (NMSettings *self, error = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "The connection was invalid: %s", - tmp_error ? tmp_error->message : "(unknown)"); + tmp_error->message); g_error_free (tmp_error); goto done; } @@ -1625,7 +1625,7 @@ pk_hostname_cb (NMAuthChain *chain, error = g_error_new (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Error checking authorization: %s", - chain_error->message ? chain_error->message : "(unknown)"); + chain_error->message); } else if (result != NM_AUTH_CALL_RESULT_YES) { error = g_error_new_literal (NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_PERMISSION_DENIED, @@ -1896,7 +1896,7 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self) if (!added) { nm_log_warn (LOGD_SETTINGS, "(%s) couldn't create default wired connection: %s", nm_device_get_iface (device), - (error && error->message) ? error->message : "(unknown)"); + error->message); g_clear_error (&error); return; } diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c index 19de1db625..8122fb2c74 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -98,8 +98,7 @@ constructor (GType type, nm_log_warn (LOGD_SETTINGS, "%s.%d - invalid connection read from /etc/network/interfaces: (%d) %s", __FILE__, __LINE__, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->code, error->message); goto err; } diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index 29a1141b8e..b948023a47 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -406,8 +406,8 @@ read_connections (NMSettingsPlugin *config) if (!dir) { nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': (%d) %s", nm_keyfile_plugin_get_path (), - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->code, + error->message); g_clear_error (&error); return; } |