From 5a4d7cf08d80d56e3eb2cf2cd9f4f7b29588fa24 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Fri, 30 Mar 2012 13:40:32 +0100 Subject: [PATCH] Darwin: Fix a warning on 64 bit platforms --- libusb/os/darwin_usb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index e112cf5..60d2e03 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1547,7 +1547,11 @@ static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0) usbi_info (ITRANSFER_CTX (itransfer), "an async io operation has completed"); - size = (UInt32) arg0; + /* The size should never be larger than 4 GB - Also see libusb bug #117 */ + if ((intptr_t) arg0 > UINT32_MAX) + usbi_err (ITRANSFER_CTX (itransfer), + "async size truncation detected - please report this error"); + size = (UInt32) (intptr_t) arg0; /* send a completion message to the device's file descriptor */ message = MESSAGE_ASYNC_IO_COMPLETE; -- 2.7.4