From: Lennart Poettering Date: Fri, 15 Dec 2017 16:03:55 +0000 (+0100) Subject: main: slight modernizations for status_welcome() X-Git-Tag: v237~209^2~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=72c7329b6eda90bbbf83354c10c51f60c3523870;p=thirdparty%2Fsystemd.git main: slight modernizations for status_welcome() There's no point in duplicating the complex parse_env_file() invocation, hence let's not do it. --- diff --git a/src/core/main.c b/src/core/main.c index af76f750fec..7e3658f7119 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,