diff --git a/src/basic/macro.h b/src/basic/macro.h index b529fb15ff7..0a258cc614a 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -334,6 +334,12 @@ static inline int __coverity_check__(int condition) { } \ } while (false) +#define return_with_errno(r, err) \ + do { \ + errno = abs(err); \ + return r; \ + } while (false) + #define PTR_TO_INT(p) ((int) ((intptr_t) (p))) #define INT_TO_PTR(u) ((void *) ((intptr_t) (u))) #define PTR_TO_UINT(p) ((unsigned) ((uintptr_t) (p))) diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 37828b2f097..19695b5ee47 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -55,16 +55,12 @@ _public_ unsigned long long int udev_device_get_seqnum(struct udev_device *udev_ r = sd_device_get_property_value(udev_device->device, "SEQNUM", &seqnum); if (r == -ENOENT) return 0; - else if (r < 0) { - errno = -r; - return 0; - } + else if (r < 0) + return_with_errno(0, r); r = safe_atollu(seqnum, &ret); - if (r < 0) { - errno = -r; - return 0; - } + if (r < 0) + return_with_errno(0, r); return ret; } @@ -84,11 +80,10 @@ _public_ dev_t udev_device_get_devnum(struct udev_device *udev_device) { assert_return_errno(udev_device, makedev(0, 0), EINVAL); r = sd_device_get_devnum(udev_device->device, &devnum); - if (r < 0) { - if (r != -ENOENT) - errno = -r; + if (r == -ENOENT) return makedev(0, 0); - } + if (r < 0) + return_with_errno(makedev(0, 0), r); return devnum; } @@ -108,10 +103,8 @@ _public_ const char *udev_device_get_driver(struct udev_device *udev_device) { assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_driver(udev_device->device, &driver); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return driver; } @@ -131,11 +124,10 @@ _public_ const char *udev_device_get_devtype(struct udev_device *udev_device) { assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_devtype(udev_device->device, &devtype); - if (r < 0) { - if (r != -ENOENT) - errno = -r; + if (r == -ENOENT) return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return devtype; } @@ -156,11 +148,10 @@ _public_ const char *udev_device_get_subsystem(struct udev_device *udev_device) assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_subsystem(udev_device->device, &subsystem); - if (r < 0) { - errno = -r; - return NULL; - } else if (!subsystem) - errno = ENODATA; + if (r < 0) + return_with_errno(NULL, r); + if (!subsystem) + return_with_errno(NULL, ENODATA); return subsystem; } @@ -175,16 +166,14 @@ _public_ const char *udev_device_get_subsystem(struct udev_device *udev_device) * Returns: the property string, or #NULL if there is no such property. **/ _public_ const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key) { - const char *value = NULL; + const char *value; int r; assert_return_errno(udev_device && key, NULL, EINVAL); r = sd_device_get_property_value(udev_device->device, key, &value); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return value; } @@ -195,10 +184,8 @@ struct udev_device *udev_device_new(struct udev *udev, sd_device *device) { assert(device); udev_device = new(struct udev_device, 1); - if (!udev_device) { - errno = ENOMEM; - return NULL; - } + if (!udev_device) + return_with_errno(NULL, ENOMEM); *udev_device = (struct udev_device) { .n_ref = 1, @@ -206,10 +193,10 @@ struct udev_device *udev_device_new(struct udev *udev, sd_device *device) { .device = sd_device_ref(device), }; - udev_list_init(udev, &udev_device->properties, true); - udev_list_init(udev, &udev_device->tags, true); - udev_list_init(udev, &udev_device->sysattrs, true); - udev_list_init(udev, &udev_device->devlinks, true); + udev_list_init(&udev_device->properties, true); + udev_list_init(&udev_device->tags, true); + udev_list_init(&udev_device->sysattrs, true); + udev_list_init(&udev_device->devlinks, true); return udev_device; } @@ -233,10 +220,8 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con int r; r = sd_device_new_from_syspath(&device, syspath); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return udev_device_new(udev, device); } @@ -262,10 +247,8 @@ _public_ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char int r; r = sd_device_new_from_devnum(&device, type, devnum); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return udev_device_new(udev, device); } @@ -293,10 +276,8 @@ _public_ struct udev_device *udev_device_new_from_device_id(struct udev *udev, c int r; r = sd_device_new_from_device_id(&device, id); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return udev_device_new(udev, device); } @@ -321,10 +302,8 @@ _public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev int r; r = sd_device_new_from_subsystem_sysname(&device, subsystem, sysname); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return udev_device_new(udev, device); } @@ -348,10 +327,8 @@ _public_ struct udev_device *udev_device_new_from_environment(struct udev *udev) int r; r = device_new_from_strv(&device, environ); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return udev_device_new(udev, device); } @@ -363,10 +340,8 @@ static struct udev_device *device_new_from_parent(struct udev_device *child) { assert_return_errno(child, NULL, EINVAL); r = sd_device_get_parent(child->device, &parent); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return udev_device_new(child->udev, parent); } @@ -433,20 +408,16 @@ _public_ struct udev_device *udev_device_get_parent_with_subsystem_devtype(struc /* first find the correct sd_device */ r = sd_device_get_parent_with_subsystem_devtype(udev_device->device, subsystem, devtype, &parent); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); /* then walk the chain of udev_device parents until the corresponding one is found */ - while ((udev_device = udev_device_get_parent(udev_device))) { + while ((udev_device = udev_device_get_parent(udev_device))) if (udev_device->device == parent) return udev_device; - } - errno = ENOENT; - return NULL; + return_with_errno(NULL, ENOENT); } /** @@ -513,10 +484,8 @@ _public_ const char *udev_device_get_devpath(struct udev_device *udev_device) { assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_devpath(udev_device->device, &devpath); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return devpath; } @@ -537,10 +506,8 @@ _public_ const char *udev_device_get_syspath(struct udev_device *udev_device) { assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_syspath(udev_device->device, &syspath); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return syspath; } @@ -560,10 +527,8 @@ _public_ const char *udev_device_get_sysname(struct udev_device *udev_device) { assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_sysname(udev_device->device, &sysname); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return sysname; } @@ -583,11 +548,10 @@ _public_ const char *udev_device_get_sysnum(struct udev_device *udev_device) { assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_sysnum(udev_device->device, &sysnum); - if (r < 0) { - if (r != -ENOENT) - errno = -r; + if (r == -ENOENT) return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return sysnum; } @@ -608,10 +572,8 @@ _public_ const char *udev_device_get_devnode(struct udev_device *udev_device) { assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_devname(udev_device->device, &devnode); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return devnode; } @@ -639,7 +601,8 @@ _public_ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev udev_list_cleanup(&udev_device->devlinks); FOREACH_DEVICE_DEVLINK(udev_device->device, devlink) - udev_list_entry_add(&udev_device->devlinks, devlink, NULL); + if (!udev_list_entry_add(&udev_device->devlinks, devlink, NULL)) + return_with_errno(NULL, ENOMEM); udev_device->devlinks_read = true; udev_device->devlinks_generation = device_get_devlinks_generation(udev_device->device); @@ -670,7 +633,8 @@ _public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct ud udev_list_cleanup(&udev_device->properties); FOREACH_DEVICE_PROPERTY(udev_device->device, key, value) - udev_list_entry_add(&udev_device->properties, key, value); + if (!udev_list_entry_add(&udev_device->properties, key, value)) + return_with_errno(NULL, ENOMEM); udev_device->properties_read = true; udev_device->properties_generation = device_get_properties_generation(udev_device->device); @@ -690,16 +654,16 @@ _public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct ud * Returns: the kernel action value, or #NULL if there is no action value available. **/ _public_ const char *udev_device_get_action(struct udev_device *udev_device) { - const char *action = NULL; + const char *action; int r; assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_property_value(udev_device->device, "ACTION", &action); - if (r < 0 && r != -ENOENT) { - errno = -r; + if (r == -ENOENT) return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return action; } @@ -723,10 +687,8 @@ _public_ unsigned long long int udev_device_get_usec_since_initialized(struct ud assert_return(udev_device, -EINVAL); r = sd_device_get_usec_since_initialized(udev_device->device, &ts); - if (r < 0) { - errno = -r; - return 0; - } + if (r < 0) + return_with_errno(0, r); return ts; } @@ -748,10 +710,8 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi assert_return_errno(udev_device, NULL, EINVAL); r = sd_device_get_sysattr_value(udev_device->device, sysattr, &value); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return value; } @@ -797,7 +757,8 @@ _public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_ udev_list_cleanup(&udev_device->sysattrs); FOREACH_DEVICE_SYSATTR(udev_device->device, sysattr) - udev_list_entry_add(&udev_device->sysattrs, sysattr, NULL); + if (!udev_list_entry_add(&udev_device->sysattrs, sysattr, NULL)) + return_with_errno(NULL, ENOMEM); udev_device->sysattrs_read = true; } @@ -824,10 +785,8 @@ _public_ int udev_device_get_is_initialized(struct udev_device *udev_device) { assert_return(udev_device, -EINVAL); r = sd_device_get_is_initialized(udev_device->device); - if (r < 0) { - errno = -r; - return 0; - } + if (r < 0) + return_with_errno(0, r); return r; } @@ -853,7 +812,8 @@ _public_ struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_dev udev_list_cleanup(&udev_device->tags); FOREACH_DEVICE_TAG(udev_device->device, tag) - udev_list_entry_add(&udev_device->tags, tag, NULL); + if (!udev_list_entry_add(&udev_device->tags, tag, NULL)) + return_with_errno(NULL, ENOMEM); udev_device->tags_read = true; udev_device->tags_generation = device_get_tags_generation(udev_device->device); diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c index 41318d0a8db..e54ee572c58 100644 --- a/src/libudev/libudev-enumerate.c +++ b/src/libudev/libudev-enumerate.c @@ -54,22 +54,16 @@ _public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev) { int r; r = sd_device_enumerator_new(&e); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); r = sd_device_enumerator_allow_uninitialized(e); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); udev_enumerate = new(struct udev_enumerate, 1); - if (!udev_enumerate) { - errno = ENOMEM; - return NULL; - } + if (!udev_enumerate) + return_with_errno(NULL, ENOMEM); *udev_enumerate = (struct udev_enumerate) { .udev = udev, @@ -77,7 +71,7 @@ _public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev) { .enumerator = TAKE_PTR(e), }; - udev_list_init(udev, &udev_enumerate->devices_list, false); + udev_list_init(&udev_enumerate->devices_list, false); return udev_enumerate; } @@ -147,12 +141,11 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume int r; r = sd_device_get_syspath(device, &syspath); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); - udev_list_entry_add(&udev_enumerate->devices_list, syspath, NULL); + if (!udev_list_entry_add(&udev_enumerate->devices_list, syspath, NULL)) + return_with_errno(NULL, ENOMEM); } udev_enumerate->devices_uptodate = true; @@ -160,7 +153,7 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume e = udev_list_get_entry(&udev_enumerate->devices_list); if (!e) - errno = ENODATA; + return_with_errno(NULL, ENODATA); return e; } diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index 2dd0a8b4841..ed755e5d3cc 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -40,23 +40,19 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) { int r; r = sd_hwdb_new(&hwdb_internal); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); hwdb = new(struct udev_hwdb, 1); - if (!hwdb) { - errno = ENOMEM; - return NULL; - } + if (!hwdb) + return_with_errno(NULL, ENOMEM); *hwdb = (struct udev_hwdb) { .n_ref = 1, .hwdb = TAKE_PTR(hwdb_internal), }; - udev_list_init(udev, &hwdb->properties_list, true); + udev_list_init(&hwdb->properties_list, true); return hwdb; } @@ -111,16 +107,13 @@ _public_ struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev udev_list_cleanup(&hwdb->properties_list); - SD_HWDB_FOREACH_PROPERTY(hwdb->hwdb, modalias, key, value) { - if (!udev_list_entry_add(&hwdb->properties_list, key, value)) { - errno = ENOMEM; - return NULL; - } - } + SD_HWDB_FOREACH_PROPERTY(hwdb->hwdb, modalias, key, value) + if (!udev_list_entry_add(&hwdb->properties_list, key, value)) + return_with_errno(NULL, ENOMEM); e = udev_list_get_entry(&hwdb->properties_list); if (!e) - errno = ENODATA; + return_with_errno(NULL, ENODATA); return e; } diff --git a/src/libudev/libudev-list-internal.h b/src/libudev/libudev-list-internal.h index 1f75c37cb28..4e1632c78d6 100644 --- a/src/libudev/libudev-list-internal.h +++ b/src/libudev/libudev-list-internal.h @@ -8,7 +8,6 @@ struct udev_list_node { }; struct udev_list { - struct udev *udev; struct udev_list_node node; struct udev_list_entry **entries; unsigned entries_cur; @@ -16,9 +15,7 @@ struct udev_list { bool unique; }; -void udev_list_init(struct udev *udev, struct udev_list *list, bool unique); +void udev_list_init(struct udev_list *list, bool unique); void udev_list_cleanup(struct udev_list *list); struct udev_list_entry *udev_list_get_entry(struct udev_list *list); struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *name, const char *value); -int udev_list_entry_get_num(struct udev_list_entry *list_entry); -void udev_list_entry_set_num(struct udev_list_entry *list_entry, int num); diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c index a5d52272ccb..5f6726c2d82 100644 --- a/src/libudev/libudev-list.c +++ b/src/libudev/libudev-list.c @@ -65,9 +65,8 @@ static inline struct udev_list_entry *list_node_to_entry(struct udev_list_node * return container_of(node, struct udev_list_entry, node); } -void udev_list_init(struct udev *udev, struct udev_list *list, bool unique) { +void udev_list_init(struct udev_list *list, bool unique) { memzero(list, sizeof(struct udev_list)); - list->udev = udev; list->unique = unique; udev_list_node_init(&list->node); } @@ -300,15 +299,3 @@ _public_ const char *udev_list_entry_get_value(struct udev_list_entry *list_entr return NULL; return list_entry->value; } - -int udev_list_entry_get_num(struct udev_list_entry *list_entry) { - if (!list_entry) - return -EINVAL; - return list_entry->num; -} - -void udev_list_entry_set_num(struct udev_list_entry *list_entry, int num) { - if (!list_entry) - return; - list_entry->num = num; -} diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index 364ec096177..70036f5136a 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -69,22 +69,16 @@ _public_ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, c int r; g = monitor_netlink_group_from_string(name); - if (g < 0) { - errno = EINVAL; - return NULL; - } + if (g < 0) + return_with_errno(NULL, EINVAL); r = device_monitor_new_full(&m, g, -1); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); udev_monitor = new(struct udev_monitor, 1); - if (!udev_monitor) { - errno = ENOMEM; - return NULL; - } + if (!udev_monitor) + return_with_errno(NULL, ENOMEM); *udev_monitor = (struct udev_monitor) { .udev = udev, @@ -257,10 +251,8 @@ _public_ struct udev_device *udev_monitor_receive_device(struct udev_monitor *ud assert_return(udev_monitor, NULL); r = udev_monitor_receive_sd_device(udev_monitor, &device); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); return udev_device_new(udev_monitor->udev, device); } diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c index 60a84cb03be..4e055bbc37a 100644 --- a/src/libudev/libudev-queue.c +++ b/src/libudev/libudev-queue.c @@ -46,10 +46,8 @@ _public_ struct udev_queue *udev_queue_new(struct udev *udev) { struct udev_queue *udev_queue; udev_queue = new(struct udev_queue, 1); - if (!udev_queue) { - errno = ENOMEM; - return NULL; - } + if (!udev_queue) + return_with_errno(NULL, ENOMEM); *udev_queue = (struct udev_queue) { .udev = udev, @@ -188,8 +186,7 @@ _public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, un * Returns: NULL. **/ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) { - errno = ENODATA; - return NULL; + return_with_errno(NULL, ENODATA); } /** diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c index 4c26231f866..d11e7a9279d 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -72,10 +72,8 @@ _public_ struct udev *udev_new(void) { struct udev *udev; udev = new(struct udev, 1); - if (!udev) { - errno = ENOMEM; - return NULL; - } + if (!udev) + return_with_errno(NULL, ENOMEM); *udev = (struct udev) { .n_ref = 1, diff --git a/src/test/test-libudev.c b/src/test/test-libudev.c index c7cc453f7ed..10bf3650356 100644 --- a/src/test/test-libudev.c +++ b/src/test/test-libudev.c @@ -8,6 +8,7 @@ #include "alloc-util.h" #include "fd-util.h" +#include "libudev-list-internal.h" #include "libudev-util.h" #include "log.h" #include "stdio-util.h" @@ -404,6 +405,64 @@ static void test_util_resolve_subsys_kernel(void) { test_util_resolve_subsys_kernel_one("[net/lo]/address", true, 0, "00:00:00:00:00:00"); } +static void test_list(void) { + struct udev_list list = {}; + struct udev_list_entry *e; + + /* empty list */ + udev_list_init(&list, false); + assert_se(!udev_list_get_entry(&list)); + + /* unique == false */ + udev_list_init(&list, false); + assert_se(udev_list_entry_add(&list, "aaa", "hoge")); + assert_se(udev_list_entry_add(&list, "aaa", "hogehoge")); + assert_se(udev_list_entry_add(&list, "bbb", "foo")); + e = udev_list_get_entry(&list); + assert_se(e); + assert_se(streq_ptr(udev_list_entry_get_name(e), "aaa")); + assert_se(streq_ptr(udev_list_entry_get_value(e), "hoge")); + e = udev_list_entry_get_next(e); + assert_se(e); + assert_se(streq_ptr(udev_list_entry_get_name(e), "aaa")); + assert_se(streq_ptr(udev_list_entry_get_value(e), "hogehoge")); + e = udev_list_entry_get_next(e); + assert_se(e); + assert_se(streq_ptr(udev_list_entry_get_name(e), "bbb")); + assert_se(streq_ptr(udev_list_entry_get_value(e), "foo")); + assert_se(!udev_list_entry_get_next(e)); + + assert_se(!udev_list_entry_get_by_name(e, "aaa")); + assert_se(!udev_list_entry_get_by_name(e, "bbb")); + assert_se(!udev_list_entry_get_by_name(e, "ccc")); + udev_list_cleanup(&list); + + /* unique == true */ + udev_list_init(&list, true); + assert_se(udev_list_entry_add(&list, "aaa", "hoge")); + assert_se(udev_list_entry_add(&list, "aaa", "hogehoge")); + assert_se(udev_list_entry_add(&list, "bbb", "foo")); + e = udev_list_get_entry(&list); + assert_se(e); + assert_se(streq_ptr(udev_list_entry_get_name(e), "aaa")); + assert_se(streq_ptr(udev_list_entry_get_value(e), "hogehoge")); + e = udev_list_entry_get_next(e); + assert_se(streq_ptr(udev_list_entry_get_name(e), "bbb")); + assert_se(streq_ptr(udev_list_entry_get_value(e), "foo")); + assert_se(!udev_list_entry_get_next(e)); + + e = udev_list_entry_get_by_name(e, "bbb"); + assert_se(e); + assert_se(streq_ptr(udev_list_entry_get_name(e), "bbb")); + assert_se(streq_ptr(udev_list_entry_get_value(e), "foo")); + e = udev_list_entry_get_by_name(e, "aaa"); + assert_se(e); + assert_se(streq_ptr(udev_list_entry_get_name(e), "aaa")); + assert_se(streq_ptr(udev_list_entry_get_value(e), "hogehoge")); + assert_se(!udev_list_entry_get_by_name(e, "ccc")); + udev_list_cleanup(&list); +} + int main(int argc, char *argv[]) { _cleanup_(udev_unrefp) struct udev *udev = NULL; bool arg_monitor = false; @@ -486,5 +545,7 @@ int main(int argc, char *argv[]) { test_util_replace_whitespace(); test_util_resolve_subsys_kernel(); + test_list(); + return EXIT_SUCCESS; }