From: Zbigniew Jędrzejewski-Szmek Date: Sat, 14 Oct 2023 15:36:01 +0000 (+0200) Subject: shared/pretty-print: drop unused flag X-Git-Tag: v255-rc1~147^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80788a0bd49d9992820b37096d59a69f82e80166;p=thirdparty%2Fsystemd.git shared/pretty-print: drop unused flag 0895e87348e5fc02f50498cad5922eb3eb172323 removed the last (only?) use of CAT_MAIN_FILE_OPTIONAL, except for tests. All callers first check if the main file exists on their own, so this code was effectively dead. I want to repopulate the enum in later commits, so a dummy flag is added to allow the code to compile. --- diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c index a354ae49830..55a2570ddf5 100644 --- a/src/shared/pretty-print.c +++ b/src/shared/pretty-print.c @@ -171,12 +171,7 @@ int cat_files(const char *file, char **dropins, CatFlags flags) { if (file) { r = cat_file(file, false); - if (r == -ENOENT && (flags & CAT_FLAGS_MAIN_FILE_OPTIONAL)) - printf("%s# Configuration file %s not found%s\n", - ansi_highlight_magenta(), - file, - ansi_normal()); - else if (r < 0) + if (r < 0) return log_warning_errno(r, "Failed to cat %s: %m", file); } diff --git a/src/shared/pretty-print.h b/src/shared/pretty-print.h index 45644da67dd..0012dc88353 100644 --- a/src/shared/pretty-print.h +++ b/src/shared/pretty-print.h @@ -15,7 +15,7 @@ int terminal_urlify_path(const char *path, const char *text, char **ret); int terminal_urlify_man(const char *page, const char *section, char **ret); typedef enum CatFlags { - CAT_FLAGS_MAIN_FILE_OPTIONAL = 1 << 0, + CAT_DUMMY_FLAG, // This flag only exists a as a placeholder because empty enums are not allowed } CatFlags; int cat_files(const char *file, char **dropins, CatFlags flags); diff --git a/src/test/test-pretty-print.c b/src/test/test-pretty-print.c index 7c6c6c7ad19..ece1a161e45 100644 --- a/src/test/test-pretty-print.c +++ b/src/test/test-pretty-print.c @@ -25,7 +25,7 @@ TEST(terminal_urlify) { TEST(cat_files) { assert_se(cat_files("/no/such/file", NULL, 0) == -ENOENT); - assert_se(cat_files("/no/such/file", NULL, CAT_FLAGS_MAIN_FILE_OPTIONAL) == 0); + assert_se(cat_files(NULL, NULL, 0) == 0); if (access("/etc/fstab", R_OK) >= 0) assert_se(cat_files("/etc/fstab", STRV_MAKE("/etc/fstab", "/etc/fstab"), 0) == 0);