libevdev_uinput_destroy: don't close non-open FD

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 debe9b030c, this patch avoids
the ioctl/close calls if the fd isn't set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Owen W. Taylor 2015-01-19 16:45:49 -05:00 committed by Peter Hutterer
parent f4cc76d96f
commit 867a237c55

View file

@ -358,9 +358,11 @@ libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev)
if (!uinput_dev) if (!uinput_dev)
return; return;
if (uinput_dev->fd >= 0) {
(void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL); (void)ioctl(uinput_dev->fd, UI_DEV_DESTROY, NULL);
if (uinput_dev->fd_is_managed) if (uinput_dev->fd_is_managed)
close(uinput_dev->fd); close(uinput_dev->fd);
}
free(uinput_dev->syspath); free(uinput_dev->syspath);
free(uinput_dev->devnode); free(uinput_dev->devnode);
free(uinput_dev->name); free(uinput_dev->name);