]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
usbtest: Disable gcc9 -Waddress-of-packed-member
authorMichael Chang <mchang@suse.com>
Thu, 11 Apr 2019 09:14:07 +0000 (17:14 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 23 Apr 2019 09:37:08 +0000 (11:37 +0200)
Disable the -Wadress-of-packaed-member diagnostic for the
grub_usb_get_string function since the result is false postive. The
descstrp->str is found to be aligned in the buffer allocated for 'struct
grub_usb_desc_str'.

[  229s] ../../grub-core/commands/usbtest.c: In function 'grub_usb_get_string':
[  229s] ../../grub-core/commands/usbtest.c:104:58: error: taking address of packed member of 'struct grub_usb_desc_str' may result in an unaligned pointer value [-Werror=address-of-packed-member]
[  229s]   104 |   *grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str,
[  229s]       |                                                  ~~~~~~~~^~~~~

Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/usbtest.c

index 01cdca93466863cc20597f2a0db373e5fd2c71fd..2c6d93fe66d5f1d0f322d69106eff9c4f748c53b 100644 (file)
@@ -63,6 +63,11 @@ static const char *usb_devspeed[] =
     "High"
   };
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
 static grub_usb_err_t
 grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
                     char **string)
@@ -108,6 +113,10 @@ grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
   return GRUB_USB_ERR_NONE;
 }
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
 static void
 usb_print_str (const char *description, grub_usb_device_t dev, int idx)
 {