Skip to contentSkip to conversation

xfsprogs: don't warn about packed members

PATCH In review Dave Chinner 5 participants 13 messages Dec 16, 2019 – Apr 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsprogs: don't warn about packed members

From: Dave Chinner <[email protected]>

gcc 9.2.1 throws lots of new warnings during the build like this:

xfs_format.h:790:3: warning: taking address of packed member of ‘struct xfs_agfl’ may result in an unaligned pointer value [-Waddress-of-packed-member]

  790 |   &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xfs_alloc.c:3149:13: note: in expansion of macro ‘XFS_BUF_TO_AGFL_BNO’
 3149 |  agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
      |             ^~~~~~~~~~~~~~~~~~~

We know this packed structure aligned correctly, so turn off this warning to shut gcc up.

---
 include/builddefs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/builddefs.in +1 -1
index 4700b52706a7..6fdc9ebb70c7 100644
@@ -13,7 +13,7 @@ OPTIMIZER = @opt_build@
 MALLOCLIB = @malloc_lib@
 LOADERFLAGS = @LDFLAGS@
 LTLDFLAGS = @LDFLAGS@
-CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64
+CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member
 BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64
 
 LIBRT = @librt@
Signature · 1 line
2.24.0.rc0
#1 lore raw
Quoted 11 lines · Dave Chinner

From: Dave Chinner <[email protected]>

gcc 9.2.1 throws lots of new warnings during the build like this:

xfs_format.h:790:3: warning: taking address of packed member of ‘struct xfs_agfl’ may result in an unaligned pointer value [-Waddress-of-packed-member]

  790 |   &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xfs_alloc.c:3149:13: note: in expansion of macro ‘XFS_BUF_TO_AGFL_BNO’
 3149 |  agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
      |             ^~~~~~~~~~~~~~~~~~~
Quoted 5 lines

We know this packed structure aligned correctly, so turn off this warning to shut gcc up.

---

I'm wondering if we could just use offsetof() in this case so we don't have to disable a warning for the entire project, particularly if this is triggered by a small number of macros..

Brian

Quoted 19 lines
 include/builddefs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/builddefs.in +1 -1
index 4700b52706a7..6fdc9ebb70c7 100644
@@ -13,7 +13,7 @@ OPTIMIZER = @opt_build@
 MALLOCLIB = @malloc_lib@
 LOADERFLAGS = @LDFLAGS@
 LTLDFLAGS = @LDFLAGS@
-CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64
+CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member
 BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64
 
 LIBRT = @librt@
Signature · 1 line
2.24.0.rc0
#2 lore raw
Quoted 15 lines · Brian Foster
Quoted 14 lines · Dave Chinner

From: Dave Chinner <[email protected]>

gcc 9.2.1 throws lots of new warnings during the build like this:

xfs_format.h:790:3: warning: taking address of packed member of ‘struct xfs_agfl’ may result in an unaligned pointer value [-Waddress-of-packed-member]

  790 |   &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xfs_alloc.c:3149:13: note: in expansion of macro ‘XFS_BUF_TO_AGFL_BNO’
 3149 |  agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
      |             ^~~~~~~~~~~~~~~~~~~

We know this packed structure aligned correctly, so turn off this warning to shut gcc up.

Quoted 6 lines
Quoted 2 lines

---

I'm wondering if we could just use offsetof() in this case so we don't have to disable a warning for the entire project, particularly if this is triggered by a small number of macros..

...and maybe kill the shouty macro while we're at it. :)

--D

Quoted 22 lines

Brian

Quoted 19 lines
 include/builddefs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/builddefs.in +1 -1
index 4700b52706a7..6fdc9ebb70c7 100644
@@ -13,7 +13,7 @@ OPTIMIZER = @opt_build@
 MALLOCLIB = @malloc_lib@
 LOADERFLAGS = @LDFLAGS@
 LTLDFLAGS = @LDFLAGS@
-CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64
+CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member
 BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64
 
 LIBRT = @librt@
Signature · 1 line
2.24.0.rc0
#4 lore raw
Quoted 2 lines · Christoph Hellwig

Eric, can you pick this one up? The warnings are fairly annoying..

Sorry, I had missed this one and/or the feedback on the original patch wasn't resolved. I tend to agree that turning off the warning globally because we know /this/ one is OK seems somewhat suboptimal.

Let me take a look again.

-Eric

#5 lore raw
Quoted 9 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig

Eric, can you pick this one up? The warnings are fairly annoying..

Sorry, I had missed this one and/or the feedback on the original patch wasn't resolved. I tend to agree that turning off the warning globally because we know /this/ one is OK seems somewhat suboptimal.

Let me take a look again.

Well, the kernel certainly runs with this warning disabled, mostly because it really isn't a very useful warning to start with.

#6 lore raw
In reply to Eric Sandeen
Quoted 9 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig

Eric, can you pick this one up? The warnings are fairly annoying..

Sorry, I had missed this one and/or the feedback on the original patch wasn't resolved. I tend to agree that turning off the warning globally because we know /this/ one is OK seems somewhat suboptimal.

Let me take a look again.

Can we get this queued up in xfsprogs? These warnings are pretty annoying..

#7 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig

Eric, can you pick this one up? The warnings are fairly annoying..

Quoted 8 lines
Quoted 5 lines

Sorry, I had missed this one and/or the feedback on the original patch wasn't resolved. I tend to agree that turning off the warning globally because we know /this/ one is OK seems somewhat suboptimal.

Let me take a look again.

Can we get this queued up in xfsprogs? These warnings are pretty annoying..

Ok. I don't really like disabling it globally but if it's good enough for the kernel... I'll add this to 5.5.0 and push out the release.

-Eric

Reviewed-by on v1 1/1
#12 lore raw
In reply to Dave Chinner
Quoted 11 lines · Dave Chinner

From: Dave Chinner <[email protected]>

gcc 9.2.1 throws lots of new warnings during the build like this:

xfs_format.h:790:3: warning: taking address of packed member of ‘struct xfs_agfl’ may result in an unaligned pointer value [-Waddress-of-packed-member]

  790 |   &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xfs_alloc.c:3149:13: note: in expansion of macro ‘XFS_BUF_TO_AGFL_BNO’
 3149 |  agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
      |             ^~~~~~~~~~~~~~~~~~~
Quoted 4 lines

We know this packed structure aligned correctly, so turn off this warning to shut gcc up.

I guess if it's good enough for the kernel ...

I'll probably add a short note to the commit, and

#8 lore raw
In reply to Eric Sandeen
Quoted 10 lines · Eric Sandeen
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig

Eric, can you pick this one up? The warnings are fairly annoying..

Sorry, I had missed this one and/or the feedback on the original patch wasn't resolved. I tend to agree that turning off the warning globally because we know /this/ one is OK seems somewhat suboptimal.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Let me take a look again.

Can we get this queued up in xfsprogs? These warnings are pretty annoying..

Ok. I don't really like disabling it globally but if it's good enough for the kernel... I'll add this to 5.5.0 and push out the release.

Seems like this still isn't in xfsprogs for-next.

#9 lore raw
Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Eric Sandeen
Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig

Eric, can you pick this one up? The warnings are fairly annoying..

Sorry, I had missed this one and/or the feedback on the original patch wasn't resolved. I tend to agree that turning off the warning globally because we know /this/ one is OK seems somewhat suboptimal.

Let me take a look again.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Can we get this queued up in xfsprogs? These warnings are pretty annoying..

Ok. I don't really like disabling it globally but if it's good enough for the kernel... I'll add this to 5.5.0 and push out the release.

Seems like this still isn't in xfsprogs for-next.

Odd, it's in origin/master in my tree as the last commit before v5.5.0:
845e5ef706cb7e29259d6541f43a7029e7dc7898.

--D

#10 lore raw
Quoted 18 lines · Darrick J. Wong
Quoted 17 lines · Christoph Hellwig
Quoted 16 lines · Eric Sandeen
Quoted 13 lines · Christoph Hellwig
Quoted 9 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig

Eric, can you pick this one up? The warnings are fairly annoying..

Sorry, I had missed this one and/or the feedback on the original patch wasn't resolved. I tend to agree that turning off the warning globally because we know /this/ one is OK seems somewhat suboptimal.

Let me take a look again.

Can we get this queued up in xfsprogs? These warnings are pretty annoying..

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Ok. I don't really like disabling it globally but if it's good enough for the kernel... I'll add this to 5.5.0 and push out the release.

Seems like this still isn't in xfsprogs for-next.

Odd, it's in origin/master in my tree as the last commit before v5.5.0:
845e5ef706cb7e29259d6541f43a7029e7dc7898.

seems like it's in for-next, no?

https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/tree/include/builddefs.in?h=for-next#n16

-Eric