From cc5ea34ae1e3353cab3cd141a57e306eb2c6d10d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 13 Jan 2026 16:48:42 +0900 Subject: [PATCH] conf-files: use empty_to_root() No functional change. For consistency with conf_file_chase_and_verify(). (cherry picked from commit 0c109deda17aeca2468b2a268a46e22ac78e55e7) --- src/basic/conf-files.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index ccf1601eb80..a0aeb818037 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -368,9 +368,9 @@ static int files_add( assert(files); assert(masked); - root = strempty(root); + root = empty_to_root(root); - FOREACH_DIRENT(de, dir, return log_debug_errno(errno, "Failed to read directory '%s/%s': %m", + FOREACH_DIRENT(de, dir, return log_debug_errno(errno, "Failed to read directory '%s%s': %m", root, skip_leading_slash(original_dirpath))) { _cleanup_free_ char *original_path = path_join(original_dirpath, de->d_name); @@ -379,19 +379,19 @@ static int files_add( /* Does this match the suffix? */ if (suffix && !endswith(de->d_name, suffix)) { - log_debug("Skipping file '%s/%s', suffix is not '%s'.", root, skip_leading_slash(original_path), suffix); + log_debug("Skipping file '%s%s', suffix is not '%s'.", root, skip_leading_slash(original_path), suffix); continue; } /* Has this file already been found in an earlier directory? */ if (hashmap_contains(*files, de->d_name)) { - log_debug("Skipping overridden file '%s/%s'.", root, skip_leading_slash(original_path)); + log_debug("Skipping overridden file '%s%s'.", root, skip_leading_slash(original_path)); continue; } /* Has this been masked in an earlier directory? */ if ((flags & CONF_FILES_FILTER_MASKED) != 0 && set_contains(*masked, de->d_name)) { - log_debug("File '%s/%s' is masked by previous entry.", root, skip_leading_slash(original_path)); + log_debug("File '%s%s' is masked by previous entry.", root, skip_leading_slash(original_path)); continue; } @@ -595,6 +595,8 @@ static int conf_files_list_impl( assert(rfd >= 0 || rfd == AT_FDCWD); assert(ret); + root = empty_to_root(root); + if (replacement) { r = conf_file_new_at(replacement, rfd, CHASE_NONEXISTENT, &c); if (r < 0) @@ -608,7 +610,8 @@ static int conf_files_list_impl( r = chase_and_opendirat(rfd, *p, CHASE_AT_RESOLVE_IN_ROOT, &path, &dir); if (r < 0) { if (r != -ENOENT) - log_debug_errno(r, "Failed to chase and open directory '%s/%s', ignoring: %m", strempty(root), skip_leading_slash(*p)); + log_debug_errno(r, "Failed to chase and open directory '%s%s', ignoring: %m", + root, skip_leading_slash(*p)); continue; } -- 2.47.3