Linux: fix log message that was being unconditionally sent to stderr (#44)
authorDaniel Drake <dan@reactivated.net>
Tue, 22 Jun 2010 23:20:23 +0000 (18:20 -0500)
committerDaniel Drake <dan@reactivated.net>
Tue, 22 Jun 2010 23:20:23 +0000 (18:20 -0500)
This message was put in place to aid libusb-compat-0.1 users, who
may run into the change that libusb-0.1 allowed you to usb_open() a
device that you don't have write access to, but libusb-1.0 does not.

As explained on the ticket this change is dangerous so it should go through
the usual logging mechanism. I also added a similar regular log message
to libusb-compat-0.1.

libusb/os/linux_usbfs.c

index cf69286..e3da552 100644 (file)
@@ -1055,10 +1055,9 @@ static int op_open(struct libusb_device_handle *handle)
        hpriv->fd = open(filename, O_RDWR);
        if (hpriv->fd < 0) {
                if (errno == EACCES) {
-                       fprintf(stderr, "libusb couldn't open USB device %s: "
-                               "Permission denied.\n"
-                               "libusb requires write access to USB device nodes.\n",
-                               filename);
+                       usbi_err("libusb couldn't open USB device %s: "
+                               "Permission denied.", filename);
+                       usbi_err("libusb requires write access to USB device nodes.");
                        return LIBUSB_ERROR_ACCESS;
                } else if (errno == ENOENT) {
                        return LIBUSB_ERROR_NO_DEVICE;