diff options
author | Tormod Volden <debian.tormod@gmail.com> | 2022-02-02 18:15:59 +0100 |
---|---|---|
committer | Tormod Volden <debian.tormod@gmail.com> | 2022-03-18 18:52:54 +0100 |
commit | c6deb2f345edc90ea975bf2e66e3eb589a878e03 (patch) | |
tree | 24b94518a8ad4e646fd13adb816cc14c8aa4f847 | |
parent | 0666aff354ec0cf2f06b2d4ecc91831ef3b549be (diff) | |
download | libusb-c6deb2f345edc90ea975bf2e66e3eb589a878e03.tar.gz |
darwin: Avoid cast warnings in time calculation
Also use the USEC_PER_SEC macro for readability.
References #1035
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
-rw-r--r-- | libusb/os/darwin_usb.c | 7 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 4fac3fd..af3c4e9 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -43,7 +43,7 @@ /* Default timeout to 10s for reenumerate. This is needed because USBDeviceReEnumerate * does not return error status on macOS. */ -#define DARWIN_REENUMERATE_TIMEOUT_US 10000000 +#define DARWIN_REENUMERATE_TIMEOUT_US (10 * USEC_PER_SEC) #include <AvailabilityMacros.h> #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 && MAC_OS_X_VERSION_MIN_REQUIRED < 101200 @@ -1809,9 +1809,10 @@ static int darwin_reenumerate_device (struct libusb_device_handle *dev_handle, b struct timespec now; usbi_get_monotonic_time(&now); - UInt32 elapsed = (now.tv_sec - start.tv_sec) * 1000000 + (now.tv_nsec - start.tv_nsec) / 1000; + unsigned long elapsed_us = (now.tv_sec - start.tv_sec) * USEC_PER_SEC + + (now.tv_nsec - start.tv_nsec) / 1000; - if (elapsed >= DARWIN_REENUMERATE_TIMEOUT_US) { + if (elapsed_us >= DARWIN_REENUMERATE_TIMEOUT_US) { usbi_err (ctx, "darwin/reenumerate_device: timeout waiting for reenumerate"); dpriv->in_reenumerate = false; return LIBUSB_ERROR_TIMEOUT; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index e7daf21..65127d8 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11702 +#define LIBUSB_NANO 11703 |