[SLOF] [PATCH slof v2 03/12] usb: Compile with -Wextra
Alexey Kardashevskiy
aik at ozlabs.ru
Tue Feb 9 12:44:48 AEDT 2021
-Wextra enables a bunch of rather useful checks which this fixes with
one exception of -Wunused-parameter - this fixes it for debug macros only
and leave the rest for the future as more functional change is needed.
Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
---
Changes:
v2:
* updated debug macros to fix -Wunused-parameter
---
These are not fixed:
====== Building common libraries ======
[CC] usb-core.o
[CC] usb-ohci.o
[CC] usb-hid.o
[CC] usb-xhci.o
/home/aik/p/slof/lib/libusb/usb-core.c: In function ‘usb_set_address’:
/home/aik/p/slof/lib/libusb/usb-core.c:244:58: warning: unused parameter ‘port’ [-Wunused-parameter]
static int usb_set_address(struct usb_dev *dev, uint32_t port)
^~~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_send_enable_slot’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:353:67: warning: unused parameter ‘port’ [-Wunused-parameter]
static void xhci_send_enable_slot(struct xhci_hcd *xhcd, uint32_t port)
^~~~
/home/aik/p/slof/lib/libusb/usb-ohci.c: In function ‘ohci_dump_regs’:
/home/aik/p/slof/lib/libusb/usb-ohci.c:42:46: warning: unused parameter ‘regs’ [-Wunused-parameter]
static void ohci_dump_regs(struct ohci_regs *regs)
^~~~
/home/aik/p/slof/lib/libusb/usb-core.c: In function ‘usb_handle_device’:
/home/aik/p/slof/lib/libusb/usb-core.c:444:80: warning: unused parameter ‘cfg’ [-Wunused-parameter]
static int usb_handle_device(struct usb_dev *dev, struct usb_dev_config_descr *cfg,
^~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘fill_setup_trb’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:1026:13: warning: unused parameter ‘size’ [-Wunused-parameter]
uint32_t size)
^~~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_transfer_bulk’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:1217:60: warning: unused parameter ‘td’ [-Wunused-parameter]
static int xhci_transfer_bulk(struct usb_pipe *pipe, void *td, void *td_phys,
^~
/home/aik/p/slof/lib/libusb/usb-xhci.c:1217:70: warning: unused parameter ‘td_phys’ [-Wunused-parameter]
static int xhci_transfer_bulk(struct usb_pipe *pipe, void *td, void *td_phys,
^~~~~~~
/home/aik/p/slof/lib/libusb/usb-xhci.c: In function ‘xhci_get_pipe_intr’:
/home/aik/p/slof/lib/libusb/usb-xhci.c:1364:22: warning: unused parameter ‘len’ [-Wunused-parameter]
char *buf, size_t len)
^~~
---
lib/libusb/usb-core.c | 4 ++--
lib/libusb/usb-ehci.c | 3 ++-
lib/libusb/usb-hid.c | 2 +-
lib/libusb/usb-ohci.c | 12 +++++-------
lib/libusb/usb-xhci.c | 17 +++++++++--------
5 files changed, 19 insertions(+), 19 deletions(-)
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-ehci.c b/lib/libusb/usb-ehci.c
index 60af9e101fab..4b1b0a8de5da 100644
--- a/lib/libusb/usb-ehci.c
+++ b/lib/libusb/usb-ehci.c
@@ -22,7 +22,8 @@
#ifdef EHCI_DEBUG
#define dprintf(_x ...) do { printf(_x); } while(0)
#else
-#define dprintf(_x ...)
+#define dprintf(_x ...) do {} while (0)
+
#endif
#ifdef EHCI_DEBUG
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..cdf804287112 100644
--- a/lib/libusb/usb-xhci.c
+++ b/lib/libusb/usb-xhci.c
@@ -22,7 +22,7 @@
#ifdef XHCI_DEBUG
#define dprintf(_x ...) do { printf("%s: ", __func__); printf(_x); } while (0)
#else
-#define dprintf(_x ...)
+#define dprintf(_x ...) do {} while (0)
#endif
struct port_state ps_array_usb2[] = {
@@ -42,9 +42,9 @@ struct port_state ps_array_usb3[] = {
{1, 1, 1, 0, PORTSC_PLS_U0, "****** Enabled ******"},
};
+#ifdef XHCI_DEBUG
static void dump_xhci_regs(struct xhci_hcd *xhcd)
{
-#ifdef XHCI_DEBUG
struct xhci_cap_regs *cap;
struct xhci_op_regs *op;
struct xhci_run_regs *run;
@@ -75,12 +75,10 @@ static void dump_xhci_regs(struct xhci_hcd *xhcd)
dprintf(" - MFINDEX %08X\n", read_reg32(&run->mfindex));
dprintf("\n");
-#endif
}
static void print_port_status(struct xhci_port_regs *prs)
{
-#ifdef XHCI_DEBUG
uint32_t portsc;
uint32_t CCS, PED, PP, PLS, i, PR = 0;
@@ -152,10 +150,13 @@ static void print_port_status(struct xhci_port_regs *prs)
}
}
}
-#endif
-
}
+#else
+#define dump_xhci_regs(r) do {} while (0)
+#define print_port_status(prs) do {} while (0)
+#endif
+
static inline bool xhci_is_hc_ready(uint32_t *usbsts)
{
return !(read_reg32(usbsts) & XHCI_USBSTS_CNR);
@@ -1157,7 +1158,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 +1186,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;
--
2.17.1
More information about the SLOF
mailing list