]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
osdep/windows/platform: Disable gcc9 -Waddress-of-packed-member
authorDaniel Kiper <daniel.kiper@oracle.com>
Thu, 10 Mar 2022 15:10:17 +0000 (16:10 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 14 Mar 2022 22:05:00 +0000 (23:05 +0100)
$ ./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 <daniel.kiper@oracle.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
grub-core/osdep/windows/platform.c

index d24fbd37eb6ede0ff33087477d7c469121a2e9c4..af04c1a1ea73ee45dcf0fb2e5564b05d9698d4df 100644 (file)
@@ -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];