chiark / gitweb /
systemd-sleep: it is not an error if the config file is missing
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 May 2013 15:35:23 +0000 (11:35 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 May 2013 15:47:50 +0000 (11:47 -0400)
src/shared/sleep-config.c

index 73a3acb8be4454496fcfe80784069218bd4b6452..cd3238b405f013ea89050dec7f098e36fceb9953 100644 (file)
@@ -47,19 +47,16 @@ int parse_sleep_config(const char *verb, char ***modes, char ***states) {
         FILE _cleanup_fclose_ *f;
 
         f = fopen(PKGSYSCONFDIR "/sleep.conf", "re");
-        if (!f) {
-                if (errno == ENOENT)
-                        return 0;
-
-                log_warning("Failed to open configuration file " PKGSYSCONFDIR "/sleep.conf: %m");
-                return 0;
+        if (!f)
+                log_full(errno == ENOENT ? LOG_DEBUG: LOG_WARNING,
+                         "Failed to open configuration file " PKGSYSCONFDIR "/sleep.conf: %m");
+        else {
+                r = config_parse(NULL, PKGSYSCONFDIR "/sleep.conf", f, "Sleep\0",
+                                 config_item_table_lookup, (void*) items, false, false, NULL);
+                if (r < 0)
+                        log_warning("Failed to parse configuration file: %s", strerror(-r));
         }
 
-        r = config_parse(NULL, PKGSYSCONFDIR "/sleep.conf", f, "Sleep\0",
-                         config_item_table_lookup, (void*) items, false, false, NULL);
-        if (r < 0)
-                log_warning("Failed to parse configuration file: %s", strerror(-r));
-
         if (streq(verb, "suspend")) {
                 /* empty by default */
                 *modes = suspend_mode;