hidraw: use cleanup for udev enumerate

This commit is contained in:
Thomas Hindoe Paaboel Andersen
2018-03-31 22:40:19 +02:00
committed by Peter Hutterer
parent 1fab318dd3
commit de8cba13cf
2 changed files with 3 additions and 5 deletions

View File

@@ -1375,7 +1375,7 @@ ratbag_find_hidraw_node(struct ratbag_device *device,
int use_usb_parent)
{
struct ratbag *ratbag = device->ratbag;
struct udev_enumerate *e;
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
struct udev_list_entry *entry;
const char *path;
struct udev_device *hid_udev;
@@ -1421,15 +1421,12 @@ ratbag_find_hidraw_node(struct ratbag_device *device,
matched = match(device);
rc = matched ? 0 : -ENODEV;
if (matched == 1)
goto out;
return rc;
skip:
ratbag_close_hidraw(device);
}
out:
udev_enumerate_unref(e);
return rc;
}

View File

@@ -135,6 +135,7 @@ static inline void reset_errno(int *saved_errno)
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev*, udev_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_device*, udev_device_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_enumerate*, udev_enumerate_unref);
/*
* ELEMENTSOF() - number of array elements