]> err.no Git - systemd/commitdiff
main: don't segfault when --log-color is passed without parameter
authorLennart Poettering <lennart@poettering.net>
Fri, 18 Jun 2010 21:13:15 +0000 (23:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 18 Jun 2010 21:13:15 +0000 (23:13 +0200)
src/main.c

index 8a7f18ea9c38c2688b9f5ebe3f765fe9643d82df..21b4174a87d6b602bb2cf8ca81010c3f8adeb501 100644 (file)
@@ -412,19 +412,25 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case ARG_LOG_COLOR:
 
-                        if ((r = log_show_color_from_string(optarg)) < 0) {
-                                log_error("Failed to parse log color setting %s.", optarg);
-                                return r;
-                        }
+                        if (optarg) {
+                                if ((r = log_show_color_from_string(optarg)) < 0) {
+                                        log_error("Failed to parse log color setting %s.", optarg);
+                                        return r;
+                                }
+                        } else
+                                log_show_color(true);
 
                         break;
 
                 case ARG_LOG_LOCATION:
 
-                        if ((r = log_show_location_from_string(optarg)) < 0) {
-                                log_error("Failed to parse log location setting %s.", optarg);
-                                return r;
-                        }
+                        if (optarg) {
+                                if ((r = log_show_location_from_string(optarg)) < 0) {
+                                        log_error("Failed to parse log location setting %s.", optarg);
+                                        return r;
+                                }
+                        } else
+                                log_show_location(true);
 
                         break;