diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-10-12 20:28:21 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-10-13 17:56:55 -0400 |
commit | 1ca208fb4f93e5869704af1812cbff7130a2fc03 (patch) | |
tree | 689343b99c76e4d34c625197762de97e8435571d /src/login/sysfs-show.c | |
parent | b506291ff195e03ce793ac925cc2d158f0b452b5 (diff) |
Introduce udev object cleanup functions
Diffstat (limited to 'src/login/sysfs-show.c')
-rw-r--r-- | src/login/sysfs-show.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c index 3c03bd1f2e..7c1adfaaca 100644 --- a/src/login/sysfs-show.c +++ b/src/login/sysfs-show.c @@ -26,6 +26,7 @@ #include "util.h" #include "sysfs-show.h" #include "path-util.h" +#include "udev-util.h" static int show_sysfs_one( struct udev *udev, @@ -143,9 +144,9 @@ static int show_sysfs_one( } int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) { - struct udev *udev; + _cleanup_udev_unref_ struct udev *udev; + _cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL; struct udev_list_entry *first = NULL; - struct udev_enumerate *e; int r; if (n_columns <= 0) @@ -162,10 +163,8 @@ int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) { return -ENOMEM; e = udev_enumerate_new(udev); - if (!e) { - r = -ENOMEM; - goto finish; - } + if (!e) + return ENOMEM; if (!streq(seat, "seat0")) r = udev_enumerate_add_match_tag(e, seat); @@ -173,22 +172,15 @@ int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) { r = udev_enumerate_add_match_tag(e, "seat"); if (r < 0) - goto finish; + return r; r = udev_enumerate_scan_devices(e); if (r < 0) - goto finish; + return r; first = udev_enumerate_get_list_entry(e); if (first) show_sysfs_one(udev, seat, &first, "/", prefix, n_columns); -finish: - if (e) - udev_enumerate_unref(e); - - if (udev) - udev_unref(udev); - return r; } |