summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-15 17:03:55 +0100
committerLennart Poettering <lennart@poettering.net>2017-12-15 20:52:28 +0100
commit72c7329b6eda90bbbf83354c10c51f60c3523870 (patch)
treeb04cf945fe50c949010b1df1563bbbb6d1f29974
parentfd8c85c6524ca64832dae0a187796a1ee56c253f (diff)
downloadsystemd-72c7329b6eda90bbbf83354c10c51f60c3523870.tar.gz
systemd-72c7329b6eda90bbbf83354c10c51f60c3523870.tar.bz2
systemd-72c7329b6eda90bbbf83354c10c51f60c3523870.zip
main: slight modernizations for status_welcome()
There's no point in duplicating the complex parse_env_file() invocation, hence let's not do it.
-rw-r--r--src/core/main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/core/main.c b/src/core/main.c
index af76f750fe..7e3658f711 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1336,23 +1336,23 @@ static int enforce_syscall_archs(Set *archs) {
static int status_welcome(void) {
_cleanup_free_ char *pretty_name = NULL, *ansi_color = NULL;
+ const char *fn;
int r;
if (arg_show_status <= 0)
return 0;
- r = parse_env_file("/etc/os-release", NEWLINE,
- "PRETTY_NAME", &pretty_name,
- "ANSI_COLOR", &ansi_color,
- NULL);
- if (r == -ENOENT)
- r = parse_env_file("/usr/lib/os-release", NEWLINE,
+ FOREACH_STRING(fn, "/etc/os-release", "/usr/lib/os-release") {
+ r = parse_env_file(fn, NEWLINE,
"PRETTY_NAME", &pretty_name,
"ANSI_COLOR", &ansi_color,
NULL);
+ if (r != -ENOENT)
+ break;
+ }
if (r < 0 && r != -ENOENT)
- log_warning_errno(r, "Failed to read os-release file: %m");
+ log_warning_errno(r, "Failed to read os-release file, ignoring: %m");
if (log_get_show_color())
return status_printf(NULL, false, false,