diff mbox series

[04/13] usb: Compile with -Wextra

Message ID 20210127085752.120571-5-aik@ozlabs.ru
State Superseded
Headers show
Series Compile with -Wextra | expand

Commit Message

Alexey Kardashevskiy Jan. 27, 2021, 8:57 a.m. UTC
-Wextra enables a bunch of rather useful checks which this fixes.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 lib/libusb/usb-core.c |  4 ++--
 lib/libusb/usb-hid.c  |  2 +-
 lib/libusb/usb-ohci.c | 12 +++++-------
 lib/libusb/usb-xhci.c |  4 ++--
 4 files changed, 10 insertions(+), 12 deletions(-)

Comments

Thomas Huth Jan. 28, 2021, 12:32 p.m. UTC | #1
On 27/01/2021 09.57, Alexey Kardashevskiy wrote:
> -Wextra enables a bunch of rather useful checks which this fixes.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>   lib/libusb/usb-core.c |  4 ++--
>   lib/libusb/usb-hid.c  |  2 +-
>   lib/libusb/usb-ohci.c | 12 +++++-------
>   lib/libusb/usb-xhci.c |  4 ++--
>   4 files changed, 10 insertions(+), 12 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/lib/libusb/usb-core.c b/lib/libusb/usb-core.c
index 4c720ce2f85b..6ad8028d03a2 100644
--- a/lib/libusb/usb-core.c
+++ b/lib/libusb/usb-core.c
@@ -18,7 +18,7 @@ 
 #ifdef DEBUG
 #define dprintf(_x ...) do { printf(_x); } while(0)
 #else
-#define dprintf(_x ...)
+#define dprintf(_x ...) do {} while (0)
 #endif
 
 #define __unused __attribute__((unused))
@@ -386,7 +386,7 @@  int usb_hid_exit(void *vdev)
 int usb_msc_init(void *vdev)
 {
 	struct usb_dev *dev;
-	int i;
+	unsigned i;
 
 	dev = (struct usb_dev *) vdev;
 	dprintf("%s: enter %x\n", __func__, dev->class);
diff --git a/lib/libusb/usb-hid.c b/lib/libusb/usb-hid.c
index 1ea9ff235f58..ce87d2194163 100644
--- a/lib/libusb/usb-hid.c
+++ b/lib/libusb/usb-hid.c
@@ -390,7 +390,7 @@  uint32_t *kbd_buffer;
 
 int usb_hid_kbd_init(struct usb_dev *dev)
 {
-	int i;
+	unsigned i;
 	uint8_t key[8];
 
 	usb_hid_set_protocol(dev, 0);
diff --git a/lib/libusb/usb-ohci.c b/lib/libusb/usb-ohci.c
index d06c754d184e..3f2ecf327444 100644
--- a/lib/libusb/usb-ohci.c
+++ b/lib/libusb/usb-ohci.c
@@ -21,7 +21,7 @@ 
 #ifdef OHCI_DEBUG
 #define dprintf(_x ...) do { printf(_x); } while(0)
 #else
-#define dprintf(_x ...)
+#define dprintf(_x ...) do {} while (0)
 #endif
 
 #undef OHCI_DEBUG_PACKET
@@ -29,7 +29,7 @@ 
 #ifdef OHCI_DEBUG_PACKET
 #define dpprintf(_x ...) do { printf(_x); } while(0)
 #else
-#define dpprintf(_x ...)
+#define dpprintf(_x ...) do {} while (0)
 #endif
 
 
@@ -199,10 +199,7 @@  static void ohci_hub_check_ports(struct ohci_hcd *ohcd)
 		}
 		if (port_status & RH_PS_PESC) {
 			port_clear |= RH_PS_PESC;
-			if (port_status & RH_PS_PES)
-				dprintf("enabled\n");
-			else
-				dprintf("disabled\n");
+			dprintf((port_status & RH_PS_PES) ? "enabled\n" : "disabled\n");
 		}
 		if (port_status & RH_PS_PSSC) {
 			port_clear |= RH_PS_PESC;
@@ -927,9 +924,10 @@  static struct usb_pipe *ohci_get_pipe(struct usb_dev *dev, struct usb_ep_descr *
 	new->epno = ep->bEndpointAddress & 0xF;
 	new->dir = ep->bEndpointAddress & 0x80;
 	if (new->type == USB_EP_TYPE_INTR)
-		if (!ohci_get_pipe_intr(new, ohcd, buf, buflen))
+		if (!ohci_get_pipe_intr(new, ohcd, buf, buflen)) {
 			dprintf("usb-ohci: %s alloc_intr failed  %p\n",
 				__func__, new);
+		}
 	if (new->type == USB_EP_TYPE_BULK)
 		ohci_init_bulk_ed(dev, new);
 
diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c
index 3ce6c004fa42..d3bb88d69b9d 100644
--- a/lib/libusb/usb-xhci.c
+++ b/lib/libusb/usb-xhci.c
@@ -1157,7 +1157,7 @@  static inline struct xhci_seg *xhci_pipe_get_seg(struct usb_pipe *pipe)
 static inline void *xhci_get_trb(struct xhci_seg *seg)
 {
 	uint64_t val, enq;
-	int index;
+	unsigned index;
 	struct xhci_link_trb *link;
 
 	enq = val = seg->enq;
@@ -1185,7 +1185,7 @@  static inline void *xhci_get_trb(struct xhci_seg *seg)
 static inline void *xhci_get_trb_deq(struct xhci_seg *seg)
 {
 	uint64_t deq_next, deq;
-	int index;
+	unsigned index;
 
 	deq = seg->deq;
 	deq_next = deq + XHCI_TRB_SIZE;