[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/8] cpio: disable gcc9 -Waddress-of-packed-member
From: |
Michael Chang |
Subject: |
[PATCH v2 1/8] cpio: disable gcc9 -Waddress-of-packed-member |
Date: |
Thu, 11 Apr 2019 17:14:02 +0800 |
Disable the -Wadress-of-packaed-member diagnostic for the
grub_cpio_find_file function since the result is found to be false
postive. Any pointers to member of the 'struct head hd' is aligned even
if the structure is packed without paddings.
[ 59s] In file included from ../grub-core/fs/cpio.c:51:
[ 59s] ../grub-core/fs/cpio_common.c: In function 'grub_cpio_find_file':
[ 59s] ../grub-core/fs/cpio_common.c:58:31: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 58 | data->size = read_number (hd.filesize, ARRAY_SIZE
(hd.filesize));
[ 59s] | ~~^~~~~~~~~
[ 59s] ../grub-core/fs/cpio_common.c:60:29: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 60 | *mtime = read_number (hd.mtime, ARRAY_SIZE (hd.mtime));
[ 59s] | ~~^~~~~~
[ 59s] ../grub-core/fs/cpio_common.c:61:28: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 61 | modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
[ 59s] | ~~^~~~~
[ 59s] ../grub-core/fs/cpio_common.c:62:29: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 62 | namesize = read_number (hd.namesize, ARRAY_SIZE
(hd.namesize));
[ 59s] | ~~^~~~~~~~~
[ 59s] In file included from ../grub-core/fs/cpio_be.c:51:
[ 59s] ../grub-core/fs/cpio_common.c: In function 'grub_cpio_find_file':
[ 59s] ../grub-core/fs/cpio_common.c:58:31: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 58 | data->size = read_number (hd.filesize, ARRAY_SIZE
(hd.filesize));
[ 59s] | ~~^~~~~~~~~
[ 59s] ../grub-core/fs/cpio_common.c:60:29: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 60 | *mtime = read_number (hd.mtime, ARRAY_SIZE (hd.mtime));
[ 59s] | ~~^~~~~~
[ 59s] ../grub-core/fs/cpio_common.c:61:28: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 61 | modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
[ 59s] | ~~^~~~~
[ 59s] ../grub-core/fs/cpio_common.c:62:29: error: taking address of packed
member of 'struct head' may result in an unaligned pointer value
[-Werror=address-of-packed-member]
[ 59s] 62 | namesize = read_number (hd.namesize, ARRAY_SIZE
(hd.namesize));
[ 59s] | ~~^~~~~~~~~
Signed-off-by: Michael Chang <address@hidden>
---
grub-core/fs/cpio_common.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c
index ed134d931..4e885d623 100644
--- a/grub-core/fs/cpio_common.c
+++ b/grub-core/fs/cpio_common.c
@@ -36,6 +36,11 @@ struct grub_archelp_data
grub_off_t size;
};
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
static grub_err_t
grub_cpio_find_file (struct grub_archelp_data *data, char **name,
grub_int32_t *mtime, grub_uint32_t *mode)
@@ -96,6 +101,10 @@ grub_cpio_find_file (struct grub_archelp_data *data, char
**name,
return GRUB_ERR_NONE;
}
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
static char *
grub_cpio_get_link_target (struct grub_archelp_data *data)
{
--
2.16.4
- [PATCH v2 0/8] fix gcc9 build with -Werror=address-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 7/8] chainloader: fix gcc9 error -Waddress-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 3/8] hfs: fix gcc9 error -Waddress-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 4/8] hfsplus: fix gcc9 error with -Waddress-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 8/8] efi: fix gcc9 error -Waddress-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 2/8] jfs: disable gcc9 -Waddress-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 5/8] acpi: fix gcc9 error -Waddress-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 6/8] usbtest: disable gcc9 -Waddress-of-packed-member, Michael Chang, 2019/04/11
- [PATCH v2 1/8] cpio: disable gcc9 -Waddress-of-packed-member,
Michael Chang <=
- Re: [PATCH v2 0/8] fix gcc9 build with -Werror=address-of-packed-member, Daniel Kiper, 2019/04/18