The returned errno from libevdev_input_create_from_device was returned
incorrectly because libevdev_uinput_destroy() would try to close the
unset value of ->fd, overwriting errno.
That was fixed in
debe9b030c8069cdf78307888ef3b65830b25122, this patch avoids
the ioctl/close calls if the fd isn't set.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
if (!uinput_dev)
return;
- (void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL);
- if (uinput_dev->fd_is_managed)
- close(uinput_dev->fd);
+ if (uinput_dev->fd >= 0) {
+ (void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL);
+ if (uinput_dev->fd_is_managed)
+ close(uinput_dev->fd);
+ }
free(uinput_dev->syspath);
free(uinput_dev->devnode);
free(uinput_dev->name);