xfs: avoid harmless gcc-7 warnings
PATCH 1/1 xfs: avoid harmless gcc-7 warnings
gcc-7 flags the use of integer math inside of a condition as a potential bug:
fs/xfs/xfs_bmap_util.c: In function 'xfs_swap_extents_check_format':fs/xfs/xfs_bmap_util.c:1619:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context] fs/xfs/xfs_bmap_util.c:1629:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]
This one is clearly fine, and we can add a comparison to zero to shut up the warning.
--- fs/xfs/xfs_bmap_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_bmap_util.c +2 -2
@@ -1613,7 +1613,7 @@ xfs_swap_extents_check_format(* extent format... */ if (tip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) { -if (XFS_IFORK_BOFF (ip) && +if ((XFS_IFORK_BOFF (ip) !=0 ) &&XFS_BMAP_BMDR_SPACE (tip->i_df.if_broot) >XFS_IFORK_BOFF (ip))return -EINVAL ; if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=
@@ -1623,7 +1623,7 @@ xfs_swap_extents_check_format(/* Reciprocal target->temp btree format checks */ if (ip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) { -if (XFS_IFORK_BOFF (tip) && +if ((XFS_IFORK_BOFF (tip) !=0 ) &&XFS_BMAP_BMDR_SPACE (ip->i_df.if_broot) >XFS_IFORK_BOFF (tip))return -EINVAL ; if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
Signature · 1 line
2.9.0
Quoted 11 lines · Arnd Bergmann
gcc-7 flags the use of integer math inside of a condition as a potential bug:
fs/xfs/xfs_bmap_util.c: In function 'xfs_swap_extents_check_format':fs/xfs/xfs_bmap_util.c:1619:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]fs/xfs/xfs_bmap_util.c:1629:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]This one is clearly fine, and we can add a comparison to zero to shut up the warning.
Signed-off-by Arnd Bergmann <[email protected]>
Thanks Arnd -
Quoted 27 lines
--- fs/xfs/xfs_bmap_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/xfs/xfs_bmap_util.c +2
-2@@ -1613,7 +1613,7 @@ xfs_swap_extents_check_format(* extent format... */ if (tip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) { -if (XFS_IFORK_BOFF (ip) && +if ((XFS_IFORK_BOFF (ip) !=0 ) &&XFS_BMAP_BMDR_SPACE (tip->i_df.if_broot) >XFS_IFORK_BOFF (ip))return -EINVAL ; if (XFS_IFORK_NEXTENTS(tip, XFS_DATA_FORK) <=@@ -1623,7 +1623,7 @@ xfs_swap_extents_check_format(/* Reciprocal target->temp btree format checks */ if (ip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) { -if (XFS_IFORK_BOFF (tip) && +if ((XFS_IFORK_BOFF (tip) !=0 ) &&XFS_BMAP_BMDR_SPACE (ip->i_df.if_broot) >XFS_IFORK_BOFF (tip))return -EINVAL ; if (XFS_IFORK_NEXTENTS(ip, XFS_DATA_FORK) <=
Quoted 20 lines · Arnd Bergmann
gcc-7 flags the use of integer math inside of a condition as a potential bug:
fs/xfs/xfs_bmap_util.c: In function 'xfs_swap_extents_check_format':fs/xfs/xfs_bmap_util.c:1619:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]fs/xfs/xfs_bmap_util.c:1629:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]This one is clearly fine, and we can add a comparison to zero to shut up the warning.
Signed-off-by Arnd Bergmann <[email protected]>--- fs/xfs/xfs_bmap_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/xfs/xfs_bmap_util.c +0
-0
fs/xfs/xfs_bmap_util.c xfs_swap_extents_check_format( · line 1616
Quoted 5 lines
fs/xfs/xfs_bmap_util.c +1
-1@@ -1613,7 +1613,7 @@ xfs_swap_extents_check_format(* extent format... */ if (tip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) { - if (XFS_IFORK_BOFF(ip) && + if ((XFS_IFORK_BOFF(ip) != 0) &&
Even if we were fine with fixing this odd warning the additional braces are simply bogus.
Quoted 16 lines · Christoph Hellwig
Quoted 15 lines · Arnd Bergmann
gcc-7 flags the use of integer math inside of a condition as a potential bug:
fs/xfs/xfs_bmap_util.c: In function 'xfs_swap_extents_check_format':fs/xfs/xfs_bmap_util.c:1619:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]fs/xfs/xfs_bmap_util.c:1629:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]This one is clearly fine, and we can add a comparison to zero to shut up the warning.
Signed-off-by Arnd Bergmann <[email protected]>--- fs/xfs/xfs_bmap_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines
fs/xfs/xfs_bmap_util.c xfs_swap_extents_check_format( · line 1616
Quoted 10 lines
fs/xfs/xfs_bmap_util.c +1
-1@@ -1613,7 +1613,7 @@ xfs_swap_extents_check_format(* extent format... */ if (tip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) { - if (XFS_IFORK_BOFF(ip) && + if ((XFS_IFORK_BOFF(ip) != 0) &&Even if we were fine with fixing this odd warning the additional braces are simply bogus.
The warning seems generally useful and is enabled by default in gcc-7. An example of a real bug it found is
https://patchwork.kernel.org/patch/9431813/, so I'd prefer to leave it enabled and fix the few instances in the kernel.
I found a better way to rework the code to avoid the warning, sending out v2 now.
Arnd
Quoted 9 lines · Arnd Bergmann
gcc-7 flags the use of integer math inside of a condition as a potential bug:
fs/xfs/xfs_bmap_util.c: In function 'xfs_swap_extents_check_format':fs/xfs/xfs_bmap_util.c:1619:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]fs/xfs/xfs_bmap_util.c:1629:8: error: '<<' in boolean context, did you mean '<' ? [-Werror=int-in-bool-context]This one is clearly fine, and we can add a comparison to zero to shut up the warning.
[]
fs/xfs/xfs_bmap_util.c
Quoted 1 line
fs/xfs/xfs_bmap_util.c +0
-0
[]
fs/xfs/xfs_bmap_util.c xfs_swap_extents_check_format( · line 1616
Quoted 6 lines
fs/xfs/xfs_bmap_util.c +1
-1@@ -1613,7 +1613,7 @@ xfs_swap_extents_check_format(* extent format... */ if (tip->i_d.di_format ==XFS_DINODE_FMT_BTREE ) { - if (XFS_IFORK_BOFF(ip) && + if ((XFS_IFORK_BOFF(ip) != 0) &&
As far as I can tell, this suggestion makes no sense.
$ git grep -E "define\s+XFS_IFORK_BOFF" fs/xfs/libxfs/xfs_inode_fork.h:#define XFS_IFORK_BOFF(ip) ((int)((ip)->i_d.di_forkoff << 3))
$ git grep -w di_forkoff|grep -P "\w+\s+di_forkoff\s*;" fs/xfs/libxfs/xfs_format.h: __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */ fs/xfs/libxfs/xfs_inode_buf.h: __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */ fs/xfs/libxfs/xfs_log_format.h: __uint8_t di_forkoff; /* attr fork offs, <<3 for 64b align */