U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1] usb: Guarantee alignment of the string descriptor
@ 2019-08-29 14:46 Andy Shevchenko
  2019-08-30  7:16 ` Bin Meng
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2019-08-29 14:46 UTC (permalink / raw)
  To: u-boot

GCC 9.x starts complaining about potential misalignment of the pointer to the
array (in this case alignment=2) in the packed (alignment=1) structures.

drivers/usb/gadget/composite.c:545:23: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  545 |    collect_langs(sp, s->wData);

drivers/usb/gadget/composite.c:550:24: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  550 |     collect_langs(sp, s->wData);

drivers/usb/gadget/composite.c:555:25: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  555 |      collect_langs(sp, s->wData);

Define structure alignment to be 2 to guarantee alignment of its members.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/usb/ch9.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 264c9712a3..a9b3c2709a 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -336,7 +336,7 @@ struct usb_string_descriptor {
 	__u8  bDescriptorType;
 
 	__le16 wData[1];		/* UTF-16LE encoded */
-} __attribute__ ((packed));
+} __attribute__ ((packed, aligned(2)));
 
 /* note that "string" zero is special, it holds language codes that
  * the device supports, not Unicode characters.
-- 
2.23.0.rc1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH v1] usb: Guarantee alignment of the string descriptor
  2019-08-29 14:46 [U-Boot] [PATCH v1] usb: Guarantee alignment of the string descriptor Andy Shevchenko
@ 2019-08-30  7:16 ` Bin Meng
  0 siblings, 0 replies; 2+ messages in thread
From: Bin Meng @ 2019-08-30  7:16 UTC (permalink / raw)
  To: u-boot

On Thu, Aug 29, 2019 at 10:46 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> GCC 9.x starts complaining about potential misalignment of the pointer to the
> array (in this case alignment=2) in the packed (alignment=1) structures.
>
> drivers/usb/gadget/composite.c:545:23: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member]
>   545 |    collect_langs(sp, s->wData);
>
> drivers/usb/gadget/composite.c:550:24: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member]
>   550 |     collect_langs(sp, s->wData);
>
> drivers/usb/gadget/composite.c:555:25: warning: taking address of packed member of ‘struct usb_string_descriptor’ may result in an unaligned pointer value [-Waddress-of-packed-member]
>   555 |      collect_langs(sp, s->wData);
>
> Define structure alignment to be 2 to guarantee alignment of its members.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/usb/ch9.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-30  7:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-29 14:46 [U-Boot] [PATCH v1] usb: Guarantee alignment of the string descriptor Andy Shevchenko
2019-08-30  7:16 ` Bin Meng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox