shared: drop nm_utils_dbus_normalize_object_path() in favor of nm_dbus_path_not_empty()

They do the same thing. Unify and drop one.
This commit is contained in:
Thomas Haller 2020-01-29 15:55:38 +01:00
parent c7e6573eb4
commit 8c23586a77
4 changed files with 7 additions and 19 deletions

View file

@ -1346,18 +1346,6 @@ int nm_utils_fd_read_loop_exact (int fd, void *buf, size_t nbytes, bool do_poll)
/*****************************************************************************/
static inline const char *
nm_utils_dbus_normalize_object_path (const char *path)
{
/* D-Bus does not allow an empty object path. Hence, whenever we mean NULL / no-object
* on D-Bus, it's path is actually "/".
*
* Normalize that away, and return %NULL in that case. */
if (path && path[0] == '/' && path[1] == '\0')
return NULL;
return path;
}
#define NM_DEFINE_GDBUS_ARG_INFO_FULL(name_, ...) \
((GDBusArgInfo *) (&((const GDBusArgInfo) { \
.ref_count = -1, \

View file

@ -1398,7 +1398,7 @@ set_property (GObject *object, guint prop_id,
case PROP_SPECIFIC_OBJECT:
/* construct-only */
tmp = g_value_get_string (value);
tmp = nm_utils_dbus_normalize_object_path (tmp);
tmp = nm_dbus_path_not_empty (tmp);
priv->specific_object = g_strdup (tmp);
break;
case PROP_DEFAULT:

View file

@ -5333,9 +5333,9 @@ impl_manager_activate_connection (NMDBusObject *obj,
g_variant_get (parameters, "(&o&o&o)", &connection_path, &device_path, &specific_object_path);
connection_path = nm_utils_dbus_normalize_object_path (connection_path);
specific_object_path = nm_utils_dbus_normalize_object_path (specific_object_path);
device_path = nm_utils_dbus_normalize_object_path (device_path);
connection_path = nm_dbus_path_not_empty (connection_path);
specific_object_path = nm_dbus_path_not_empty (specific_object_path);
device_path = nm_dbus_path_not_empty (device_path);
/* If the connection path is given and valid, that connection is activated.
* Otherwise the "best" connection for the device is chosen and activated,
@ -5623,8 +5623,8 @@ impl_manager_add_and_activate_connection (NMDBusObject *obj,
}
}
specific_object_path = nm_utils_dbus_normalize_object_path (specific_object_path);
device_path = nm_utils_dbus_normalize_object_path (device_path);
specific_object_path = nm_dbus_path_not_empty (specific_object_path);
device_path = nm_dbus_path_not_empty (device_path);
/* Try to create a new connection with the given settings.
* We allow empty settings for AddAndActivateConnection(). In that case,

View file

@ -1401,7 +1401,7 @@ props_changed_cb (GDBusProxy *proxy,
}
if (g_variant_lookup (changed_properties, "CurrentBSS", "&o", &s)) {
s = nm_utils_dbus_normalize_object_path (s);
s = nm_dbus_path_not_empty (s);
if (!nm_streq0 (s, priv->current_bss)) {
g_free (priv->current_bss);
priv->current_bss = g_strdup (s);