mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-16 17:01:22 +01:00
all: use g_error_matches()
Use g_error_matches() where we're testing error codes. In particular, use it rather than looking at only ->code and not also ->domain, which is just wrong. [thaller@redhat.com: rebase and modify original patch]
This commit is contained in:
parent
01b9b4104c
commit
6265398b6e
3 changed files with 6 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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>",
|
||||
|
|
|
|||
|
|
@ -2163,7 +2163,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 +2172,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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue