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>
This commit is contained in:
Thomas Haller
2016-02-28 16:25:36 +01:00
parent 7871d850f5
commit 01b9b4104c
32 changed files with 79 additions and 91 deletions

View File

@@ -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)
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)
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;
} }

View File

@@ -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);
} }
} }

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
} }

View File

@@ -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)
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;

View File

@@ -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);
} }
} }

View File

@@ -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__)

View File

@@ -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);
} }

View File

@@ -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;
} }

View File

@@ -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,
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),

View File

@@ -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,
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);
} }

View File

@@ -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
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;

View File

@@ -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)
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;

View File

@@ -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)
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;

View File

@@ -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,
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;

View File

@@ -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,
/* 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,
} 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,
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,
} 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);

View File

@@ -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);
} }

View File

@@ -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);

View File

@@ -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)
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);
} }
} }

View File

@@ -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;
} }

View File

@@ -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);
} }

View File

@@ -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[])
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[])
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);

View File

@@ -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.",

View File

@@ -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
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,
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,
path, path,
NM_DEVICE_STATE_REASON_USER_REQUESTED, NM_DEVICE_STATE_REASON_USER_REQUESTED,
&error)) &error))
g_assert (error); nm_assert (error);
} }
active = active_connection_get_by_path (self, path);
if (active) { if (active) {
nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DEACTIVATE, nm_audit_log_connection_op (NM_AUDIT_OP_CONN_DEACTIVATE,
nm_active_connection_get_settings_connection (active), nm_active_connection_get_settings_connection (active),
@@ -4011,8 +4011,8 @@ _internal_enable (NMManager *self, gboolean enable)
/* Not a hard error */ /* Not a hard error */
_LOGW (LOGD_SUSPEND, "writing to state file %s failed: (%d) %s.", _LOGW (LOGD_SUSPEND, "writing to state file %s failed: (%d) %s.",
priv->state_file, priv->state_file,
err ? err->code : -1, err->code,
(err && err->message) ? err->message : "unknown"); err->message);
} }
} }
@@ -4973,8 +4973,8 @@ manager_radio_user_toggled (NMManager *self,
&error)) { &error)) {
_LOGW (LOGD_CORE, "writing to state file %s failed: (%d) %s.", _LOGW (LOGD_CORE, "writing to state file %s failed: (%d) %s.",
priv->state_file, priv->state_file,
error ? error->code : -1, error->code,
(error && error->message) ? error->message : "unknown"); error->message);
g_clear_error (&error); g_clear_error (&error);
} }
} }

View File

