[PATCH libevdev 2/2] uinput: preserve the errno before cleaning up

David Herrmann dh.herrmann at gmail.com
Thu Aug 14 04:44:06 PDT 2014


Hi

On Tue, Aug 12, 2014 at 8:00 AM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> libevdev_uinput_destroy() may/will botch the errno, make sure we save it
> before use.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  libevdev/libevdev-uinput.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libevdev/libevdev-uinput.c b/libevdev/libevdev-uinput.c
> index 4446b45..0cf3054 100644
> --- a/libevdev/libevdev-uinput.c
> +++ b/libevdev/libevdev-uinput.c
> @@ -277,6 +277,7 @@ LIBEVDEV_EXPORT int
>  libevdev_uinput_create_from_device(const struct libevdev *dev, int fd, struct libevdev_uinput** uinput_dev)
>  {
>         int rc;
> +       int errno_preserved;
>         struct uinput_user_dev uidev;
>         struct libevdev_uinput *new_device;
>
> @@ -344,8 +345,9 @@ libevdev_uinput_create_from_device(const struct libevdev *dev, int fd, struct li
>         return 0;
>
>  error:
> +       errno_preserved = errno;
>         libevdev_uinput_destroy(new_device);
> -       return -errno;
> +       return -errno_preserved;

Ugh? Why not:

rc = -errno;
libevdev_uinput_destroy(new_device);
return rc;

Thanks
David

>  }
>
>  LIBEVDEV_EXPORT void
> --
> 1.9.3
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/input-tools


More information about the Input-tools mailing list