mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-09 22:38:25 +02:00
cli: use an error quark for domain in g_set_error() instead of 0 (rh #842975)
glib 2.32 makes a runtime check that domain is not NULL: GLib-WARNING **: (gerror.c:390):g_error_new_valist: runtime check failed: (domain != 0)
This commit is contained in:
parent
1f4b97c878
commit
853803c2f0
4 changed files with 29 additions and 11 deletions
|
|
@ -1230,7 +1230,7 @@ find_device_for_connection (NmCli *nmc,
|
|||
active = nm_device_get_active_connection (*device);
|
||||
|
||||
if (!active) {
|
||||
g_set_error (error, 0, 0, _("no active connection on device '%s'"), iface);
|
||||
g_set_error (error, NMCLI_ERROR, 0, _("no active connection on device '%s'"), iface);
|
||||
return FALSE;
|
||||
}
|
||||
*spec_object = nm_object_get_path (NM_OBJECT (active));
|
||||
|
|
@ -1238,7 +1238,7 @@ find_device_for_connection (NmCli *nmc,
|
|||
} else {
|
||||
active = get_default_active_connection (nmc, device);
|
||||
if (!active) {
|
||||
g_set_error (error, 0, 0, _("no active connection or device"));
|
||||
g_set_error_literal (error, NMCLI_ERROR, 0, _("no active connection or device"));
|
||||
return FALSE;
|
||||
}
|
||||
*spec_object = nm_object_get_path (NM_OBJECT (active));
|
||||
|
|
@ -1309,9 +1309,11 @@ find_device_for_connection (NmCli *nmc,
|
|||
return TRUE;
|
||||
} else {
|
||||
if (iface)
|
||||
g_set_error (error, 0, 0, _("device '%s' not compatible with connection '%s'"), iface, nm_setting_connection_get_id (s_con));
|
||||
g_set_error (error, NMCLI_ERROR, 0, _("device '%s' not compatible with connection '%s'"),
|
||||
iface, nm_setting_connection_get_id (s_con));
|
||||
else
|
||||
g_set_error (error, 0, 0, _("no device found for connection '%s'"), nm_setting_connection_get_id (s_con));
|
||||
g_set_error (error, NMCLI_ERROR, 0, _("no device found for connection '%s'"),
|
||||
nm_setting_connection_get_id (s_con));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,18 @@ typedef struct {
|
|||
GMainLoop *loop = NULL;
|
||||
|
||||
|
||||
/* Get an error quark for use with GError */
|
||||
GQuark
|
||||
nmcli_error_quark (void)
|
||||
{
|
||||
static GQuark error_quark = 0;
|
||||
|
||||
if (G_UNLIKELY (error_quark == 0))
|
||||
error_quark = g_quark_from_static_string ("nmcli-error-quark");
|
||||
|
||||
return error_quark;
|
||||
}
|
||||
|
||||
static void
|
||||
usage (const char *prog_name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,4 +119,8 @@ typedef struct _NmCli {
|
|||
gboolean nocheck_ver; /* Don't check nmcli and NM versions: option '--nocheck' */
|
||||
} NmCli;
|
||||
|
||||
/* Error quark for GError domain */
|
||||
#define NMCLI_ERROR (nmcli_error_quark ())
|
||||
GQuark nmcli_error_quark (void);
|
||||
|
||||
#endif /* NMC_NMCLI_H */
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ nmc_ip4_address_as_string (guint32 ip, GError **error)
|
|||
if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) {
|
||||
return g_strdup (buf);
|
||||
} else {
|
||||
g_set_error (error, 0, 0, _("Error converting IP4 address '0x%X' to text form"),
|
||||
g_set_error (error, NMCLI_ERROR, 0, _("Error converting IP4 address '0x%X' to text form"),
|
||||
ntohl (tmp_addr.s_addr));
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ nmc_ip6_address_as_string (const struct in6_addr *ip, GError **error)
|
|||
g_string_append_printf (ip6_str, "%02X", ip->s6_addr[0]);
|
||||
for (j = 1; j < 16; j++)
|
||||
g_string_append_printf (ip6_str, " %02X", ip->s6_addr[j]);
|
||||
g_set_error (error, 0, 0, _("Error converting IP6 address '%s' to text form"),
|
||||
g_set_error (error, NMCLI_ERROR, 0, _("Error converting IP6 address '%s' to text form"),
|
||||
ip6_str->str);
|
||||
g_string_free (ip6_str, TRUE);
|
||||
}
|
||||
|
|
@ -229,10 +229,10 @@ parse_output_fields (const char *fields_str, const NmcOutputField fields_array[]
|
|||
}
|
||||
if (fields_array[i].name == NULL) {
|
||||
if (!strcasecmp (*iter, "all") || !strcasecmp (*iter, "common"))
|
||||
g_set_error (error, 0, 0, _("field '%s' has to be alone"), *iter);
|
||||
g_set_error (error, NMCLI_ERROR, 0, _("field '%s' has to be alone"), *iter);
|
||||
|
||||
else
|
||||
g_set_error (error, 0, 1, _("invalid field '%s'"), *iter);
|
||||
g_set_error (error, NMCLI_ERROR, 1, _("invalid field '%s'"), *iter);
|
||||
g_array_free (array, TRUE);
|
||||
array = NULL;
|
||||
goto done;
|
||||
|
|
@ -251,11 +251,11 @@ nmc_terse_option_check (NMCPrintOutput print_output, const char *fields, GError
|
|||
|
||||
if (print_output == NMC_PRINT_TERSE) {
|
||||
if (!fields) {
|
||||
g_set_error (error, 0, 0, _("Option '--terse' requires specifying '--fields'"));
|
||||
g_set_error_literal (error, NMCLI_ERROR, 0, _("Option '--terse' requires specifying '--fields'"));
|
||||
return FALSE;
|
||||
} else if ( !strcasecmp (fields, "all")
|
||||
|| !strcasecmp (fields, "common")) {
|
||||
g_set_error (error, 0, 0, _("Option '--terse' requires specific '--fields' option values , not '%s'"), fields);
|
||||
g_set_error (error, NMCLI_ERROR, 0, _("Option '--terse' requires specific '--fields' option values , not '%s'"), fields);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -468,7 +468,7 @@ nmc_is_nm_running (NmCli *nmc, GError **error)
|
|||
g_string_printf (nmc->return_text, _("Error: Couldn't create D-Bus object proxy for org.freedesktop.DBus"));
|
||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||
if (error)
|
||||
g_set_error (error, 0, 0, "%s", nmc->return_text->str);
|
||||
g_set_error_literal (error, NMCLI_ERROR, 0, nmc->return_text->str);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue