Skip to contentSkip to conversation

f2fs: Disable gcc9 -Waddress-of-packed-member

PATCH In review John Paul Adrian Glaubitz 3 participants 5 messages May 29, 2019 – Jun 3, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: Disable gcc9 -Waddress-of-packed-member

Disable the -Wadress-of-packaed-member diagnostic for the grub_f2fs_label function since the result is found to be false postive.

A pointer to the 'volume_name' member of 'struct grub_f2fs_superblock' is guaranteed to be aligned as the offset of 'volume_name' within the struct is dividable by the natural alignment on both 32- and 64-bit targets.

grub-core/fs/f2fs.c: In function ‘grub_f2fs_label’:
grub-core/fs/f2fs.c:1253:60: error: taking address of packed member of ‘struct grub_f2fs_superblock’ may result in an unaligned pointer value [-Werror=address-of-packed-member]

 1253 |     *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name);
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~

cc1: all warnings being treated as errors

---
 grub-core/fs/f2fs.c | 9 +++++++++
 1 file changed, 9 insertions(+)
grub-core/fs/f2fs.c +9 -0
index bb28b291b..8a9992ca9 100644
@@ -1240,6 +1240,11 @@ grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le)
   return out_buf;
 }
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
 static grub_err_t
 grub_f2fs_label (grub_device_t device, char **label)
 {
@@ -1260,6 +1265,10 @@ grub_f2fs_label (grub_device_t device, char **label)
   return grub_errno;
 }
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
 static grub_err_t
 grub_f2fs_uuid (grub_device_t device, char **uuid)
 {
Signature · 1 line
2.20.1
#1 lore raw

Neil, could you test this patch?

Quoted 47 lines · John Paul Adrian Glaubitz

Disable the -Wadress-of-packaed-member diagnostic for the grub_f2fs_label function since the result is found to be false postive.

A pointer to the 'volume_name' member of 'struct grub_f2fs_superblock' is guaranteed to be aligned as the offset of 'volume_name' within the struct is dividable by the natural alignment on both 32- and 64-bit targets.

grub-core/fs/f2fs.c: In function ‘grub_f2fs_label’:
grub-core/fs/f2fs.c:1253:60: error: taking address of packed member of ‘struct grub_f2fs_superblock’ may result in an unaligned pointer value [-Werror=address-of-packed-member]

 1253 |     *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name);
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~

cc1: all warnings being treated as errors

---
 grub-core/fs/f2fs.c | 9 +++++++++
 1 file changed, 9 insertions(+)
grub-core/fs/f2fs.c +9 -1
index bb28b291b..8a9992ca9 100644
@@ -1240,6 +1240,11 @@ grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le)
   return out_buf;
 }
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
 static grub_err_t
 grub_f2fs_label (grub_device_t device, char **label)
 {
@@ -1260,6 +1265,10 @@ grub_f2fs_label (grub_device_t device, char **label)
   return grub_errno;
 }
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
 static grub_err_t
 grub_f2fs_uuid (grub_device_t device, char **uuid)
 {
--

2.20.1

#2 lore raw

Hi Daniel

I can confirm that grub (based on 53e70d30cf0d18e6c28bab0ab8d223a90d3e1b46) is building with gcc-9.1 and this new patch.

I'm not in a position to run-time test the resulting grub binary, but it does at least now build!

Many thanks
Neil

Quoted 51 lines · Daniel Kiper

Neil, could you test this patch?

Quoted 47 lines · John Paul Adrian Glaubitz

Disable the -Wadress-of-packaed-member diagnostic for the grub_f2fs_label function since the result is found to be false postive.

A pointer to the 'volume_name' member of 'struct grub_f2fs_superblock' is guaranteed to be aligned as the offset of 'volume_name' within the struct is dividable by the natural alignment on both 32- and 64-bit targets.

grub-core/fs/f2fs.c: In function ‘grub_f2fs_label’:
grub-core/fs/f2fs.c:1253:60: error: taking address of packed member of ‘struct grub_f2fs_superblock’ may result in an unaligned pointer value [-Werror=address-of-packed-member]

 1253 |     *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name);
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~

cc1: all warnings being treated as errors

---
 grub-core/fs/f2fs.c | 9 +++++++++
 1 file changed, 9 insertions(+)
grub-core/fs/f2fs.c +9 -1
index bb28b291b..8a9992ca9 100644
@@ -1240,6 +1240,11 @@ grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le)
   return out_buf;
 }
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
+
 static grub_err_t
 grub_f2fs_label (grub_device_t device, char **label)
 {
@@ -1260,6 +1265,10 @@ grub_f2fs_label (grub_device_t device, char **label)
   return grub_errno;
 }
 
+#if __GNUC__ >= 9
+#pragma GCC diagnostic pop
+#endif
+
 static grub_err_t
 grub_f2fs_uuid (grub_device_t device, char **uuid)
 {
--

2.20.1

#3 lore raw
Quoted 8 lines · Neil MacLeod

Hi Daniel

I can confirm that grub (based on 53e70d30cf0d18e6c28bab0ab8d223a90d3e1b46) is building with gcc-9.1 and this new patch.

I'm not in a position to run-time test the resulting grub binary, but it does at least now build!

Patch pushed.

Neil, thanks for doing the test.

John, could you do your test builds?

Daniel

#4 lore raw
Quoted 1 line · Daniel Kiper

John, could you do your test builds?

Yes, can do.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913