From 8250881d74678e7312806960470db3636891d296 Mon Sep 17 00:00:00 2001 From: Chris Dickens Date: Tue, 28 Apr 2020 12:24:59 -0700 Subject: Fix some trivial compiler warnings for the Haiku and BSD backends * [-Wformat=] format 'S' expects argument of type 'T1', but argument N has type 'T2' * [-Wmissing-declarations] no previous declaration for 'func' * [-Wreorder] 'Class::Member' will be initialized after * [-Wsign-compare] comparison between signed and unsigned integer expressions * [-Wunused-but-set-variable] variable 'v' set but not used * [-Wunused-parameter] unused parameter 'p' Signed-off-by: Chris Dickens --- libusb/core.c | 4 ++-- libusb/os/haiku_usb_backend.cpp | 14 +++++++------- libusb/os/haiku_usb_raw.cpp | 1 + libusb/os/netbsd_usb.c | 18 +++++++++++------- libusb/os/openbsd_usb.c | 14 +++++++++----- libusb/version_nano.h | 2 +- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/libusb/core.c b/libusb/core.c index 009d0c8..00af3eb 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1639,7 +1639,7 @@ int API_EXPORTED libusb_set_configuration(libusb_device_handle *dev_handle, int configuration) { usbi_dbg("configuration %d", configuration); - if (configuration < -1 || configuration > UINT8_MAX) + if (configuration < -1 || configuration > (int)UINT8_MAX) return LIBUSB_ERROR_INVALID_PARAM; return usbi_backend.set_configuration(dev_handle, configuration); } @@ -1768,7 +1768,7 @@ int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev_hand interface_number, alternate_setting); if (interface_number < 0 || interface_number >= USB_MAXINTERFACES) return LIBUSB_ERROR_INVALID_PARAM; - if (alternate_setting < 0 || alternate_setting > UINT8_MAX) + if (alternate_setting < 0 || alternate_setting > (int)UINT8_MAX) return LIBUSB_ERROR_INVALID_PARAM; usbi_mutex_lock(&dev_handle->lock); diff --git a/libusb/os/haiku_usb_backend.cpp b/libusb/os/haiku_usb_backend.cpp index 9eda263..2b6ad71 100644 --- a/libusb/os/haiku_usb_backend.cpp +++ b/libusb/os/haiku_usb_backend.cpp @@ -26,7 +26,7 @@ #include "haiku_usb.h" -int _errno_to_libusb(int status) +static int _errno_to_libusb(int status) { return status; } @@ -127,7 +127,7 @@ USBTransfer::Do(int fRawFD) int i; usb_iso_packet_descriptor *packetDescriptors = new usb_iso_packet_descriptor[fLibusbTransfer->num_iso_packets]; for (i = 0; i < fLibusbTransfer->num_iso_packets; i++) { - if ((int16)(fLibusbTransfer->iso_packet_desc[i]).length != (fLibusbTransfer->iso_packet_desc[i]).length) { + if ((fLibusbTransfer->iso_packet_desc[i]).length > (unsigned int)INT16_MAX) { fUsbiTransfer->transferred = -1; usbi_err(TRANSFER_CTX(fLibusbTransfer), "failed isochronous transfer"); break; @@ -222,9 +222,9 @@ USBDeviceHandle::CancelTransfer(USBTransfer *transfer) USBDeviceHandle::USBDeviceHandle(USBDevice *dev) : - fTransfersThread(-1), fUSBDevice(dev), fClaimedInterfaces(0), + fTransfersThread(-1), fInitCheck(false) { fRawFD = open(dev->Location(), O_RDWR | O_CLOEXEC); @@ -295,7 +295,7 @@ USBDeviceHandle::SetAltSetting(int inumber, int alt) usbi_err(NULL, "Error retrieving active alternate interface"); return _errno_to_libusb(command.alternate.status); } - if (command.alternate.alternate_info == alt) { + if (command.alternate.alternate_info == (uint32)alt) { usbi_dbg("Setting alternate interface successful"); return LIBUSB_SUCCESS; } @@ -329,10 +329,10 @@ USBDeviceHandle::ClearHalt(uint8 endpoint) USBDevice::USBDevice(const char *path) : - fPath(NULL), - fActiveConfiguration(0), //0? - fConfigurationDescriptors(NULL), fClaimedInterfaces(0), + fConfigurationDescriptors(NULL), + fActiveConfiguration(0), //0? + fPath(NULL), fEndpointToIndex(NULL), fEndpointToInterface(NULL), fInitCheck(false) diff --git a/libusb/os/haiku_usb_raw.cpp b/libusb/os/haiku_usb_raw.cpp index f48c507..a9fb6b8 100644 --- a/libusb/os/haiku_usb_raw.cpp +++ b/libusb/os/haiku_usb_raw.cpp @@ -35,6 +35,7 @@ static int haiku_get_config_descriptor(struct libusb_device *, uint8_t, static int haiku_init(struct libusb_context *ctx) { + UNUSED(ctx); if (atomic_add(&gInitCount, 1) == 0) return gUsbRoster.Start(); return LIBUSB_SUCCESS; diff --git a/libusb/os/netbsd_usb.c b/libusb/os/netbsd_usb.c index 485208d..2a1359b 100644 --- a/libusb/os/netbsd_usb.c +++ b/libusb/os/netbsd_usb.c @@ -227,13 +227,13 @@ netbsd_get_active_config_descriptor(struct libusb_device *dev, { struct device_priv *dpriv = usbi_get_device_priv(dev); - len = MIN(len, UGETW(dpriv->cdesc->wTotalLength)); + len = MIN(len, (size_t)UGETW(dpriv->cdesc->wTotalLength)); - usbi_dbg("len %d", len); + usbi_dbg("len %zu", len); memcpy(buf, dpriv->cdesc, len); - return len; + return (int)len; } int @@ -244,7 +244,7 @@ netbsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx, struct usb_full_desc ufd; int fd, err; - usbi_dbg("index %d, len %d", idx, len); + usbi_dbg("index %u, len %zu", idx, len); /* A config descriptor may be requested before opening the device */ if (dpriv->fd >= 0) { @@ -269,7 +269,7 @@ netbsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx, if (dpriv->fd < 0) close(fd); - return len; + return (int)len; } int @@ -306,6 +306,8 @@ netbsd_claim_interface(struct libusb_device_handle *handle, int iface) struct handle_priv *hpriv = usbi_get_device_handle_priv(handle); int i; + UNUSED(iface); + for (i = 0; i < USB_MAX_ENDPOINTS; i++) hpriv->endpoints[i] = -1; @@ -318,6 +320,8 @@ netbsd_release_interface(struct libusb_device_handle *handle, int iface) struct handle_priv *hpriv = usbi_get_device_handle_priv(handle); int i; + UNUSED(iface); + for (i = 0; i < USB_MAX_ENDPOINTS; i++) if (hpriv->endpoints[i] >= 0) close(hpriv->endpoints[i]); @@ -379,13 +383,11 @@ int netbsd_submit_transfer(struct usbi_transfer *itransfer) { struct libusb_transfer *transfer; - struct handle_priv *hpriv; int err = 0; usbi_dbg(" "); transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); - hpriv = usbi_get_device_handle_priv(transfer->dev_handle); switch (transfer->type) { case LIBUSB_TRANSFER_TYPE_CONTROL: @@ -424,6 +426,8 @@ netbsd_submit_transfer(struct usbi_transfer *itransfer) int netbsd_cancel_transfer(struct usbi_transfer *itransfer) { + UNUSED(itransfer); + usbi_dbg(" "); return (LIBUSB_ERROR_NOT_SUPPORTED); diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c index 41550b0..42cfbd5 100644 --- a/libusb/os/openbsd_usb.c +++ b/libusb/os/openbsd_usb.c @@ -260,13 +260,13 @@ obsd_get_active_config_descriptor(struct libusb_device *dev, { struct device_priv *dpriv = usbi_get_device_priv(dev); - len = MIN(len, UGETW(dpriv->cdesc->wTotalLength)); + len = MIN(len, (size_t)UGETW(dpriv->cdesc->wTotalLength)); usbi_dbg("len %zu", len); memcpy(buf, dpriv->cdesc, len); - return (len); + return ((int)len); } int @@ -294,7 +294,7 @@ obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx, } close(fd); - return (len); + return ((int)len); } int @@ -331,6 +331,8 @@ obsd_claim_interface(struct libusb_device_handle *handle, int iface) struct handle_priv *hpriv = usbi_get_device_handle_priv(handle); int i; + UNUSED(iface); + for (i = 0; i < USB_MAX_ENDPOINTS; i++) hpriv->endpoints[i] = -1; @@ -343,6 +345,8 @@ obsd_release_interface(struct libusb_device_handle *handle, int iface) struct handle_priv *hpriv = usbi_get_device_handle_priv(handle); int i; + UNUSED(iface); + for (i = 0; i < USB_MAX_ENDPOINTS; i++) if (hpriv->endpoints[i] >= 0) close(hpriv->endpoints[i]); @@ -416,13 +420,11 @@ int obsd_submit_transfer(struct usbi_transfer *itransfer) { struct libusb_transfer *transfer; - struct handle_priv *hpriv; int err = 0; usbi_dbg(" "); transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); - hpriv = usbi_get_device_handle_priv(transfer->dev_handle); switch (transfer->type) { case LIBUSB_TRANSFER_TYPE_CONTROL: @@ -461,6 +463,8 @@ obsd_submit_transfer(struct usbi_transfer *itransfer) int obsd_cancel_transfer(struct usbi_transfer *itransfer) { + UNUSED(itransfer); + usbi_dbg(" "); return (LIBUSB_ERROR_NOT_SUPPORTED); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 5dac176..f15a1f1 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11511 +#define LIBUSB_NANO 11512 -- cgit v1.2.1