diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-18 17:13:42 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-18 18:21:28 +0100 |
commit | 06acf2d46a38bec212d78094e6ef8b100679048a (patch) | |
tree | b11d48d1ba1d1c05741b60df2631ab01150b1e3f /src/core | |
parent | e120204729764f6243b60899eb907103e678bee2 (diff) |
core,logind: libudev usage modernizations
Always use cleanup logic and don't eat up errors returned by libudev
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/umount.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/core/umount.c b/src/core/umount.c index e7460cb6bf..30111bea80 100644 --- a/src/core/umount.c +++ b/src/core/umount.c @@ -202,9 +202,10 @@ finish: } static int loopback_list_get(MountPoint **head) { - _cleanup_udev_unref_ struct udev *udev; _cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL; struct udev_list_entry *item = NULL, *first = NULL; + _cleanup_udev_unref_ struct udev *udev = NULL; + int r; assert(head); @@ -216,13 +217,21 @@ static int loopback_list_get(MountPoint **head) { if (!e) return -ENOMEM; - if (udev_enumerate_add_match_subsystem(e, "block") < 0 || - udev_enumerate_add_match_sysname(e, "loop*") < 0 || - udev_enumerate_add_match_sysattr(e, "loop/backing_file", NULL) < 0) - return -EIO; + r = udev_enumerate_add_match_subsystem(e, "block"); + if (r < 0) + return r; + + r = udev_enumerate_add_match_sysname(e, "loop*"); + if (r < 0) + return r; - if (udev_enumerate_scan_devices(e) < 0) - return -EIO; + r = udev_enumerate_add_match_sysattr(e, "loop/backing_file", NULL); + if (r < 0) + return r; + + r = udev_enumerate_scan_devices(e); + if (r < 0) + return r; first = udev_enumerate_get_list_entry(e); udev_list_entry_foreach(item, first) { @@ -257,9 +266,10 @@ static int loopback_list_get(MountPoint **head) { } static int dm_list_get(MountPoint **head) { - _cleanup_udev_unref_ struct udev *udev; _cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL; struct udev_list_entry *item = NULL, *first = NULL; + _cleanup_udev_unref_ struct udev *udev = NULL; + int r; assert(head); @@ -271,15 +281,19 @@ static int dm_list_get(MountPoint **head) { if (!e) return -ENOMEM; - if (udev_enumerate_add_match_subsystem(e, "block") < 0 || - udev_enumerate_add_match_sysname(e, "dm-*") < 0) - return -EIO; + r = udev_enumerate_add_match_subsystem(e, "block"); + if (r < 0) + return r; + + r = udev_enumerate_add_match_sysname(e, "dm-*"); + if (r < 0) + return r; - if (udev_enumerate_scan_devices(e) < 0) - return -EIO; + r = udev_enumerate_scan_devices(e); + if (r < 0) + return r; first = udev_enumerate_get_list_entry(e); - udev_list_entry_foreach(item, first) { MountPoint *m; _cleanup_udev_device_unref_ struct udev_device *d; |