Commit 01b9b410 authored by Thomas Haller's avatar Thomas Haller

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's avatarDan Winship <danw@gnome.org>
parent 7871d850
...@@ -2302,7 +2302,7 @@ nmc_activate_connection (NmCli *nmc, ...@@ -2302,7 +2302,7 @@ nmc_activate_connection (NmCli *nmc,
/* Virtual connection may not have their interfaces created yet */ /* Virtual connection may not have their interfaces created yet */
if (!device_found && !nm_connection_is_virtual (connection)) { if (!device_found && !nm_connection_is_virtual (connection)) {
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_CON_ACTIVATION, 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); g_clear_error (&local);
return FALSE; return FALSE;
} }
...@@ -2450,8 +2450,8 @@ do_connection_up (NmCli *nmc, int argc, char **argv) ...@@ -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)) { if (!nmc_activate_connection (nmc, connection, ifname, ap, nsp, pwds, activate_connection_cb, &error)) {
g_string_printf (nmc->return_text, _("Error: %s."), g_string_printf (nmc->return_text, _("Error: %s."),
error ? error->message : _("unknown error")); error->message);
nmc->return_value = error ? error->code : NMC_RESULT_ERROR_CON_ACTIVATION; nmc->return_value = error->code;
g_clear_error (&error); g_clear_error (&error);
nmc->should_wait--; nmc->should_wait--;
goto error; goto error;
...@@ -10724,7 +10724,7 @@ do_connection_export (NmCli *nmc, int argc, char **argv) ...@@ -10724,7 +10724,7 @@ do_connection_export (NmCli *nmc, int argc, char **argv)
if (!nm_vpn_editor_plugin_export (plugin, path, connection, &error)) { if (!nm_vpn_editor_plugin_export (plugin, path, connection, &error)) {
g_string_printf (nmc->return_text, _("Error: failed to export '%s': %s."), 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; nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto finish; goto finish;
} }
......
...@@ -812,8 +812,8 @@ nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active) ...@@ -812,8 +812,8 @@ nm_client_deactivate_connection (NMClient *client, NMActiveConnection *active)
DBUS_TYPE_G_OBJECT_PATH, path, DBUS_TYPE_G_OBJECT_PATH, path,
G_TYPE_INVALID, G_TYPE_INVALID,
G_TYPE_INVALID)) { G_TYPE_INVALID)) {
g_warning ("Could not deactivate connection '%s': %s", g_warning ("Could not deactivate connection '%s': %s",
path, error ? error->message : "(unknown)"); path, NM_G_ERROR_MSG (error));
g_clear_error (&error); g_clear_error (&error);
} }
} }
......
...@@ -2202,8 +2202,8 @@ device_operation_cb (DBusGProxy *proxy, ...@@ -2202,8 +2202,8 @@ device_operation_cb (DBusGProxy *proxy,
__func__, __func__,
nm_object_get_path (NM_OBJECT (info->device)), nm_object_get_path (NM_OBJECT (info->device)),
info->method, info->method,
error ? error->code : -1, error->code,
error && error->message ? error->message : "(unknown)"); NM_G_ERROR_MSG (error));
} }
g_clear_error (&error); g_clear_error (&error);
......
...@@ -457,8 +457,7 @@ replace_settings (NMRemoteConnection *self, GHashTable *new_settings) ...@@ -457,8 +457,7 @@ replace_settings (NMRemoteConnection *self, GHashTable *new_settings)
g_warning ("%s: error updating connection %s settings: (%d) %s", g_warning ("%s: error updating connection %s settings: (%d) %s",
__func__, __func__,
nm_connection_get_path (NM_CONNECTION (self)), nm_connection_get_path (NM_CONNECTION (self)),
error ? error->code : -1, error->code, error->message);
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error); g_clear_error (&error);
g_signal_emit (self, signals[REMOVED], 0); g_signal_emit (self, signals[REMOVED], 0);
......
...@@ -331,8 +331,7 @@ verify_request (NMSecretAgent *self, ...@@ -331,8 +331,7 @@ verify_request (NMSecretAgent *self,
NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, NM_SECRET_AGENT_ERROR_INVALID_CONNECTION,
"Invalid connection: (%d) %s", "Invalid connection: (%d) %s",
local ? local->code : -1, local->code, local->message);
(local && local->message) ? local->message : "(unknown)");
g_clear_error (&local); g_clear_error (&local);
} }
......
...@@ -1515,8 +1515,7 @@ nm_utils_uuid_generate_from_string (const char *s) ...@@ -1515,8 +1515,7 @@ nm_utils_uuid_generate_from_string (const char *s)
if (!nm_utils_init (&error)) { if (!nm_utils_init (&error)) {
g_warning ("error initializing crypto: (%d) %s", g_warning ("error initializing crypto: (%d) %s",
error ? error->code : 0, error->code, error->message);
error ? error->message : "unknown");
if (error) if (error)
g_error_free (error); g_error_free (error);
return NULL; return NULL;
...@@ -1524,8 +1523,7 @@ nm_utils_uuid_generate_from_string (const char *s) ...@@ -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)) { if (!crypto_md5_hash (NULL, 0, s, strlen (s), (char *) uuid, sizeof (uuid), &error)) {
g_warning ("error generating UUID: (%d) %s", g_warning ("error generating UUID: (%d) %s",
error ? error->code : 0, error->code, error->message);
error ? error->message : "unknown");
if (error) if (error)
g_error_free (error); g_error_free (error);
return NULL; return NULL;
......
...@@ -567,8 +567,8 @@ replace_settings (NMRemoteConnection *self, GVariant *new_settings) ...@@ -567,8 +567,8 @@ replace_settings (NMRemoteConnection *self, GVariant *new_settings)
g_warning ("%s: error updating connection %s settings: (%d) %s", g_warning ("%s: error updating connection %s settings: (%d) %s",
__func__, __func__,
nm_connection_get_path (NM_CONNECTION (self)), nm_connection_get_path (NM_CONNECTION (self)),
error ? error->code : -1, error->code,
(error && error->message) ? error->message : "(unknown)"); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
} }
......
...@@ -154,7 +154,7 @@ inline static void ...@@ -154,7 +154,7 @@ inline static void
_nmtst_assert_success (gboolean success, GError *error, const char *file, int line) _nmtst_assert_success (gboolean success, GError *error, const char *file, int line)
{ {
if (!success || error) 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__) #define nmtst_assert_success(success, error) _nmtst_assert_success ((success), (error), __FILE__, __LINE__)
......
...@@ -247,8 +247,7 @@ pan_connection_check_create (NMBluezDevice *self) ...@@ -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); nm_log_dbg (LOGD_BT, "bluez[%s] added new Bluetooth connection for NAP device: '%s' (%s)", priv->path, id, uuid);
} else { } else {
nm_log_warn (LOGD_BT, "bluez[%s] couldn't add new Bluetooth connection for NAP device: '%s' (%s): %d / %s", 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, priv->path, id, uuid, error->code, error->message);
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error); g_clear_error (&error);
} }
......
...@@ -231,8 +231,7 @@ on_proxy_acquired (GObject *object, ...@@ -231,8 +231,7 @@ on_proxy_acquired (GObject *object,
priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error); priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
if (!priv->proxy) { if (!priv->proxy) {
nm_log_warn (LOGD_BT, "Couldn't acquire object manager proxy: %s", nm_log_warn (LOGD_BT, "Couldn't acquire object manager proxy: %s", error->message);
error && error->message ? error->message : "(unknown)");
g_clear_error (&error); g_clear_error (&error);
return; return;
} }
......
...@@ -498,7 +498,7 @@ modem_ip4_config_result (NMModem *modem, ...@@ -498,7 +498,7 @@ modem_ip4_config_result (NMModem *modem,
if (error) { if (error) {
_LOGW (LOGD_MB | LOGD_IP4 | LOGD_BT, _LOGW (LOGD_MB | LOGD_IP4 | LOGD_BT,
"retrieving IP4 configuration failed: (%d) %s", "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); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
} else } else
...@@ -728,8 +728,7 @@ bluez_connect_cb (GObject *object, ...@@ -728,8 +728,7 @@ bluez_connect_cb (GObject *object,
res, &error); res, &error);
if (!device) { if (!device) {
_LOGW (LOGD_BT, "Error connecting with bluez: %s", _LOGW (LOGD_BT, "Error connecting with bluez: %s", error->message);
error && error->message ? error->message : "(unknown)");
g_clear_error (&error); g_clear_error (&error);
nm_device_state_changed (NM_DEVICE (self), nm_device_state_changed (NM_DEVICE (self),
......
...@@ -177,7 +177,7 @@ _update_s390_subchannels (NMDeviceEthernet *self) ...@@ -177,7 +177,7 @@ _update_s390_subchannels (NMDeviceEthernet *self)
dir = g_dir_open (parent_path, 0, &error); dir = g_dir_open (parent_path, 0, &error);
if (!dir) { if (!dir) {
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to open directory '%s': %s", _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); g_clear_error (&error);
goto out; goto out;
} }
...@@ -597,13 +597,13 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, ...@@ -597,13 +597,13 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
if (!success) { if (!success) {
_LOGE (LOGD_DEVICE | LOGD_ETHER, _LOGE (LOGD_DEVICE | LOGD_ETHER,
"Activation: (ethernet) couldn't send security configuration to the supplicant: %s", "Activation: (ethernet) couldn't send security configuration to the supplicant: %s",
error ? error->message : "<BUG>"); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
} else { } else {
_LOGE (LOGD_DEVICE | LOGD_ETHER, _LOGE (LOGD_DEVICE | LOGD_ETHER,
"Activation: (ethernet) couldn't build security configuration: %s", "Activation: (ethernet) couldn't build security configuration: %s",
error ? error->message : "<BUG>"); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
......
...@@ -355,7 +355,7 @@ read_device_factory_paths (void) ...@@ -355,7 +355,7 @@ read_device_factory_paths (void)
if (!dir) { if (!dir) {
nm_log_warn (LOGD_HW, "device plugin: failed to open directory %s: %s", nm_log_warn (LOGD_HW, "device plugin: failed to open directory %s: %s",
NMPLUGINDIR, NMPLUGINDIR,
(error && error->message) ? error->message : "(unknown)"); error->message);
g_clear_error (&error); g_clear_error (&error);
return NULL; return NULL;
} }
...@@ -499,7 +499,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call ...@@ -499,7 +499,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
factory = create_func (&error); factory = create_func (&error);
if (!factory) { if (!factory) {
nm_log_warn (LOGD_HW, "(%s): failed to initialize device factory: %s", 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_clear_error (&error);
g_module_close (plugin); g_module_close (plugin);
continue; continue;
......
...@@ -2883,7 +2883,7 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master) ...@@ -2883,7 +2883,7 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
&error)) &error))
{ {
_LOGE (LOGD_DEVICE, "master device '%s' failed to update slave connection: %s", _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_error_free (error);
g_object_unref (connection); g_object_unref (connection);
return NULL; return NULL;
...@@ -6631,7 +6631,7 @@ start_sharing (NMDevice *self, NMIP4Config *config) ...@@ -6631,7 +6631,7 @@ start_sharing (NMDevice *self, NMIP4Config *config)
if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, config, &error)) { if (!nm_dnsmasq_manager_start (priv->dnsmasq_manager, config, &error)) {
_LOGE (LOGD_SHARING, "share: (%s) failed to start dnsmasq: %s", _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); g_error_free (error);
nm_act_request_set_shared (req, FALSE); nm_act_request_set_shared (req, FALSE);
return FALSE; return FALSE;
......
...@@ -2491,7 +2491,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) ...@@ -2491,7 +2491,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
if (config == NULL) { if (config == NULL) {
_LOGE (LOGD_DEVICE | LOGD_WIFI, _LOGE (LOGD_DEVICE | LOGD_WIFI,
"Activation: (wifi) couldn't build wireless configuration: %s", "Activation: (wifi) couldn't build wireless configuration: %s",
error ? error->message : "<BUG>"); error->message);
g_clear_error (&error); g_clear_error (&error);
*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; *reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED;
goto out; goto out;
...@@ -2506,7 +2506,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) ...@@ -2506,7 +2506,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
if (!nm_supplicant_interface_set_config (priv->sup_iface, config, &error)) { if (!nm_supplicant_interface_set_config (priv->sup_iface, config, &error)) {
_LOGE (LOGD_DEVICE | LOGD_WIFI, _LOGE (LOGD_DEVICE | LOGD_WIFI,
"Activation: (wifi) couldn't send wireless configuration to the supplicant: %s", "Activation: (wifi) couldn't send wireless configuration to the supplicant: %s",
error ? error->message : "<BUG>"); error->message);
g_clear_error (&error); g_clear_error (&error);
*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED; *reason = NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED;
goto out; goto out;
......
...@@ -158,7 +158,7 @@ modem_ip4_config_result (NMModem *modem, ...@@ -158,7 +158,7 @@ modem_ip4_config_result (NMModem *modem,
if (error) { if (error) {
_LOGW (LOGD_MB | LOGD_IP4, "retrieving IPv4 configuration failed: (%d) %s", _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); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
} else { } else {
...@@ -185,7 +185,7 @@ modem_ip6_config_result (NMModem *modem, ...@@ -185,7 +185,7 @@ modem_ip6_config_result (NMModem *modem,
if (error) { if (error) {
_LOGW (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: (%d) %s", _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); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return; return;
......
...@@ -464,7 +464,7 @@ connect_context_step (NMModemBroadband *self) ...@@ -464,7 +464,7 @@ connect_context_step (NMModemBroadband *self)
nm_log_warn (LOGD_MB, "(%s): Failed to connect '%s': %s", nm_log_warn (LOGD_MB, "(%s): Failed to connect '%s': %s",
nm_modem_get_uid (NM_MODEM (self)), nm_modem_get_uid (NM_MODEM (self)),
nm_connection_get_id (ctx->connection), nm_connection_get_id (ctx->connection),
error ? error->message : "unknown error"); error->message);
g_clear_error (&error); g_clear_error (&error);
g_signal_emit_by_name (self, NM_MODEM_PREPARE_RESULT, FALSE, NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED); 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, ...@@ -734,7 +734,7 @@ set_power_state_low_ready (MMModem *modem,
/* Log but ignore errors; not all modems support low power state */ /* 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_log_dbg (LOGD_MB, "(%s): failed to set modem low power state: %s",
nm_modem_get_uid (NM_MODEM (self)), nm_modem_get_uid (NM_MODEM (self)),
error && error->message ? error->message : "(unknown)"); NM_G_ERROR_MSG (error));
g_clear_error (&error); g_clear_error (&error);
} }
...@@ -759,7 +759,7 @@ modem_disable_ready (MMModem *modem_iface, ...@@ -759,7 +759,7 @@ modem_disable_ready (MMModem *modem_iface,
} else { } else {
nm_log_warn (LOGD_MB, "(%s): failed to disable modem: %s", nm_log_warn (LOGD_MB, "(%s): failed to disable modem: %s",
nm_modem_get_uid (NM_MODEM (self)), 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"); nm_modem_set_prev_state (NM_MODEM (self), "disable failed");
g_clear_error (&error); g_clear_error (&error);
} }
...@@ -778,7 +778,7 @@ modem_enable_ready (MMModem *modem_iface, ...@@ -778,7 +778,7 @@ modem_enable_ready (MMModem *modem_iface,
if (!mm_modem_enable_finish (modem_iface, res, &error)) { if (!mm_modem_enable_finish (modem_iface, res, &error)) {
nm_log_warn (LOGD_MB, "(%s) failed to enable modem: %s", nm_log_warn (LOGD_MB, "(%s) failed to enable modem: %s",
nm_modem_get_uid (NM_MODEM (self)), 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"); nm_modem_set_prev_state (NM_MODEM (self), "enable failed");
g_clear_error (&error); g_clear_error (&error);
} }
...@@ -1259,7 +1259,7 @@ get_sim_ready (MMModem *modem, ...@@ -1259,7 +1259,7 @@ get_sim_ready (MMModem *modem,
} else { } else {
nm_log_warn (LOGD_MB, "(%s): failed to retrieve SIM object: %s", nm_log_warn (LOGD_MB, "(%s): failed to retrieve SIM object: %s",
nm_modem_get_uid (NM_MODEM (self)), nm_modem_get_uid (NM_MODEM (self)),
error && error->message ? error->message : "(unknown)"); NM_G_ERROR_MSG (error));
} }
g_clear_error (&error); g_clear_error (&error);
g_object_unref (self); g_object_unref (self);
......
...@@ -145,7 +145,7 @@ modem_object_added (MMManager *modem_manager, ...@@ -145,7 +145,7 @@ modem_object_added (MMManager *modem_manager,
handle_new_modem (self, modem); handle_new_modem (self, modem);
else { else {
nm_log_warn (LOGD_MB, "failed to create modem: %s", nm_log_warn (LOGD_MB, "failed to create modem: %s",
error ? error->message : "(unknown)"); error->message);
} }
g_clear_error (&error); g_clear_error (&error);
} }
......
...@@ -547,8 +547,8 @@ ppp_stage3_ip_config_start (NMModem *self, ...@@ -547,8 +547,8 @@ ppp_stage3_ip_config_start (NMModem *self,
} else { } else {
nm_log_err (LOGD_PPP, "(%s): error starting PPP: (%d) %s", nm_log_err (LOGD_PPP, "(%s): error starting PPP: (%d) %s",
nm_modem_get_uid (self), nm_modem_get_uid (self),
error ? error->code : -1, error->code,
error && error->message ? error->message : "(unknown)"); error->message);
g_error_free (error); g_error_free (error);
nm_exported_object_clear_and_unexport (&priv->ppp_manager); nm_exported_object_clear_and_unexport (&priv->ppp_manager);
......
...@@ -380,8 +380,8 @@ dhclient_start (NMDhcpClient *client, ...@@ -380,8 +380,8 @@ dhclient_start (NMDhcpClient *client,
if (!success) { if (!success) {
nm_log_warn (log_domain, "(%s): failed to save DUID to %s: (%d) %s.", nm_log_warn (log_domain, "(%s): failed to save DUID to %s: (%d) %s.",
iface, priv->lease_file, iface, priv->lease_file,
error ? error->code : -1, error->code,
error && error->message ? error->message : "(unknown)"); error->message);
g_free (pid_file); g_free (pid_file);
return FALSE; return FALSE;
} }
...@@ -591,8 +591,8 @@ get_duid (NMDhcpClient *client) ...@@ -591,8 +591,8 @@ get_duid (NMDhcpClient *client)
if (error) { if (error) {
nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': (%d) %s", nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': (%d) %s",
priv->def_leasefile, priv->def_leasefile,
error ? error->code : -1, error->code,
error ? error->message : "(unknown)"); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
} }
......
...@@ -285,8 +285,7 @@ update (NMDnsPlugin *plugin, ...@@ -285,8 +285,7 @@ update (NMDnsPlugin *plugin,
if (!g_file_set_contents (CONFFILE, conf->str, -1, &error)) { if (!g_file_set_contents (CONFFILE, conf->str, -1, &error)) {
nm_log_warn (LOGD_DNS, "Failed to write dnsmasq config file %s: (%d) %s", nm_log_warn (LOGD_DNS, "Failed to write dnsmasq config file %s: (%d) %s",
CONFFILE, CONFFILE,
error ? error->code : -1, error->code, error->message);
error && error->message ? error->message : "(unknown)");
g_clear_error (&error); g_clear_error (&error);
goto out; goto out;
} }
......
...@@ -176,8 +176,7 @@ nm_dns_plugin_child_spawn (NMDnsPlugin *self, ...@@ -176,8 +176,7 @@ nm_dns_plugin_child_spawn (NMDnsPlugin *self,
priv->watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) watch_cb, self); priv->watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) watch_cb, self);
} else { } else {
nm_log_warn (LOGD_DNS, "Failed to spawn %s: (%d) %s", nm_log_warn (LOGD_DNS, "Failed to spawn %s: (%d) %s",
priv->progname, error ? error->code : -1, priv->progname, error->code, error->message);
error && error->message ? error->message : "(unknown)");
g_clear_error (&error); g_clear_error (&error);
} }
......
...@@ -216,8 +216,7 @@ print_config (NMConfigCmdLineOptions *config_cli) ...@@ -216,8 +216,7 @@ print_config (NMConfigCmdLineOptions *config_cli)
config = nm_config_new (config_cli, NULL, &error); config = nm_config_new (config_cli, NULL, &error);
if (config == NULL) { if (config == NULL) {
fprintf (stderr, _("Failed to read configuration: %s\n"), fprintf (stderr, _("Failed to read configuration: %s\n"), error->message);
(error && error->message) ? error->message : _("unknown"));
return 7; return 7;
} }
...@@ -360,8 +359,8 @@ main (int argc, char *argv[]) ...@@ -360,8 +359,8 @@ main (int argc, char *argv[])
config_cli = NULL; config_cli = NULL;
if (config == NULL) { if (config == NULL) {
fprintf (stderr, _("Failed to read configuration: (%d) %s\n"), fprintf (stderr, _("Failed to read configuration: (%d) %s\n"),
error ? error->code : -1, error->code,
(error && error->message) ? error->message : _("unknown")); error->message);
exit (1); exit (1);
} }
...@@ -415,8 +414,8 @@ main (int argc, char *argv[]) ...@@ -415,8 +414,8 @@ main (int argc, char *argv[])
if (!parse_state_file (global_opt.state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &error)) { 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", nm_log_err (LOGD_CORE, "State file %s parsing failed: (%d) %s",
global_opt.state_file, global_opt.state_file,
error ? error->code : -1, error->code,
(error && error->message) ? error->message : _("unknown")); error->message);
/* Not a hard failure */ /* Not a hard failure */
} }
g_clear_error (&error); g_clear_error (&error);
......
...@@ -304,8 +304,7 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared) ...@@ -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, if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL, NULL, NULL, &status, &error)) { NULL, NULL, NULL, NULL, &status, &error)) {
nm_log_warn (LOGD_SHARING, "Error executing command: (%d) %s", nm_log_warn (LOGD_SHARING, "Error executing command: (%d) %s",
error ? error->code : -1, error->code, error->message);
(error && error->message) ? error->message : "(unknown)");
g_clear_error (&error); g_clear_error (&error);
} else if (WEXITSTATUS (status)) { } else if (WEXITSTATUS (status)) {
nm_log_warn (LOGD_SHARING, "** Command returned exit status %d.", nm_log_warn (LOGD_SHARING, "** Command returned exit status %d.",
......
...@@ -1627,7 +1627,7 @@ get_existing_connection (NMManager *self, NMDevice *device, gboolean *out_genera ...@@ -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", _LOGW (LOGD_SETTINGS, "(%s) Couldn't save generated connection '%s': %s",
nm_device_get_iface (device), nm_device_get_iface (device),
nm_connection_get_id (connection), nm_connection_get_id (connection),
(error && error->message) ? error->message : "(unknown)"); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
g_object_unref (connection); g_object_unref (connection);
...@@ -1660,8 +1660,8 @@ assume_connection (NMManager *self, NMDevice *device, NMSettingsConnection *conn ...@@ -1660,8 +1660,8 @@ assume_connection (NMManager *self, NMDevice *device, NMSettingsConnection *conn
if (!active) { if (!active) {
_LOGW (LOGD_DEVICE, "assumed connection %s failed to activate: (%d) %s", _LOGW (LOGD_DEVICE, "assumed connection %s failed to activate: (%d) %s",
nm_connection_get_path (NM_CONNECTION (connection)), nm_connection_get_path (NM_CONNECTION (connection)),
error ? error->code : -1, error->code,
error && error->message ? error->message : "(unknown)"); error->message);
g_error_free (error); g_error_free (error);
return FALSE; return FALSE;
} }
...@@ -3671,7 +3671,6 @@ deactivate_net_auth_done_cb (NMAuthChain *chain, ...@@ -3671,7 +3671,6 @@ deactivate_net_auth_done_cb (NMAuthChain *chain,
path = nm_auth_chain_get_data (chain, "path"); path = nm_auth_chain_get_data (chain, "path");
result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL); result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL);
active = active_connection_get_by_path (self, path);
if (auth_error) { if (auth_error) {
_LOGD (LOGD_CORE, "Disconnect request failed: %s", auth_error->message); _LOGD (LOGD_CORE, "Disconnect request failed: %s", auth_error->message);
...@@ -3689,9 +3688,10 @@ deactivate_net_auth_done_cb (NMAuthChain *chain, ...@@ -3689,9 +3688,10 @@ deactivate_net_auth_done_cb (NMAuthChain *chain,
path, path,
NM_DEVICE_STATE_REASON_USER_REQUESTED, NM_DEVICE_STATE_REASON_USER_REQUESTED,
&error)) &error))
g_assert (error);