mount-util: don't clobber return value in umount_recursive()

We shouldn't override 'r' with the result of cunescape(), since we use
it to return the last error of umount().
This commit is contained in:
Lennart Poettering 2019-03-25 16:54:48 +01:00
parent 867189b545
commit f8b1904f96

View file

@ -29,8 +29,8 @@
#include "strv.h" #include "strv.h"
int umount_recursive(const char *prefix, int flags) { int umount_recursive(const char *prefix, int flags) {
bool again;
int n = 0, r; int n = 0, r;
bool again;
/* Try to umount everything recursively below a /* Try to umount everything recursively below a
* directory. Also, take care of stacked mounts, and keep * directory. Also, take care of stacked mounts, and keep
@ -73,9 +73,9 @@ int umount_recursive(const char *prefix, int flags) {
continue; continue;
} }
r = cunescape(path, UNESCAPE_RELAX, &p); k = cunescape(path, UNESCAPE_RELAX, &p);
if (r < 0) if (k < 0)
return r; return k;
if (!path_startswith(p, prefix)) if (!path_startswith(p, prefix))
continue; continue;
@ -95,7 +95,7 @@ int umount_recursive(const char *prefix, int flags) {
} while (again); } while (again);
return r ? r : n; return r < 0 ? r : n;
} }
static int get_mount_flags(const char *path, unsigned long *flags) { static int get_mount_flags(const char *path, unsigned long *flags) {