* [PATCH] USB: core: Fix compiler warnings in devio.c
@ 2019-06-25 20:00 Alan Stern
0 siblings, 0 replies; only message in thread
From: Alan Stern @ 2019-06-25 20:00 UTC (permalink / raw)
To: Greg KH; +Cc: USB list
In the current kernel, devio.c generates a number of compiler warnings
about taking the address of a member of a packed structure. The
warnings all look like this one:
drivers/usb/core/devio.c: In function ‘proc_do_submiturb’:
drivers/usb/core/devio.c:1489:43: warning: taking address of packed member of ‘struct usb_ctrlrequest’ may result in an unaligned pointer value [-Waddress-of-packed-member]
1489 | if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) {
| ^~~~~~~~~~~~
These warnings can easily be eliminated by changing various
le16_to_cpup() calls to use le16_to_cpu() instead.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
---
[as1903]
drivers/usb/core/devio.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: usb-devel/drivers/usb/core/devio.c
===================================================================
--- usb-devel.orig/drivers/usb/core/devio.c
+++ usb-devel/drivers/usb/core/devio.c
@@ -1486,15 +1486,15 @@ static int proc_do_submiturb(struct usb_
ret = -EFAULT;
goto error;
}
- if (uurb->buffer_length < (le16_to_cpup(&dr->wLength) + 8)) {
+ if (uurb->buffer_length < (le16_to_cpu(dr->wLength) + 8)) {
ret = -EINVAL;
goto error;
}
ret = check_ctrlrecip(ps, dr->bRequestType, dr->bRequest,
- le16_to_cpup(&dr->wIndex));
+ le16_to_cpu(dr->wIndex));
if (ret)
goto error;
- uurb->buffer_length = le16_to_cpup(&dr->wLength);
+ uurb->buffer_length = le16_to_cpu(dr->wLength);
uurb->buffer += 8;
if ((dr->bRequestType & USB_DIR_IN) && uurb->buffer_length) {
is_in = 1;
@@ -1509,9 +1509,9 @@ static int proc_do_submiturb(struct usb_
"bRequest=%02x wValue=%04x "
"wIndex=%04x wLength=%04x\n",
dr->bRequestType, dr->bRequest,
- __le16_to_cpup(&dr->wValue),
- __le16_to_cpup(&dr->wIndex),
- __le16_to_cpup(&dr->wLength));
+ __le16_to_cpu(dr->wValue),
+ __le16_to_cpu(dr->wIndex),
+ __le16_to_cpu(dr->wLength));
u = sizeof(struct usb_ctrlrequest);
break;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-06-25 20:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 20:00 [PATCH] USB: core: Fix compiler warnings in devio.c Alan Stern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).