From 497bbf94d0e19320d17b521dae7ac66ab3157d9d Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 19 Nov 2013 18:20:13 +0200 Subject: [PATCH] android/hidhost: Fix misuse of errno --- android/hidhost.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/android/hidhost.c b/android/hidhost.c index 502b10b17..d50c5b81c 100644 --- a/android/hidhost.c +++ b/android/hidhost.c @@ -516,13 +516,15 @@ static void bt_hid_set_info(struct hid_device *dev) static int uhid_create(struct hid_device *dev) { GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_NVAL; - GIOChannel *io; struct uhid_event ev; + GIOChannel *io; + int err; dev->uhid_fd = open(UHID_DEVICE_FILE, O_RDWR | O_CLOEXEC); if (dev->uhid_fd < 0) { + err = -errno; error("Failed to open uHID device: %s", strerror(errno)); - return -errno; + return err; } memset(&ev, 0, sizeof(ev)); @@ -537,10 +539,11 @@ static int uhid_create(struct hid_device *dev) ev.u.create.rd_data = dev->rd_data; if (write(dev->uhid_fd, &ev, sizeof(ev)) < 0) { + err = -errno; error("Failed to create uHID device: %s", strerror(errno)); close(dev->uhid_fd); dev->uhid_fd = -1; - return -errno; + return err; } io = g_io_channel_unix_new(dev->uhid_fd); -- 2.47.3