]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
main: slight modernizations for status_welcome()
authorLennart Poettering <lennart@poettering.net>
Fri, 15 Dec 2017 16:03:55 +0000 (17:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 15 Dec 2017 19:52:28 +0000 (20:52 +0100)
There's no point in duplicating the complex parse_env_file() invocation,
hence let's not do it.

src/core/main.c

index af76f750fec3cd658d0e12b538394ed5c27b7233..7e3658f7119bd7f9f336d09b3bfb8e647e4e0a9f 100644 (file)
@@ -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,