summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-11-09 15:54:35 +0100
committerThomas Haller <thaller@redhat.com>2022-11-14 08:04:16 +0100
commitcf6d38177fd9e25e3cf0b8b0047bd95e80164ec4 (patch)
tree0860b72a4a5dcab5f1370342bdb33ace42df8847
parenta7fea45adf25a8a4562557acea4d04b894366f2c (diff)
downloadNetworkManager-cf6d38177fd9e25e3cf0b8b0047bd95e80164ec4.tar.gz
glib-aux: drop duplicate _nm_dbus_error_has_name() for nm_dbus_error_is()
-rw-r--r--src/core/nm-dispatcher.c2
-rw-r--r--src/core/supplicant/nm-supplicant-interface.c2
-rw-r--r--src/core/supplicant/nm-supplicant-manager.c4
-rw-r--r--src/libnm-glib-aux/nm-dbus-aux.c42
-rw-r--r--src/libnm-glib-aux/nm-dbus-aux.h2
5 files changed, 13 insertions, 39 deletions
diff --git a/src/core/nm-dispatcher.c b/src/core/nm-dispatcher.c
index d6dd9bfa9d..ab361faa7b 100644
--- a/src/core/nm-dispatcher.c
+++ b/src/core/nm-dispatcher.c
@@ -429,7 +429,7 @@ dispatcher_done_cb(GObject *source, GAsyncResult *result, gpointer user_data)
if (!ret) {
NMLogLevel log_level = LOGL_DEBUG;
- if (_nm_dbus_error_has_name(error, "org.freedesktop.systemd1.LoadFailed")) {
+ if (nm_dbus_error_is(error, "org.freedesktop.systemd1.LoadFailed")) {
g_dbus_error_strip_remote_error(error);
log_level = LOGL_WARN;
}
diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c
index 5b5d86229c..18525724f4 100644
--- a/src/core/supplicant/nm-supplicant-interface.c
+++ b/src/core/supplicant/nm-supplicant-interface.c
@@ -2647,7 +2647,7 @@ scan_request_cb(GObject *source, GAsyncResult *result, gpointer user_data)
_LOGD("request-scan: request cancelled");
else {
if (error) {
- if (_nm_dbus_error_has_name(error, "fi.w1.wpa_supplicant1.Interface.ScanError"))
+ if (nm_dbus_error_is(error, "fi.w1.wpa_supplicant1.Interface.ScanError"))
_LOGD("request-scan: could not get scan request result: %s", error->message);
else {
g_dbus_error_strip_remote_error(error);
diff --git a/src/core/supplicant/nm-supplicant-manager.c b/src/core/supplicant/nm-supplicant-manager.c
index 2ec7db237a..f6927500dd 100644
--- a/src/core/supplicant/nm-supplicant-manager.c
+++ b/src/core/supplicant/nm-supplicant-manager.c
@@ -450,7 +450,7 @@ _create_iface_dbus_call_get_interface_cb(GObject *source, GAsyncResult *result,
char ifname[NMP_IFNAMSIZ];
if (handle->create_iface_try_count < CREATE_IFACE_TRY_COUNT_MAX
- && _nm_dbus_error_has_name(error, NM_WPAS_ERROR_UNKNOWN_IFACE)
+ && nm_dbus_error_is(error, NM_WPAS_ERROR_UNKNOWN_IFACE)
&& nm_platform_if_indextoname(NM_PLATFORM_GET, handle->ifindex, ifname)) {
/* Before, supplicant told us the interface existed. Was there a race?
* Try again. */
@@ -500,7 +500,7 @@ _create_iface_dbus_call_create_interface_cb(GObject *source,
nm_assert(handle->self);
TRUE;
})
- && _nm_dbus_error_has_name(error, NM_WPAS_ERROR_EXISTS_ERROR)
+ && nm_dbus_error_is(error, NM_WPAS_ERROR_EXISTS_ERROR)
&& nm_platform_if_indextoname(NM_PLATFORM_GET, handle->ifindex, ifname)) {
self = handle->self;
_LOGT("create-iface[" NM_HASH_OBFUSCATE_PTR_FMT
diff --git a/src/libnm-glib-aux/nm-dbus-aux.c b/src/libnm-glib-aux/nm-dbus-aux.c
index 32e87fe0ee..ffa0f84035 100644
--- a/src/libnm-glib-aux/nm-dbus-aux.c
+++ b/src/libnm-glib-aux/nm-dbus-aux.c
@@ -414,6 +414,12 @@ _nm_dbus_error_is(GError *error, ...)
gs_free char *dbus_error = NULL;
const char *name;
va_list ap;
+ gboolean found = FALSE;
+
+ /* This should only be used for "foreign" D-Bus errors (eg, errors
+ * from BlueZ or wpa_supplicant). All NetworkManager D-Bus errors
+ * should be properly mapped by gdbus to one of the domains/codes in
+ * nm-errors.h. */
dbus_error = g_dbus_error_get_remote_error(error);
if (!dbus_error)
@@ -422,13 +428,13 @@ _nm_dbus_error_is(GError *error, ...)
va_start(ap, error);
while ((name = va_arg(ap, const char *))) {
if (nm_streq(dbus_error, name)) {
- va_end(ap);
- return TRUE;
+ found = TRUE;
+ break;
}
}
va_end(ap);
- return FALSE;
+ return found;
}
/*****************************************************************************/
@@ -731,33 +737,3 @@ _nm_dbus_connection_call_finish(GDBusConnection *dbus_connection,
nm_clear_pointer(&variant, g_variant_unref);
return variant;
}
-
-/**
- * _nm_dbus_error_has_name:
- * @error: (allow-none): a #GError, or %NULL
- * @dbus_error_name: a D-Bus error name
- *
- * Checks if @error is set and corresponds to the D-Bus error @dbus_error_name.
- *
- * This should only be used for "foreign" D-Bus errors (eg, errors
- * from BlueZ or wpa_supplicant). All NetworkManager D-Bus errors
- * should be properly mapped by gdbus to one of the domains/codes in
- * nm-errors.h.
- *
- * Returns: %TRUE or %FALSE
- */
-gboolean
-_nm_dbus_error_has_name(GError *error, const char *dbus_error_name)
-{
- gboolean has_name = FALSE;
-
- if (error && g_dbus_error_is_remote_error(error)) {
- char *error_name;
-
- error_name = g_dbus_error_get_remote_error(error);
- has_name = !g_strcmp0(error_name, dbus_error_name);
- g_free(error_name);
- }
-
- return has_name;
-}
diff --git a/src/libnm-glib-aux/nm-dbus-aux.h b/src/libnm-glib-aux/nm-dbus-aux.h
index dbc0e6e257..f7fc4294ae 100644
--- a/src/libnm-glib-aux/nm-dbus-aux.h
+++ b/src/libnm-glib-aux/nm-dbus-aux.h
@@ -312,6 +312,4 @@ GVariant *_nm_dbus_connection_call_finish(GDBusConnection *dbus_connection,
const GVariantType *reply_type,
GError **error);
-gboolean _nm_dbus_error_has_name(GError *error, const char *dbus_error_name);
-
#endif /* __NM_DBUS_AUX_H__ */