Re: [PATCH] xfsprogs: don't warn about packed members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 17, 2019 at 08:52:45AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@xxxxxxxxxx>
> 
> 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.
> 
> Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
> ---

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

>  include/builddefs.in | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/builddefs.in b/include/builddefs.in
> index 4700b52706a7..6fdc9ebb70c7 100644
> --- a/include/builddefs.in
> +++ b/include/builddefs.in
> @@ -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@
> -- 
> 2.24.0.rc0
> 





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux