aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kiper <daniel.kiper@oracle.com>2022-03-10 16:10:17 +0100
committerDaniel Kiper <daniel.kiper@oracle.com>2022-03-14 23:05:00 +0100
commit70406f432b89426e2b1ac380363697db02e84e72 (patch)
tree0e5aa27a7d75e052d0cf0a4bc371d3b342cfcce4
parent0cfb9240ae2deeec1437bc1fc885a23842bbd132 (diff)
downloadgrub-70406f432b89426e2b1ac380363697db02e84e72.tar.gz
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 <daniel.kiper@oracle.com> Reviewed-by: Robbie Harwood <rharwood@redhat.com>
-rw-r--r--grub-core/osdep/windows/platform.c10
1 files changed, 10 insertions, 0 deletions
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];