diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test-libudev.c | 8 | ||||
-rw-r--r-- | test/test-udev.c | 16 |
2 files changed, 11 insertions, 13 deletions
diff --git a/test/test-libudev.c b/test/test-libudev.c index 0e1202b449..912b61396a 100644 --- a/test/test-libudev.c +++ b/test/test-libudev.c @@ -30,6 +30,7 @@ #include <sys/epoll.h> #include "libudev.h" +#include "udev-util.h" #include "util.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -116,7 +117,7 @@ static void print_device(struct udev_device *device) { } static int test_device(struct udev *udev, const char *syspath) { - struct udev_device *device; + _cleanup_udev_device_unref_ struct udev_device *device; printf("looking at device: %s\n", syspath); device = udev_device_new_from_syspath(udev, syspath); @@ -125,12 +126,12 @@ static int test_device(struct udev *udev, const char *syspath) { return -1; } print_device(device); - udev_device_unref(device); + return 0; } static int test_device_parents(struct udev *udev, const char *syspath) { - struct udev_device *device; + _cleanup_udev_device_unref_ struct udev_device *device; struct udev_device *device_parent; printf("looking at device: %s\n", syspath); @@ -151,7 +152,6 @@ static int test_device_parents(struct udev *udev, const char *syspath) { print_device(device_parent); device_parent = udev_device_get_parent(device_parent); } while (device_parent != NULL); - udev_device_unref(device); return 0; } diff --git a/test/test-udev.c b/test/test-udev.c index fd4388a678..b3ff9a94cc 100644 --- a/test/test-udev.c +++ b/test/test-udev.c @@ -31,9 +31,10 @@ #include <sched.h> #include <sys/mount.h> #include <sys/signalfd.h> -#include <linux/fs.h> +#include "missing.h" #include "udev.h" +#include "udev-util.h" #ifndef HAVE_UNSHARE #include <sys/syscall.h> @@ -91,10 +92,10 @@ out: } int main(int argc, char *argv[]) { - struct udev *udev = NULL; - struct udev_event *event = NULL; - struct udev_device *dev = NULL; - struct udev_rules *rules = NULL; + _cleanup_udev_unref_ struct udev *udev = NULL; + _cleanup_udev_event_unref_ struct udev_event *event = NULL; + _cleanup_udev_device_unref_ struct udev_device *dev = NULL; + _cleanup_udev_rules_unref_ struct udev_rules *rules = NULL; char syspath[UTIL_PATH_SIZE]; const char *devpath; const char *action; @@ -169,10 +170,7 @@ int main(int argc, char *argv[]) { out: if (event != NULL && event->fd_signal >= 0) close(event->fd_signal); - udev_event_unref(event); - udev_device_unref(dev); - udev_rules_unref(rules); label_finish(); - udev_unref(udev); + return err ? EXIT_FAILURE : EXIT_SUCCESS; } |