diff options
author | Thomas Haller <thaller@redhat.com> | 2016-03-03 19:08:40 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-03-03 19:08:40 +0100 |
commit | 21ff0420511975ec3669563f48c0288717c84b66 (patch) | |
tree | 1dbe34839e59cf1d1d61e63dc3da56034a4c3508 | |
parent | 99b37d768f6100aaec6767e85a6f9e70ff4354e1 (diff) | |
parent | cd4f84b7381707bff6e5fcc3cee84492e12c6879 (diff) | |
download | NetworkManager-21ff0420511975ec3669563f48c0288717c84b66.tar.gz |
all: merge branch 'danw/gerror-bgo762868'
https://bugzilla.gnome.org/show_bug.cgi?id=762868
47 files changed, 174 insertions, 195 deletions
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c index de13bd0de3..7ddffb0493 100644 --- a/callouts/nm-dispatcher.c +++ b/callouts/nm-dispatcher.c @@ -549,8 +549,7 @@ script_dispatch (ScriptInfo *script) request->num_scripts_nowait++; return TRUE; } else { - _LOG_S_W (script, "complete: failed to execute script: %s (%d)", - error->message, error->code); + _LOG_S_W (script, "complete: failed to execute script: %s", error->message); script->result = DISPATCH_RESULT_EXEC_FAILED; script->error = g_strdup (error->message); request->num_scripts_done++; @@ -594,8 +593,8 @@ find_scripts (const char *str_action) dirname = NMD_SCRIPT_DIR_DEFAULT; if (!(dir = g_dir_open (dirname, 0, &error))) { - g_message ("find-scripts: Failed to open dispatcher directory '%s': (%d) %s", - dirname, error->code, error->message); + g_message ("find-scripts: Failed to open dispatcher directory '%s': %s", + dirname, error->message); g_error_free (error); return NULL; } diff --git a/clients/cli/connections.c b/clients/cli/connections.c index d263154d22..4cb85f7287 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; @@ -7898,7 +7898,7 @@ load_history_cmds (const char *uuid) filename = g_build_filename (g_get_home_dir (), NMCLI_EDITOR_HISTORY, NULL); kf = g_key_file_new (); if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_KEEP_COMMENTS, &err)) { - if (err->code == G_KEY_FILE_ERROR_PARSE) + if (g_error_matches (err, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_PARSE)) g_print ("Warning: %s parse error: %s\n", filename, err->message); g_key_file_free (kf); g_free (filename); @@ -7933,8 +7933,8 @@ save_history_cmds (const char *uuid) filename = g_build_filename (g_get_home_dir (), NMCLI_EDITOR_HISTORY, NULL); kf = g_key_file_new (); if (!g_key_file_load_from_file (kf, filename, G_KEY_FILE_KEEP_COMMENTS, &err)) { - if ( err->code != G_FILE_ERROR_NOENT - && err->code != G_KEY_FILE_ERROR_NOT_FOUND) { + if ( !g_error_matches (err, G_FILE_ERROR, G_FILE_ERROR_NOENT) + && !g_error_matches (err, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND)) { g_print ("Warning: %s parse error: %s\n", filename, err->message); g_key_file_free (kf); g_free (filename); @@ -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-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index 0ecb988af2..cc8ea66ed7 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -2907,8 +2907,7 @@ set_property (GObject *object, guint prop_id, g_bytes_unref (priv->ca_cert); priv->ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CA_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", error->message); g_error_free (error); } break; @@ -2929,8 +2928,7 @@ set_property (GObject *object, guint prop_id, g_bytes_unref (priv->client_cert); priv->client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CLIENT_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", error->message); g_error_free (error); } break; @@ -2959,8 +2957,7 @@ set_property (GObject *object, guint prop_id, g_bytes_unref (priv->phase2_ca_cert); priv->phase2_ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CA_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", error->message); g_error_free (error); } break; @@ -2981,8 +2978,7 @@ set_property (GObject *object, guint prop_id, g_bytes_unref (priv->phase2_client_cert); priv->phase2_client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", error->message); g_error_free (error); } break; @@ -3006,8 +3002,7 @@ set_property (GObject *object, guint prop_id, g_bytes_unref (priv->private_key); priv->private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PRIVATE_KEY, &error); if (error) { - g_warning ("Error setting private key (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting private key (invalid data): %s", error->message); g_error_free (error); } break; @@ -3023,8 +3018,7 @@ set_property (GObject *object, guint prop_id, g_bytes_unref (priv->phase2_private_key); priv->phase2_private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &error); if (error) { - g_warning ("Error setting private key (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting private key (invalid data): %s", error->message); g_error_free (error); } break; diff --git a/libnm-glib/nm-active-connection.c b/libnm-glib/nm-active-connection.c index db6e7ab732..aa79e1ac04 100644 --- a/libnm-glib/nm-active-connection.c +++ b/libnm-glib/nm-active-connection.c @@ -139,8 +139,8 @@ _nm_active_connection_type_for_path (DBusGConnection *connection, else type = NM_TYPE_ACTIVE_CONNECTION; } else { - g_warning ("Error in getting active connection 'Vpn' property: (%d) %s", - error->code, error->message); + g_warning ("Error in getting active connection 'Vpn' property: %s", + error->message); g_error_free (error); type = G_TYPE_INVALID; } diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index fc105e53e7..13d02943f4 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -513,7 +513,7 @@ activate_info_complete (ActivateInfo *info, error, info->user_data); } else if (error) - g_warning ("Device activation failed: (%d) %s", error->code, error->message); + g_warning ("Device activation failed: %s", error->message); priv->pending_activations = g_slist_remove (priv->pending_activations, info); } @@ -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); } } @@ -1839,8 +1839,8 @@ constructed (GObject *object) GError *error = NULL; if (!nm_utils_init (&error)) { - g_warning ("Couldn't initilize nm-utils/crypto system: %d %s", - error->code, error->message); + g_warning ("Couldn't initilize nm-utils/crypto system: %s", + error->message); g_clear_error (&error); } diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 312f970059..3392d230d3 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -2198,12 +2198,11 @@ device_operation_cb (DBusGProxy *proxy, if (info->fn) info->fn (info->device, error, info->user_data); else if (error) { - g_warning ("%s: device %s %s failed: (%d) %s", + g_warning ("%s: device %s %s failed: %s", __func__, nm_object_get_path (NM_OBJECT (info->device)), info->method, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + NM_G_ERROR_MSG (error)); } g_clear_error (&error); diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index b252dc7a6d..c7201cda26 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -1402,11 +1402,10 @@ _nm_object_reload_property (NMObject *object, G_TYPE_INVALID, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { - dbgmsg ("%s: Error getting '%s' for %s: (%d) %s\n", + dbgmsg ("%s: Error getting '%s' for %s: %s\n", __func__, prop_name, nm_object_get_path (object), - err->code, err->message); g_clear_error (&err); return; diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c index 2031b27f11..132032f488 100644 --- a/libnm-glib/nm-remote-connection.c +++ b/libnm-glib/nm-remote-connection.c @@ -454,11 +454,10 @@ replace_settings (NMRemoteConnection *self, GHashTable *new_settings) if (nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error)) g_signal_emit (self, signals[UPDATED], 0, new_settings); else { - g_warning ("%s: error updating connection %s settings: (%d) %s", + g_warning ("%s: error updating connection %s settings: %s", __func__, nm_connection_get_path (NM_CONNECTION (self)), - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + error->message); g_clear_error (&error); g_signal_emit (self, signals[REMOVED], 0); diff --git a/libnm-glib/nm-remote-settings.c b/libnm-glib/nm-remote-settings.c index fa2b325f05..b64743a99c 100644 --- a/libnm-glib/nm-remote-settings.c +++ b/libnm-glib/nm-remote-settings.c @@ -503,7 +503,7 @@ connection_inited (GObject *source, GAsyncResult *result, gpointer user_data) if (!dbus_g_error_has_name (error, "org.freedesktop.NetworkManager.Settings.PermissionDenied")) g_hash_table_remove (priv->pending, path); - if (print_once && error->code == DBUS_GERROR_LIMITS_EXCEEDED) { + if (print_once && g_error_matches (error, DBUS_GERROR, DBUS_GERROR_LIMITS_EXCEEDED)) { g_printerr ("Warning: libnm-glib:%s(): a D-Bus limit exceeded: %s. The application might not work properly.\n" "Consider increasing max_replies_per_connection limit in /etc/dbus-1/system.d/org.freedesktop.NetworkManager.conf " "like <limit name=\"max_replies_per_connection\">2048</limit>", @@ -574,9 +574,8 @@ fetch_connections_done (DBusGProxy *proxy, if ( !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN) && !g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NAME_HAS_NO_OWNER) && priv->service_running) { - g_warning ("%s: error fetching connections: (%d) %s.", + g_warning ("%s: error fetching connections: %s.", __func__, - error->code, error->message ? error->message : "(unknown)"); } g_clear_error (&error); diff --git a/libnm-glib/nm-secret-agent.c b/libnm-glib/nm-secret-agent.c index a0966f9f6c..0a86245568 100644 --- a/libnm-glib/nm-secret-agent.c +++ b/libnm-glib/nm-secret-agent.c @@ -330,9 +330,8 @@ verify_request (NMSecretAgent *self, g_set_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INVALID_CONNECTION, - "Invalid connection: (%d) %s", - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + "Invalid connection: %s", + local->message); g_clear_error (&local); } diff --git a/libnm-glib/nm-vpn-plugin.c b/libnm-glib/nm-vpn-plugin.c index 9f941fcb60..d117e53092 100644 --- a/libnm-glib/nm-vpn-plugin.c +++ b/libnm-glib/nm-vpn-plugin.c @@ -455,8 +455,7 @@ _connect_generic (NMVPNPlugin *plugin, connection = nm_connection_new_from_hash (properties, &local); if (!connection) { g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, - "Invalid connection: (%d) %s", - local->code, local->message); + "Invalid connection: %s", local->message); g_clear_error (&local); return FALSE; } @@ -537,9 +536,9 @@ impl_vpn_plugin_need_secrets (NMVPNPlugin *plugin, g_set_error (err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID, - "The connection was invalid: '%s' / '%s' invalid: %d.", + "The connection was invalid: '%s' / '%s' invalid.", g_type_name (nm_connection_lookup_setting_type_by_quark (cnfh_err->domain)), - cnfh_err->message, cnfh_err->code); + cnfh_err->message); g_error_free (cnfh_err); return FALSE; } @@ -595,8 +594,8 @@ impl_vpn_plugin_new_secrets (NMVPNPlugin *plugin, connection = nm_connection_new_from_hash (properties, &local); if (!connection) { g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, - "Invalid connection: (%d) %s", - local->code, local->message); + "Invalid connection: %s", + local->message); g_clear_error (&local); return FALSE; } diff --git a/libnm-util/nm-setting-8021x.c b/libnm-util/nm-setting-8021x.c index f476b2489b..4f974a413a 100644 --- a/libnm-util/nm-setting-8021x.c +++ b/libnm-util/nm-setting-8021x.c @@ -2878,8 +2878,8 @@ set_property (GObject *object, guint prop_id, } priv->ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CA_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", + error->message); g_error_free (error); } break; @@ -2902,8 +2902,8 @@ set_property (GObject *object, guint prop_id, } priv->client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CLIENT_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", + error->message); g_error_free (error); } break; @@ -2934,8 +2934,8 @@ set_property (GObject *object, guint prop_id, } priv->phase2_ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CA_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", + error->message); g_error_free (error); } break; @@ -2958,8 +2958,8 @@ set_property (GObject *object, guint prop_id, } priv->phase2_client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, &error); if (error) { - g_warning ("Error setting certificate (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting certificate (invalid data): %s", + error->message); g_error_free (error); } break; @@ -2985,8 +2985,8 @@ set_property (GObject *object, guint prop_id, } priv->private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PRIVATE_KEY, &error); if (error) { - g_warning ("Error setting private key (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting private key (invalid data): %s", + error->message); g_error_free (error); } break; @@ -3004,8 +3004,8 @@ set_property (GObject *object, guint prop_id, } priv->phase2_private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &error); if (error) { - g_warning ("Error setting private key (invalid data): (%d) %s", - error->code, error->message); + g_warning ("Error setting private key (invalid data): %s", + error->message); g_error_free (error); } break; @@ -3726,8 +3726,8 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class) /* Initialize crypto lbrary. */ if (!nm_utils_init (&error)) { - g_warning ("Couldn't initilize nm-utils/crypto system: %d %s", - error->code, error->message); + g_warning ("Couldn't initilize nm-utils/crypto system: %s", + error->message); g_error_free (error); } } diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index 7c9def1da2..24f233f913 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -1514,18 +1514,14 @@ nm_utils_uuid_generate_from_string (const char *s) g_return_val_if_fail (s && *s, NULL); if (!nm_utils_init (&error)) { - g_warning ("error initializing crypto: (%d) %s", - error ? error->code : 0, - error ? error->message : "unknown"); + g_warning ("error initializing crypto: %s", error->message); if (error) g_error_free (error); return NULL; } 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"); + g_warning ("error generating UUID: %s", error->message); if (error) g_error_free (error); return NULL; diff --git a/libnm/nm-object.c b/libnm/nm-object.c index b35f6822a5..9a5dcd6f0d 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -1280,11 +1280,10 @@ _nm_object_reload_property (NMObject *object, G_DBUS_CALL_FLAGS_NONE, 15000, NULL, &err); if (!ret) { - dbgmsg ("%s: Error getting '%s' for %s: (%d) %s\n", + dbgmsg ("%s: Error getting '%s' for %s: %s\n", __func__, prop_name, nm_object_get_path (object), - err->code, err->message); g_clear_error (&err); return; diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c index d2b55bd84f..c4a0b6aeb0 100644 --- a/libnm/nm-remote-connection.c +++ b/libnm/nm-remote-connection.c @@ -564,11 +564,10 @@ replace_settings (NMRemoteConnection *self, GVariant *new_settings) GError *error = NULL; if (!nm_connection_replace_settings (NM_CONNECTION (self), new_settings, &error)) { - g_warning ("%s: error updating connection %s settings: (%d) %s", + g_warning ("%s: error updating connection %s settings: %s", __func__, nm_connection_get_path (NM_CONNECTION (self)), - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); + error->message); g_clear_error (&error); } } diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index 19f14176fa..74861edc46 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -470,8 +470,8 @@ _connect_generic (NMVpnPluginOld *plugin, g_dbus_method_invocation_return_error (context, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, - "Invalid connection: (%d) %s", - error->code, error->message); + "Invalid connection: %s", + error->message); g_clear_error (&error); } @@ -611,8 +611,8 @@ impl_vpn_plugin_old_new_secrets (NMVpnPluginOld *plugin, g_dbus_method_invocation_return_error (context, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, - "Invalid connection: (%d) %s", - error->code, error->message); + "Invalid connection: %s", + error->message); g_clear_error (&error); return; } diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 5fbd359025..876d479817 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -486,8 +486,8 @@ _connect_generic (NMVpnServicePlugin *plugin, g_dbus_method_invocation_return_error (context, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, - "Invalid connection: (%d) %s", - error->code, error->message); + "Invalid connection: %s", + error->message); g_clear_error (&error); return; } @@ -631,8 +631,8 @@ impl_vpn_service_plugin_new_secrets (NMVpnServicePlugin *plugin, g_dbus_method_invocation_return_error (context, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS, - "Invalid connection: (%d) %s", - error->code, error->message); + "Invalid connection: %s", + error->message); g_clear_error (&error); return; } diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h index aa38bacf55..dafce87795 100644 --- a/shared/nm-macros-internal.h +++ b/shared/nm-macros-internal.h @@ -116,6 +116,26 @@ GS_DEFINE_CLEANUP_FUNCTION(void*, _nm_auto_free_impl, free) /********************************************************/ +/** + * NM_G_ERROR_MSG: + * @error: (allow none): the #GError instance + * + * All functions must follow the convention that when they + * return a failure, they must also set the GError to a valid + * message. For external API however, we want to be extra + * careful before accessing the error instance. Use NM_G_ERROR_MSG() + * which is safe to use on NULL. + * + * Returns: the error message. + **/ +static inline const char * +NM_G_ERROR_MSG (GError *error) +{ + return error ? (error->message ? : "(null)") : "(no-error)"; \ +} + +/********************************************************/ + /* macro to return strlen() of a compile time string. */ #define NM_STRLEN(str) ( sizeof ("" str) - 1 ) 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..a009746d02 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -246,9 +246,8 @@ pan_connection_check_create (NMBluezDevice *self) priv->pan_connection = added; 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)"); + nm_log_warn (LOGD_BT, "bluez[%s] couldn't add new Bluetooth connection for NAP device: '%s' (%s): %s", + priv->path, id, uuid, 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..4ecb56edbc 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -497,8 +497,8 @@ 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)"); + "retrieving IP4 configuration failed: %s", + 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/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c index 01990beed7..838368c479 100644 --- a/src/devices/wifi/tests/test-wifi-ap-utils.c +++ b/src/devices/wifi/tests/test-wifi-ap-utils.c @@ -37,7 +37,7 @@ if (expected) { \ if (!success) { \ g_assert (error != NULL); \ - g_warning ("Failed to complete connection: (%d) %s", error->code, error->message); \ + g_warning ("Failed to complete connection: %s", error->message); \ } \ g_assert (success == TRUE); \ g_assert (error == NULL); \ diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index e9c4f02e20..a8361c4976 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -157,8 +157,8 @@ modem_ip4_config_result (NMModem *modem, g_return_if_fail (nm_device_activate_ip4_state_in_conf (device) == TRUE); if (error) { - _LOGW (LOGD_MB | LOGD_IP4, "retrieving IPv4 configuration failed: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + _LOGW (LOGD_MB | LOGD_IP4, "retrieving IPv4 configuration failed: %s", + error->message); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } else { @@ -184,8 +184,7 @@ modem_ip6_config_result (NMModem *modem, g_return_if_fail (nm_device_activate_ip6_state_in_conf (device) == TRUE); if (error) { - _LOGW (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); + _LOGW (LOGD_MB | LOGD_IP6, "retrieving IPv6 configuration failed: %s", 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..2a8a9d1e92 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -545,10 +545,9 @@ ppp_stage3_ip_config_start (NMModem *self, ret = NM_ACT_STAGE_RETURN_POSTPONE; } else { - nm_log_err (LOGD_PPP, "(%s): error starting PPP: (%d) %s", + nm_log_err (LOGD_PPP, "(%s): error starting PPP: %s", nm_modem_get_uid (self), - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + 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..e5329ef33c 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient.c +++ b/src/dhcp-manager/nm-dhcp-dhclient.c @@ -362,9 +362,9 @@ dhclient_start (NMDhcpClient *client, priv->lease_file = g_strdup (g_file_get_path (dst)); } else { /* Failure; just use the existing leasefile */ - nm_log_warn (log_domain, "Failed to copy leasefile %s to %s: (%d) %s", + nm_log_warn (log_domain, "Failed to copy leasefile %s to %s: %s", g_file_get_path (src), g_file_get_path (dst), - error->code, error->message); + error->message); g_clear_error (&error); } g_object_unref (src); @@ -378,10 +378,9 @@ dhclient_start (NMDhcpClient *client, success = nm_dhcp_dhclient_save_duid (priv->lease_file, escaped, &error); g_free (escaped); 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: %s.", iface, priv->lease_file, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->message); g_free (pid_file); return FALSE; } @@ -577,8 +576,8 @@ get_duid (NMDhcpClient *client) duid = nm_dhcp_dhclient_read_duid (leasefile, &error); if (error) { - nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': (%d) %s", - leasefile, error->code, error->message); + nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': %s", + leasefile, error->message); g_clear_error (&error); } g_free (leasefile); @@ -589,10 +588,9 @@ get_duid (NMDhcpClient *client) nm_log_dbg (LOGD_DHCP, "Looking for default DHCPv6 DUID in '%s'.", priv->def_leasefile); duid = nm_dhcp_dhclient_read_duid (priv->def_leasefile, &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': %s", priv->def_leasefile, - error ? error->code : -1, - error ? error->message : "(unknown)"); + 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..919fa67608 100644 --- a/src/dns-manager/nm-dns-dnsmasq.c +++ b/src/dns-manager/nm-dns-dnsmasq.c @@ -283,10 +283,9 @@ update (NMDnsPlugin *plugin, /* Write out the config file */ 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: %s", CONFFILE, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + 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..6bdcbce168 100644 --- a/src/dns-manager/nm-dns-plugin.c +++ b/src/dns-manager/nm-dns-plugin.c @@ -175,9 +175,8 @@ nm_dns_plugin_child_spawn (NMDnsPlugin *self, nm_log_dbg (LOGD_DNS, "%s started with pid %d", priv->progname, priv->pid); 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)"); + nm_log_warn (LOGD_DNS, "Failed to spawn %s: %s", + priv->progname, error->message); g_clear_error (&error); } diff --git a/src/main.c b/src/main.c index 9495a9eff1..0f074b012d 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; } @@ -359,9 +358,8 @@ main (int argc, char *argv[]) nm_config_cmd_line_options_free (config_cli); 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")); + fprintf (stderr, _("Failed to read configuration: %s\n"), + error->message); exit (1); } @@ -413,10 +411,9 @@ main (int argc, char *argv[]) /* Parse the state file */ 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: %s", global_opt.state_file, - error ? error->code : -1, - (error && error->message) ? error->message : _("unknown")); + 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..acc3e4ca76 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -303,9 +303,8 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared) nm_log_info (LOGD_SHARING, "Executing: %s", cmd); 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)"); + nm_log_warn (LOGD_SHARING, "Error executing command: %s", + 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-auth-utils.c b/src/nm-auth-utils.c index e741546bbc..928e88b0c4 100644 --- a/src/nm-auth-utils.c +++ b/src/nm-auth-utils.c @@ -335,8 +335,8 @@ pk_call_cb (GObject *object, GAsyncResult *result, gpointer user_data) } if (error) { - nm_log_warn (LOGD_CORE, "error requesting auth for %s: (%d) %s", - call->permission, error->code, error->message); + nm_log_warn (LOGD_CORE, "error requesting auth for %s: %s", + call->permission, error->message); if (!call->chain->error) { call->chain->error = error; diff --git a/src/nm-manager.c b/src/nm-manager.c index a99d77fffb..e7eb7c63c8 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); @@ -1658,10 +1658,9 @@ assume_connection (NMManager *self, NMDevice *device, NMSettingsConnection *conn g_object_unref (subject); if (!active) { - _LOGW (LOGD_DEVICE, "assumed connection %s failed to activate: (%d) %s", + _LOGW (LOGD_DEVICE, "assumed connection %s failed to activate: %s", nm_connection_get_path (NM_CONNECTION (connection)), - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->message); g_error_free (error); return FALSE; } @@ -3671,7 +3670,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 +3687,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), @@ -4009,10 +4008,9 @@ _internal_enable (NMManager *self, gboolean enable) G_TYPE_BOOLEAN, (gpointer) &enable, &err)) { /* Not a hard error */ - _LOGW (LOGD_SUSPEND, "writing to state file %s failed: (%d) %s.", + _LOGW (LOGD_SUSPEND, "writing to state file %s failed: %s", priv->state_file, - err ? err->code : -1, - (err && err->message) ? err->message : "unknown"); + err->message); } } @@ -4971,10 +4969,9 @@ manager_radio_user_toggled (NMManager *self, "main", rstate->key, G_TYPE_BOOLEAN, (gpointer) &enabled, &error)) { - _LOGW (LOGD_CORE, "writing to state file %s failed: (%d) %s.", + _LOGW (LOGD_CORE, "writing to state file %s failed: %s", priv->state_file, - error ? error->code : -1, - (error && error->message) ? error->message : "unknown"); + 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..4c16f1f0f1 100644 --- a/src/ppp-manager/nm-pppd-plugin.c +++ b/src/ppp-manager/nm-pppd-plugin.c @@ -302,10 +302,9 @@ get_credentials (char *username, char *password) G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err); if (!ret) { - g_warning ("nm-ppp-plugin: (%s): could not get secrets: (%d) %s", + g_warning ("nm-ppp-plugin: (%s): could not get secrets: %s", __func__, - err ? err->code : -1, - err->message ? err->message : "(unknown)"); + 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..455871de12 100644 --- a/src/settings/nm-agent-manager.c +++ b/src/settings/nm-agent-manager.c @@ -263,8 +263,8 @@ agent_register_permissions_done (NMAuthChain *chain, if (error) { local = g_error_new (NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_PERMISSION_DENIED, - "Failed to request agent permissions: (%d) %s", - error->code, error->message); + "Failed to request agent permissions: %s", + error->message); g_dbus_method_invocation_take_error (context, local); } else { agent = nm_auth_chain_steal_data (chain, "agent"); @@ -987,9 +987,9 @@ _con_get_request_start_validated (NMAuthChain *chain, req->con.chain = NULL; if (error) { - _LOGD (req->current, "agent "LOG_REQ_FMT" MODIFY check error: (%d) %s", + _LOGD (req->current, "agent "LOG_REQ_FMT" MODIFY check error: %s", LOG_REQ_ARG (req), - error->code, error->message ? error->message : "(unknown)"); + 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..10aa77ab41 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -883,10 +883,8 @@ new_secrets_commit_cb (NMSettingsConnection *self, GError *error, gpointer user_data) { - if (error) { - _LOGW ("Error saving new secrets to backing storage: (%d) %s", - error->code, error->message ? error->message : "(unknown)"); - } + if (error) + _LOGW ("Error saving new secrets to backing storage: %s", error->message); } static void @@ -1086,19 +1084,17 @@ get_secrets_done_cb (NMAgentManager *manager, } } else { - _LOGD ("(%s:%p) failed to update with agent secrets: (%d) %s", + _LOGD ("(%s:%p) failed to update with agent secrets: %s", setting_name, info, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + local->message); } g_variant_unref (filtered_secrets); } else { - _LOGD ("(%s:%p) failed to update with existing secrets: (%d) %s", + _LOGD ("(%s:%p) failed to update with existing secrets: %s", setting_name, info, - local ? local->code : -1, - (local && local->message) ? local->message : "(unknown)"); + local->message); } applied_connection = info->applied_connection; @@ -2163,7 +2159,7 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *self, /* Save timestamp to timestamps database file */ timestamps_file = g_key_file_new (); if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) { - if (!(error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT)) + if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) _LOGW ("error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message); g_clear_error (&error); } @@ -2172,7 +2168,7 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *self, tmp = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp); g_key_file_set_value (timestamps_file, "timestamps", connection_uuid, tmp); g_free (tmp); - + data = g_key_file_to_data (timestamps_file, &len, &error); if (data) { g_file_set_contents (SETTINGS_TIMESTAMPS_FILE, data, len, &error); @@ -2219,8 +2215,7 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *self) priv->timestamp = timestamp; priv->timestamp_set = TRUE; } else { - _LOGD ("failed to read connection timestamp: (%d) %s", - err->code, err->message); + _LOGD ("failed to read connection timestamp: %s", err->message); g_clear_error (&err); } g_key_file_free (timestamps_file); diff --git a/src/settings/nm-settings-plugin.c b/src/settings/nm-settings-plugin.c index 2023bc17d5..7de7e597ff 100644 --- a/src/settings/nm-settings-plugin.c +++ b/src/settings/nm-settings-plugin.c @@ -175,5 +175,7 @@ nm_settings_plugin_add_connection (NMSettingsPlugin *config, if (NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->add_connection) return NM_SETTINGS_PLUGIN_GET_INTERFACE (config)->add_connection (config, connection, save_to_disk, error); + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_NOT_SUPPORTED, + "Plugin does not support adding connections"); return NULL; } 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..93b106b8ea 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -95,11 +95,10 @@ constructor (GType type, } if (!ifupdown_update_connection_from_if_block (NM_CONNECTION (object), priv->ifblock, &error)) { - 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: %s", __FILE__, __LINE__, - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->message); goto err; } diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index 29a1141b8e..6003c7457f 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -404,10 +404,9 @@ read_connections (NMSettingsPlugin *config) dir = g_dir_open (nm_keyfile_plugin_get_path (), 0, &error); if (!dir) { - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': (%d) %s", + nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': %s", nm_keyfile_plugin_get_path (), - error ? error->code : -1, - error && error->message ? error->message : "(unknown)"); + error->message); g_clear_error (&error); return; } diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 653b997231..54d20b1914 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -2224,8 +2224,8 @@ get_secrets_cb (NMSettingsConnection *connection, return; if (error && priv->secrets_idx >= SECRETS_REQ_NEW) { - _LOGE ("Failed to request VPN secrets #%d: (%d) %s", - priv->secrets_idx + 1, error->code, error->message); + _LOGE ("Failed to request VPN secrets #%d: %s", + priv->secrets_idx + 1, error->message); _set_vpn_state (self, STATE_FAILED, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS, FALSE); return; } |