chiark / gitweb /
path-util: introduce empty_to_root() and use it many places
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 May 2018 16:47:33 +0000 (01:47 +0900)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
src/basic/path-util.h
src/libelogind/sd-bus/bus-socket.c

index 9f22322abc3d8accc13c89b1df98147c689fee0f..e1f22ed97fe2fe8818ea04ed1edf1f705054581c 100644 (file)
@@ -178,3 +178,6 @@ static inline const char *skip_dev_prefix(const char *p) {
 }
 
 bool empty_or_root(const char *root);
+static inline const char *empty_to_root(const char *path) {
+        return isempty(path) ? "/" : path;
+}
index 54feddf9e542ee8d66af850ad754288299b582ab..04839bada415d544db18f6b290dc8453f0424007 100644 (file)
@@ -777,7 +777,7 @@ static int bus_socket_inotify_setup(sd_bus *b) {
                         if (IN_SET(errno, ENOENT, ELOOP))
                                 break; /* This component doesn't exist yet, or the path contains a cyclic symlink right now */
 
-                        r = log_debug_errno(errno, "Failed to add inotify watch on %s: %m", isempty(prefix) ? "/" : prefix);
+                        r = log_debug_errno(errno, "Failed to add inotify watch on %s: %m", empty_to_root(prefix));
                         goto fail;
                 } else
                         new_watches[n++] = wd;