From 7802e4a3e38bcefccf96ae510ec2c6b7a959b8b5 Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Mon, 15 Nov 2010 14:55:51 +0100 Subject: [PATCH] Linux: Correctly catch read() errors for sysfs config descriptors 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index ec6f230..44d705d 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -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)); -- 2.7.4