@@ -697,8 +697,8 @@ auto_activate_device (gpointer user_data)
&error)) { &error)) {
nm_log_info (LOGD_DEVICE, "Connection '%s' auto-activation failed: (%d) %s", nm_log_info (LOGD_DEVICE, "Connection '%s' auto-activation failed: (%d) %s",
nm_settings_connection_get_id (best_connection), nm_settings_connection_get_id (best_connection),
error ? error->code : -1, error->code,
error ? error->message : "(none)"); error->message);
g_error_free (error); g_error_free (error);
} }
g_object_unref (subject); g_object_unref (subject);
@@ -1090,8 +1090,8 @@ activate_secondary_connections (NMPolicy *policy,
else { else {
nm_log_warn (LOGD_DEVICE, "Secondary connection '%s (%s)' auto-activation failed: (%d) %s", nm_log_warn (LOGD_DEVICE, "Secondary connection '%s (%s)' auto-activation failed: (%d) %s",
nm_settings_connection_get_id (settings_con), sec_uuid, nm_settings_connection_get_id (settings_con), sec_uuid,
error ? error->code : 0, error->code,
(error && error->message) ? error->message : "unknown"); error->message);
g_clear_error (&error); g_clear_error (&error);
success = FALSE; success = FALSE;
break; break;

View File

@@ -304,8 +304,8 @@ get_credentials (char *username, char *password)
if (!ret) { if (!ret) {
g_warning ("nm-ppp-plugin: (%s): could not get secrets: (%d) %s", g_warning ("nm-ppp-plugin: (%s): could not get secrets: (%d) %s",
__func__, __func__,
err ? err->code : -1, err->code,
err->message ? err->message : "(unknown)"); err->message);
g_error_free (err); g_error_free (err);
return -1; return -1;
} }

View File

@@ -989,7 +989,7 @@ _con_get_request_start_validated (NMAuthChain *chain,
if (error) { if (error) {
_LOGD (req->current, "agent "LOG_REQ_FMT" MODIFY check error: (%d) %s", _LOGD (req->current, "agent "LOG_REQ_FMT" MODIFY check error: (%d) %s",
LOG_REQ_ARG (req), LOG_REQ_ARG (req),
error->code, error->message ? error->message : "(unknown)"); error->code, error->message);
/* Try the next agent */ /* Try the next agent */
request_next_agent (req); request_next_agent (req);
} else { } else {

View File

@@ -885,7 +885,7 @@ new_secrets_commit_cb (NMSettingsConnection *self,
{ {
if (error) { if (error) {
_LOGW ("Error saving new secrets to backing storage: (%d) %s", _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", _LOGD ("(%s:%p) failed to update with agent secrets: (%d) %s",
setting_name, setting_name,
info, info,
local ? local->code : -1, local->code,
(local && local->message) ? local->message : "(unknown)"); local->message);
} }
g_variant_unref (filtered_secrets); g_variant_unref (filtered_secrets);
} else { } else {
_LOGD ("(%s:%p) failed to update with existing secrets: (%d) %s", _LOGD ("(%s:%p) failed to update with existing secrets: (%d) %s",
setting_name, setting_name,
info, info,
local ? local->code : -1, local->code,
(local && local->message) ? local->message : "(unknown)"); local->message);
} }
applied_connection = info->applied_connection; applied_connection = info->applied_connection;

View File

@@ -1120,7 +1120,7 @@ nm_settings_add_connection (NMSettings *self,
nm_log_dbg (LOGD_SETTINGS, "Failed to add %s/'%s': %s", nm_log_dbg (LOGD_SETTINGS, "Failed to add %s/'%s': %s",
nm_connection_get_uuid (connection), nm_connection_get_uuid (connection),
nm_connection_get_id (connection), nm_connection_get_id (connection),
add_error ? add_error->message : "(unknown)"); add_error->message);
g_clear_error (&add_error); g_clear_error (&add_error);
} }
@@ -1211,7 +1211,7 @@ pk_add_cb (NMAuthChain *chain,
error = g_error_new (NM_SETTINGS_ERROR, error = g_error_new (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_FAILED, NM_SETTINGS_ERROR_FAILED,
"Error checking authorization: %s", "Error checking authorization: %s",
chain_error->message ? chain_error->message : "(unknown)"); chain_error->message);
} else if (result != NM_AUTH_CALL_RESULT_YES) { } else if (result != NM_AUTH_CALL_RESULT_YES) {
error = g_error_new_literal (NM_SETTINGS_ERROR, error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED, NM_SETTINGS_ERROR_PERMISSION_DENIED,
@@ -1294,7 +1294,7 @@ nm_settings_add_connection_dbus (NMSettings *self,
error = g_error_new (NM_SETTINGS_ERROR, error = g_error_new (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_CONNECTION, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"The connection was invalid: %s", "The connection was invalid: %s",
tmp_error ? tmp_error->message : "(unknown)"); tmp_error->message);
g_error_free (tmp_error); g_error_free (tmp_error);
goto done; goto done;
} }
@@ -1625,7 +1625,7 @@ pk_hostname_cb (NMAuthChain *chain,
error = g_error_new (NM_SETTINGS_ERROR, error = g_error_new (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_FAILED, NM_SETTINGS_ERROR_FAILED,
"Error checking authorization: %s", "Error checking authorization: %s",
chain_error->message ? chain_error->message : "(unknown)"); chain_error->message);
} else if (result != NM_AUTH_CALL_RESULT_YES) { } else if (result != NM_AUTH_CALL_RESULT_YES) {
error = g_error_new_literal (NM_SETTINGS_ERROR, error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED, NM_SETTINGS_ERROR_PERMISSION_DENIED,
@@ -1896,7 +1896,7 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self)
if (!added) { if (!added) {
nm_log_warn (LOGD_SETTINGS, "(%s) couldn't create default wired connection: %s", nm_log_warn (LOGD_SETTINGS, "(%s) couldn't create default wired connection: %s",
nm_device_get_iface (device), nm_device_get_iface (device),
(error && error->message) ? error->message : "(unknown)"); error->message);
g_clear_error (&error); g_clear_error (&error);
return; return;
} }

View File

@@ -98,8 +98,7 @@ constructor (GType type,
nm_log_warn (LOGD_SETTINGS, "%s.%d - invalid connection read from /etc/network/interfaces: (%d) %s", nm_log_warn (LOGD_SETTINGS, "%s.%d - invalid connection read from /etc/network/interfaces: (%d) %s",
__FILE__, __FILE__,
__LINE__, __LINE__,
error ? error->code : -1, error->code, error->message);
error && error->message ? error->message : "(unknown)");
goto err; goto err;
} }

View File

@@ -406,8 +406,8 @@ read_connections (NMSettingsPlugin *config)
if (!dir) { if (!dir) {
nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': (%d) %s", nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': (%d) %s",
nm_keyfile_plugin_get_path (), nm_keyfile_plugin_get_path (),
error ? error->code : -1, error->code,
error && error->message ? error->message : "(unknown)"); error->message);
g_clear_error (&error); g_clear_error (&error);
return; return;
} }