glib-aux: drop duplicate _nm_dbus_error_has_name() for nm_dbus_error_is()
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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__ */
|
||||
|
Reference in New Issue
Block a user