usb: thor: fix possible alignment issues 17/221717/1 accepted/tizen/unified/20200108.131623 submit/tizen/20200107.060950
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 7 Jan 2020 05:27:37 +0000 (14:27 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 7 Jan 2020 05:27:40 +0000 (14:27 +0900)
With gcc9, address-of-packed-member warnings are shown. Fix the
issues by using packed structure.

Change-Id: Ia375a212e112a935eefaa7ea6105b0bbceae52a3
Ref: https://patchwork.ozlabs.org/patch/1218603/
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
property/usb/cdc_descriptor.c

index bf27148..6dba80f 100644 (file)
@@ -8,6 +8,8 @@
 #define THOR_VENDOR_NUM                        0x04E8
 #define THOR_PRODUCT_NUM               0x685D
 
+typedef struct { __le16 val; } __attribute__((aligned(16))) __le16_packed;
+
 static struct usb_device_descriptor thor_device_desc_high __align (32)= {
        .bLength                        = sizeof(thor_device_desc_high),
        .bDescriptorType        = USB_DT_DEVICE,
@@ -272,14 +274,15 @@ unsigned char *thor_get_config_desc(unsigned int speed)
        return (unsigned char *) &function_desc_buf;
 }
 
-static void str2wide (char *str, u16 * wide)
+static void str2wide (char *str, void *wide)
 {
        int i;
+       __le16_packed   *tmp = wide;
        for (i = 0; i < strlen (str) && str[i]; i++){
                #if defined(__LITTLE_ENDIAN)
-                       wide[i] = (u16) str[i];
+                       tmp[i].val = (u16) str[i];
                #elif defined(__BIG_ENDIAN)
-                       wide[i] = ((u16)(str[i])<<8);
+                       tmp[i].val = ((u16)(str[i])<<8);
                #else
                        #error "__LITTLE_ENDIAN or __BIG_ENDIAN undefined"
                #endif