From: Daniel Kiper Date: Thu, 10 Mar 2022 15:10:17 +0000 (+0100) Subject: osdep/windows/platform: Disable gcc9 -Waddress-of-packed-member X-Git-Tag: grub-2.12-rc1~445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70406f432b89426e2b1ac380363697db02e84e72;p=thirdparty%2Fgrub.git osdep/windows/platform: Disable gcc9 -Waddress-of-packed-member $ ./configure --target=x86_64-w64-mingw32 --with-platform=efi --host=x86_64-w64-mingw32 $ make [...] In file included from grub-core/osdep/platform.c:4: grub-core/osdep/windows/platform.c: In function ‘grub_install_register_efi’: grub-core/osdep/windows/platform.c:382:41: error: taking address of packed member of ‘struct grub_efi_file_path_device_path’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 382 | path16_len = grub_utf8_to_utf16 (filep->path_name, | ~~~~~^~~~~~~~~~~ Disable the -Wadress-of-packaed-member diagnostic for grub_utf8_to_utf16() call which contains filep->path_name reference. It seems safe because the structure is defined according to the UEFI spec and we hope authors did not make any mistake... :-) This fix is similar to the fix in the commit 8e8723a6b (f2fs: Disable gcc9 -Waddress-of-packed-member). Signed-off-by: Daniel Kiper Reviewed-by: Robbie Harwood --- diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c index d24fbd37e..af04c1a1e 100644 --- a/grub-core/osdep/windows/platform.c +++ b/grub-core/osdep/windows/platform.c @@ -379,10 +379,20 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, filep->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE; filep->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE; +#if __GNUC__ >= 9 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" +#endif + path16_len = grub_utf8_to_utf16 (filep->path_name, path8_len * GRUB_MAX_UTF16_PER_UTF8, (const grub_uint8_t *) efifile_path, path8_len, 0); + +#if __GNUC__ >= 9 +#pragma GCC diagnostic pop +#endif + filep->path_name[path16_len] = 0; filep->header.length = sizeof (*filep) + (path16_len + 1) * sizeof (grub_uint16_t); pathptr = &filep->path_name[path16_len + 1];