summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-10-24 12:27:15 +0200
committerThomas Haller <thaller@redhat.com>2019-11-06 17:33:15 +0100
commit30d3ea4cb2fdc7044ae93ab1ae3a4687c75c0cf3 (patch)
tree348a4571e4b0dec7cb48456086eff24533bcbc69
parent41df6d0c757ceb25838c600ba6e76bf69bd51b03 (diff)
downloadNetworkManager-30d3ea4cb2fdc7044ae93ab1ae3a4687c75c0cf3.tar.gz
shared: add nm_dbus_path_not_empty() helper
-rw-r--r--shared/nm-glib-aux/nm-macros-internal.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h
index ea54f4488d..81b56b583e 100644
--- a/shared/nm-glib-aux/nm-macros-internal.h
+++ b/shared/nm-glib-aux/nm-macros-internal.h
@@ -1268,6 +1268,17 @@ nm_clear_g_cancellable_disconnect (GCancellable *cancellable, gulong *cancellabl
/*****************************************************************************/
+static inline const char *
+nm_dbus_path_not_empty (const char *str)
+{
+ nm_assert (!str || str[0] == '/');
+ return !str || (str[0] == '/' && str[1] == '\0')
+ ? NULL
+ : str;
+}
+
+/*****************************************************************************/
+
/* GVariantType is basically a C string. But G_VARIANT_TYPE() is not suitable
* to initialize a static variable (because it evaluates a function check that
* the string is valid). Add an alternative macro that does the plain cast.