[PATCH libevdev 2/2] uinput: preserve the errno before cleaning up
Peter Hutterer
peter.hutterer at who-t.net
Thu Aug 14 15:39:33 PDT 2014
On Thu, Aug 14, 2014 at 01:44:06PM +0200, David Herrmann wrote:
> 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;
good point. amended and pushed, thanks.
Cheers,
Peter
More information about the Input-tools
mailing list