From 47fc0bb4dc80cbd9e14680ea917845b76fc9cbc7 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 11 May 2018 01:47:33 +0900 Subject: [PATCH] path-util: introduce empty_to_root() and use it many places --- src/basic/path-util.h | 3 +++ src/libelogind/sd-bus/bus-socket.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 9f22322ab..e1f22ed97 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -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; +} diff --git a/src/libelogind/sd-bus/bus-socket.c b/src/libelogind/sd-bus/bus-socket.c index 54feddf9e..04839bada 100644 --- a/src/libelogind/sd-bus/bus-socket.c +++ b/src/libelogind/sd-bus/bus-socket.c @@ -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; -- 2.30.2