]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
initctl: do not ignore errors in function
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 7 Aug 2018 01:06:49 +0000 (10:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 7 Aug 2018 01:06:49 +0000 (10:06 +0900)
src/initctl/initctl.c

index 0c5aab6968deae9fedacf35afabe9f616096c0d5..c93c02bf48b26eec66366cd345f7b800b117b0f4 100644 (file)
@@ -81,7 +81,7 @@ static const char *translate_runlevel(int runlevel, bool *isolate) {
         return NULL;
 }
 
-static void change_runlevel(Server *s, int runlevel) {
+static int change_runlevel(Server *s, int runlevel) {
         const char *target;
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
         const char *mode;
@@ -93,7 +93,7 @@ static void change_runlevel(Server *s, int runlevel) {
         target = translate_runlevel(runlevel, &isolate);
         if (!target) {
                 log_warning("Got request for unknown runlevel %c, ignoring.", runlevel);
-                return;
+                return 0;
         }
 
         if (isolate)
@@ -112,10 +112,10 @@ static void change_runlevel(Server *s, int runlevel) {
                         &error,
                         NULL,
                         "ss", target, mode);
-        if (r < 0) {
-                log_error("Failed to change runlevel: %s", bus_error_message(&error, -r));
-                return;
-        }
+        if (r < 0)
+                return log_error_errno(r, "Failed to change runlevel: %s", bus_error_message(&error, -r));
+
+        return 0;
 }
 
 static void request_process(Server *s, const struct init_request *req) {
@@ -156,7 +156,7 @@ static void request_process(Server *s, const struct init_request *req) {
                                 break;
 
                         default:
-                                change_runlevel(s, req->runlevel);
+                                (void) change_runlevel(s, req->runlevel);
                         }
                 return;