chiark / gitweb /
fscd: fix error handling
[elogind.git] / src / fsckd / fsckd.c
index 4a61d80a18e3980d41ce30c8bb058e5d615fc41e..4ff8eeaeccf584cf8f84e205e97c76fe09cb9c37 100644 (file)
@@ -160,7 +160,7 @@ static int plymouth_feedback_handler(sd_event_source *s, int fd, uint32_t revent
 
 static int send_message_plymouth_socket(int plymouth_fd, const char *message, bool update) {
         _cleanup_free_ char *packet = NULL;
-        int r, n;
+        int n;
         char mode = 'M';
 
         if (update)
@@ -168,31 +168,37 @@ static int send_message_plymouth_socket(int plymouth_fd, const char *message, bo
 
         if (asprintf(&packet, "%c\002%c%s%n", mode, (int) (strlen(message) + 1), message, &n) < 0)
                 return log_oom();
-        r = loop_write(plymouth_fd, packet, n + 1, true);
-        return r;
-}
 
+        return loop_write(plymouth_fd, packet, n + 1, true);
+}
 
 static int send_message_plymouth(Manager *m, const char *message) {
-        int r;
         const char *plymouth_cancel_message = NULL;
+        int r;
 
         r = connect_plymouth(m);
         if (r < 0)
                 return r;
 
         if (!m->plymouth_cancel_sent) {
-                /* indicate to plymouth that we listen to Ctrl+C */
+
+                /* Indicate to plymouth that we listen to Ctrl+C */
                 r = loop_write(m->plymouth_fd, PLYMOUTH_REQUEST_KEY, sizeof(PLYMOUTH_REQUEST_KEY), true);
                 if (r < 0)
-                        return log_warning_errno(errno, "Can't send to plymouth cancel key: %m");
+                        return log_warning_errno(r, "Can't send to plymouth cancel key: %m");
+
                 m->plymouth_cancel_sent = true;
+
                 plymouth_cancel_message = strjoina("fsckd-cancel-msg:", _("Press Ctrl+C to cancel all filesystem checks in progress"));
+
                 r = send_message_plymouth_socket(m->plymouth_fd, plymouth_cancel_message, false);
                 if (r < 0)
                         log_warning_errno(r, "Can't send filesystem cancel message to plymouth: %m");
+
         } else if (m->numdevices == 0) {
+
                 m->plymouth_cancel_sent = false;
+
                 r = send_message_plymouth_socket(m->plymouth_fd, "", false);
                 if (r < 0)
                         log_warning_errno(r, "Can't clear plymouth filesystem cancel message: %m");
@@ -200,7 +206,7 @@ static int send_message_plymouth(Manager *m, const char *message) {
 
         r = send_message_plymouth_socket(m->plymouth_fd,  message, true);
         if (r < 0)
-                return log_warning_errno(errno, "Couldn't send \"%s\" to plymouth: %m", message);
+                return log_warning_errno(r, "Couldn't send \"%s\" to plymouth: %m", message);
 
         return 0;
 }