Linux: Correctly catch read() errors for sysfs config descriptors
authorLudovic Rousseau <rousseau@debian.org>
Mon, 15 Nov 2010 13:55:51 +0000 (14:55 +0100)
committerPeter Stuge <peter@stuge.se>
Mon, 13 Jun 2011 20:01:42 +0000 (22:01 +0200)
read(2) returns ssize_t (signed) and not size_t (unsigned) or int.

Silence "warning: comparison of unsigned expression < 0 is always false"
and fix #75.

libusb/os/linux_usbfs.c

index ec6f230..44d705d 100644 (file)
@@ -363,7 +363,7 @@ static int sysfs_get_active_config(struct libusb_device *dev, int *config)
        char tmp[4] = {0, 0, 0, 0};
        long num;
        int fd;
-       size_t r;
+       ssize_t r;
 
        fd = __open_sysfs_attr(dev, "bConfigurationValue");
        if (fd < 0)
@@ -407,7 +407,7 @@ static int seek_to_next_config(struct libusb_context *ctx, int fd,
        struct libusb_config_descriptor config;
        unsigned char tmp[6];
        off_t off;
-       int r;
+       ssize_t r;
 
        /* read first 6 bytes of descriptor */
        r = read(fd, tmp, sizeof(tmp));