]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/pretty-print: drop unused flag
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 14 Oct 2023 15:36:01 +0000 (17:36 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 14 Oct 2023 16:36:10 +0000 (18:36 +0200)
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.

src/shared/pretty-print.c
src/shared/pretty-print.h
src/test/test-pretty-print.c

index a354ae4983037544e6c2890d41b59766f809fe37..55a2570ddf51cc9417208f24147b54dff23dfd01 100644 (file)
@@ -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);
         }
 
index 45644da67dd3b5b2e1849b037381e3a83682d31b..0012dc88353e6cf9176c187d46113121ddb66ba9 100644 (file)
@@ -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);
index 7c6c6c7ad1928efdae9ba0b380bd0254a923df98..ece1a161e451fdf7af87608f8a40c84b314793f2 100644 (file)
@@ -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);