From: Lennart Poettering Date: Fri, 20 Dec 2019 15:59:42 +0000 (+0100) Subject: umount: show correct error message X-Git-Tag: v245-rc1~221^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=88287615e631d2023ff337a08b6ff45b1cfa58ee;p=thirdparty%2Fsystemd.git umount: show correct error message 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. --- diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c index 0b8044dacbc..51ed05cb6a2 100644 --- a/src/shutdown/umount.c +++ b/src/shutdown/umount.c @@ -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);