chiark / gitweb /
test: utf8 - fix utf16 tests on BE machines
[elogind.git] / src / sleep / sleep.c
index a7506ed7711a99f13ddcf8a5b033ba09eaf3980f..cc1ffa63f1efeb28f7e00b2e69bbed848e2e5198 100644 (file)
@@ -77,10 +77,8 @@ static int write_state(FILE **f, char **states) {
 
                 fclose(*f);
                 *f = fopen("/sys/power/state", "we");
-                if (!*f) {
-                        log_error_errno(errno, "Failed to open /sys/power/state: %m");
-                        return -errno;
-                }
+                if (!*f)
+                        return log_error_errno(errno, "Failed to open /sys/power/state: %m");
         }
 
         return r;
@@ -94,6 +92,7 @@ static int execute(char **modes, char **states) {
                 arg_verb,
                 NULL
         };
+        static const char* const dirs[] = {SYSTEM_SLEEP_PATH, NULL};
 
         int r;
         _cleanup_fclose_ FILE *f = NULL;
@@ -101,17 +100,15 @@ static int execute(char **modes, char **states) {
         /* This file is opened first, so that if we hit an error,
          * we can abort before modifying any state. */
         f = fopen("/sys/power/state", "we");
-        if (!f) {
-                log_error_errno(errno, "Failed to open /sys/power/state: %m");
-                return -errno;
-        }
+        if (!f)
+                return log_error_errno(errno, "Failed to open /sys/power/state: %m");
 
         /* Configure the hibernation mode */
         r = write_mode(modes);
         if (r < 0)
                 return r;
 
-        execute_directory(SYSTEM_SLEEP_PATH, NULL, DEFAULT_TIMEOUT_USEC, arguments);
+        execute_directories(dirs, DEFAULT_TIMEOUT_USEC, arguments);
 
         log_struct(LOG_INFO,
                    LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_START),
@@ -125,12 +122,12 @@ static int execute(char **modes, char **states) {
 
         log_struct(LOG_INFO,
                    LOG_MESSAGE_ID(SD_MESSAGE_SLEEP_STOP),
-                   LOG_MESSAGE("MESSAGE=System resumed."),
+                   LOG_MESSAGE("System resumed."),
                    "SLEEP=%s", arg_verb,
                    NULL);
 
         arguments[1] = (char*) "post";
-        execute_directory(SYSTEM_SLEEP_PATH, NULL, DEFAULT_TIMEOUT_USEC, arguments);
+        execute_directories(dirs, DEFAULT_TIMEOUT_USEC, arguments);
 
         return r;
 }