Ticket #75 (closed defect: fixed)

Opened 3 years ago

Last modified 20 months ago

[PATCH] Correctly check read() return code

Reported by: ludovicrousseau Owned by: segher
Milestone: Component: libusb-1.0
Keywords: Cc:
Blocked By: Blocks:

Description

read(2) returns a ssize_t (signed) and not a size_t (unsigned) or int

Fix the compiler warning:
os/linux_usbfs.c: In function ‘sysfs_get_active_config’:
os/linux_usbfs.c:366: warning: comparison of unsigned expression < 0 is always false

Attachments

0001-Correctly-check-read-return-code.patch (1.3 KB) - added by ludovicrousseau 3 years ago.

Download all attachments as: .zip

Change History

Changed 3 years ago by ludovicrousseau

comment:1 Changed 3 years ago by segher

  • Owner set to segher
  • Status changed from new to accepted

Looks good. It might be better still to only check for -1
though (which, incidentally, would work with size_t as well).

comment:2 Changed 20 months ago by Ludovic Rousseau <rousseau@…>

  • Resolution set to fixed
  • Status changed from accepted to closed

In [7802e4a3e38bcefccf96ae510ec2c6b7a959b8b5/libusb]:

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.

Note: See TracTickets for help on using tickets.