]> git.itanic.dy.fi Git - glucose/commitdiff
_hiddev_open: Fix error messages
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 27 Mar 2012 18:12:01 +0000 (21:12 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 27 Mar 2012 18:12:01 +0000 (21:12 +0300)
Not all of the errors are caused by device open. There is actually
only one error case for open and two for ioctls. Fix the error
messages.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
hiddev.c

index d02f463c0852483b2567ce9aa6edbd163dbc507d..048e3b14749524e8d8b2fc1e51d80a5f0819dea2 100644 (file)
--- a/hiddev.c
+++ b/hiddev.c
@@ -115,20 +115,22 @@ static int _hiddev_open(const char *device_path, int *usage_code,
 {
        struct hiddev_devinfo device_info;
        struct hiddev_report_info rinfo;
 {
        struct hiddev_devinfo device_info;
        struct hiddev_report_info rinfo;
-       int ret, error;
+       int ret;
        int fd;
 
        trace(3, "Opening device %s\n", device_path);
        fd = ret = open(device_path, O_RDWR);
 
        int fd;
 
        trace(3, "Opening device %s\n", device_path);
        fd = ret = open(device_path, O_RDWR);
 
-       if (fd < 0)
-               goto err;
+       if (fd < 0) {
+               trace(0, "Error opening device %s: %m\n", device_path);
+               return -1;
+       }
 
        rinfo.report_type = HID_REPORT_TYPE_OUTPUT;
        rinfo.report_id = HID_REPORT_ID_FIRST;
        ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
        if (ret < 0)
 
        rinfo.report_type = HID_REPORT_TYPE_OUTPUT;
        rinfo.report_id = HID_REPORT_ID_FIRST;
        ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
        if (ret < 0)
-               goto err_close;
+               goto err_ioctl;
 
        PRINT_FIELD(3, rinfo.report_type);
        PRINT_FIELD(3, rinfo.report_id);
 
        PRINT_FIELD(3, rinfo.report_type);
        PRINT_FIELD(3, rinfo.report_id);
@@ -142,7 +144,7 @@ static int _hiddev_open(const char *device_path, int *usage_code,
        ret = ioctl(fd, HIDIOCGDEVINFO, &device_info);
 
        if (ret < 0)
        ret = ioctl(fd, HIDIOCGDEVINFO, &device_info);
 
        if (ret < 0)
-               goto err_close;
+               goto err_ioctl;
 
        PRINT_FIELD(3, device_info.bustype);
        PRINT_FIELD(3, device_info.busnum);
 
        PRINT_FIELD(3, device_info.bustype);
        PRINT_FIELD(3, device_info.busnum);
@@ -164,13 +166,12 @@ static int _hiddev_open(const char *device_path, int *usage_code,
 
        return fd;
 
 
        return fd;
 
+err_ioctl:
+       trace(0, "Error issuing ioctl: %m\n");
+
 err_close:
        close(fd);
 err_close:
        close(fd);
-err:
-       error = errno;
-       if (error)
-               printf("Error opening device %s: %s\n", device_path,
-                       strerror(error));
+
        return ret;
 }
 
        return ret;
 }