summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-11 17:03:55 +0200
committerThomas Haller <thaller@redhat.com>2018-04-18 07:55:15 +0200
commit56a3f3bba93f49611cc5ac1e34acb607143bb3a2 (patch)
tree11c549aa935032865bdbfe76c19a54619a33290c
parentbe9a5ab308f13977f07a33135b3792ccbd1d6e67 (diff)
downloadNetworkManager-56a3f3bba93f49611cc5ac1e34acb607143bb3a2.tar.gz
shared: add nm_utils_dbus_normalize_object_path() helper
-rw-r--r--shared/nm-utils/nm-shared-utils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h
index 9f86a15170..f966d293d1 100644
--- a/shared/nm-utils/nm-shared-utils.h
+++ b/shared/nm-utils/nm-shared-utils.h
@@ -501,6 +501,18 @@ 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, \