summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-10-14 17:36:01 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-10-14 18:36:10 +0200
commit80788a0bd49d9992820b37096d59a69f82e80166 (patch)
treeab5899df987d8487cb73030f8917932ce03312db /src
parentMerge pull request #29544 from yuwata/network-dhcp-bus-command (diff)
downloadsystemd-80788a0bd49d9992820b37096d59a69f82e80166.tar.xz
systemd-80788a0bd49d9992820b37096d59a69f82e80166.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/shared/pretty-print.c7
-rw-r--r--src/shared/pretty-print.h2
-rw-r--r--src/test/test-pretty-print.c2
3 files changed, 3 insertions, 8 deletions
diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c
index a354ae4983..55a2570ddf 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 45644da67d..0012dc8835 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 7c6c6c7ad1..ece1a161e4 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);