]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
umount: show correct error message
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Dec 2019 15:59:42 +0000 (16:59 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 20 Dec 2019 17:15:59 +0000 (18:15 +0100)
We fucked up errno vs. r two times, let's correct that.

While we are at it, let's handle the error first, like we usually do,
and the clean case without indentation.

src/shutdown/umount.c

index 0b8044dacbc280d4c134a4ae4d2236f692c0405c..51ed05cb6a2969b1633f89f6260ea009c547821e 100644 (file)
@@ -515,13 +515,14 @@ static int swap_points_list_off(MountPoint **head, bool *changed) {
 
         LIST_FOREACH_SAFE(mount_point, m, n, *head) {
                 log_info("Deactivating swap %s.", m->path);
-                if (swapoff(m->path) == 0) {
-                        *changed = true;
-                        mount_point_free(head, m);
-                } else {
+                if (swapoff(m->path) < 0) {
                         log_warning_errno(errno, "Could not deactivate swap %s: %m", m->path);
                         n_failed++;
+                        continue;
                 }
+
+                *changed = true;
+                mount_point_free(head, m);
         }
 
         return n_failed;
@@ -551,15 +552,15 @@ static int loopback_points_list_detach(MountPoint **head, bool *changed, int umo
 
                 log_info("Detaching loopback %s.", m->path);
                 r = delete_loopback(m->path);
-                if (r >= 0) {
-                        if (r > 0)
-                                *changed = true;
-
-                        mount_point_free(head, m);
-                } else {
-                        log_full_errno(umount_log_level, errno, "Could not detach loopback %s: %m", m->path);
+                if (r < 0) {
+                        log_full_errno(umount_log_level, r, "Could not detach loopback %s: %m", m->path);
                         n_failed++;
+                        continue;
                 }
+                if (r > 0)
+                        *changed = true;
+
+                mount_point_free(head, m);
         }
 
         return n_failed;
@@ -584,23 +585,24 @@ static int dm_points_list_detach(MountPoint **head, bool *changed, int umount_lo
                         continue;
                 }
 
-                log_info("Detaching DM %u:%u.", major(m->devnum), minor(m->devnum));
+                log_info("Detaching DM %s (%u:%u).", m->path, major(m->devnum), minor(m->devnum));
                 r = delete_dm(m->devnum);
-                if (r >= 0) {
-                        *changed = true;
-                        mount_point_free(head, m);
-                } else {
-                        log_full_errno(umount_log_level, errno, "Could not detach DM %s: %m", m->path);
+                if (r < 0) {
+                        log_full_errno(umount_log_level, r, "Could not detach DM %s: %m", m->path);
                         n_failed++;
+                        continue;
                 }
+
+                *changed = true;
+                mount_point_free(head, m);
         }
 
         return n_failed;
 }
 
 static int umount_all_once(bool *changed, int umount_log_level) {
-        int r;
         _cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);
+        int r;
 
         assert(changed);