[PATCH] usbtty: fix possible alignment issues

Simon Glass sjg at chromium.org
Thu Jan 30 03:17:13 CET 2020


On Mon, 6 Jan 2020 at 22:17, Seung-Woo Kim <sw0312.kim at samsung.com> wrote:
>
> With gcc9, below warnings are shown:
>   drivers/serial/usbtty.c: In function 'usbtty_init_strings':
>   drivers/serial/usbtty.c:590:44: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
>     590 |  str2wide (CONFIG_USBD_MANUFACTURER, string->wData);
>         |                                      ~~~~~~^~~~~~~
>   drivers/serial/usbtty.c:596:44: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
>     597 |  str2wide (CONFIG_USBD_PRODUCT_NAME, string->wData);
>         |                                      ~~~~~~^~~~~~~
>   drivers/serial/usbtty.c:603:33: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
>     604 |  str2wide (serial_number, string->wData);
>         |                           ~~~~~~^~~~~~~
>   drivers/serial/usbtty.c:610:49: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
>     611 |  str2wide (CONFIG_USBD_CONFIGURATION_STR, string->wData);
>         |                                           ~~~~~~^~~~~~~
>   drivers/serial/usbtty.c:617:50: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
>     618 |  str2wide (CONFIG_USBD_DATA_INTERFACE_STR, string->wData);
>         |                                            ~~~~~~^~~~~~~
>   drivers/serial/usbtty.c:623:50: warning: taking address of packed member of 'struct usb_string_descriptor' may result in an unaligned pointer value [-Waddress-of-packed-member]
>     624 |  str2wide (CONFIG_USBD_CTRL_INTERFACE_STR, string->wData);
>         |                                            ~~~~~~^~~~~~~
>
> Fix the issues by using packed structure.
>
> Ref: commit 616ebd8b9cb4 ("usb: composite: fix possible alignment issues")
> Signed-off-by: Seung-Woo Kim <sw0312.kim at samsung.com>
> ---
>  drivers/serial/usbtty.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

+Marek Vasut

Reviewed-by: Simon Glass <sjg at chromium.org>

I wonder if we should use the put_unaligned macros?

Regards,
Simon


More information about the U-Boot mailing list