From: Yu Watanabe Date: Thu, 10 May 2018 16:47:33 +0000 (+0900) Subject: path-util: introduce empty_to_root() and use it many places X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=47fc0bb4dc80cbd9e14680ea917845b76fc9cbc7;p=elogind.git path-util: introduce empty_to_root() and use it many places --- 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;