xfs: ASSERT should always evaluate its parameter
PATCH 1/1 xfs: ASSERT should always evaluate its parameter
Ensure that ASSERT evalulates its expression argument so that we don't get a ton of compiler warnings in non-warn non-debug mode. Fix up everything that breaks as a result.
Signed-off-by Darrick J. Wong <[email protected]>
--- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 -- fs/xfs/xfs_inode.c | 8 ++++++++ fs/xfs/xfs_linux.h | 3 ++- fs/xfs/xfs_trans.c | 2 ++ 5 files changed, 13 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +1 -1
@@ -579,7 +579,7 @@ xfs_bmap_validate_ret(#else #define xfs_bmap_check_leaf_extents (cur, ip, whichfork) do { } while (0) -#define xfs_bmap_validate_ret (bno,len,flags,mval,onmap,nmap) +#define xfs_bmap_validate_ret (bno,len,flags,mval,onmap,nmap) ((void)0)#endif /* DEBUG */ /*
fs/xfs/libxfs/xfs_dir2_node.c +0 -2
@@ -1005,9 +1005,7 @@ xfs_dir2_leafn_rebalance(xfs_dir2_leaf_t *leaf1;/* first leaf structure */ xfs_dir2_leaf_t *leaf2;/* second leaf structure */ int mid;/* midpoint leaf index */ -#if defined(DEBUG ) || defined(XFS_WARN )int oldstale;/* old count of stale leaves */ -#endif int oldsum;/* old total leaf count */ int swap;/* swapped leaf blocks */ struct xfs_dir2_leaf_entry *ents1;
fs/xfs/xfs_inode.c +8 -0
@@ -382,6 +382,14 @@ xfs_isilocked(ASSERT (0 ); return 0; } +#else +int +xfs_isilocked ( +xfs_inode_t *ip, +uint lock_flags) +{ +return 0 ; +}#endif #ifdef DEBUG
fs/xfs/xfs_linux.h +2 -1
@@ -260,7 +260,8 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)#else /* !DEBUG && !XFS_WARN */ -#define ASSERT (expr) ((void)0) +#define ASSERT (expr) \ + (likely(expr) ? (void)0 : (void)0)#ifndef STATIC # define STATIC static noinline
fs/xfs/xfs_trans.c +2 -0
@@ -421,9 +421,11 @@ xfs_trans_apply_sb_deltas(/* * Check that superblock mods match the mods made to AGF counters. */ +#if defined(DEBUG ) || defined(XFS_WARN )ASSERT ((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + tp->t_ag_btree_delta)); +#endif /* * Only update the superblock counters if we are logging them
Quoted 46 lines · Darrick J. Wong
Ensure that ASSERT evalulates its expression argument so that we don't get a ton of compiler warnings in non-warn non-debug mode. Fix up everything that breaks as a result.
Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_dir2_node.c | 2 -- fs/xfs/xfs_inode.c | 8 ++++++++ fs/xfs/xfs_linux.h | 3 ++- fs/xfs/xfs_trans.c | 2 ++ 5 files changed, 13 insertions(+), 4 deletions(-)fs/xfs/libxfs/xfs_bmap.c +1
-1@@ -579,7 +579,7 @@ xfs_bmap_validate_ret(#else #define xfs_bmap_check_leaf_extents (cur, ip, whichfork) do { } while (0) -#define xfs_bmap_validate_ret (bno,len,flags,mval,onmap,nmap) +#define xfs_bmap_validate_ret (bno,len,flags,mval,onmap,nmap) ((void)0)#endif /* DEBUG */ /* fs/xfs/libxfs/xfs_dir2_node.c +0
-2@@ -1005,9 +1005,7 @@ xfs_dir2_leafn_rebalance(xfs_dir2_leaf_t *leaf1;/* first leaf structure */ xfs_dir2_leaf_t *leaf2;/* second leaf structure */ int mid;/* midpoint leaf index */ -#if defined(DEBUG ) || defined(XFS_WARN )int oldstale;/* old count of stale leaves */ -#endif int oldsum;/* old total leaf count */ int swap;/* swapped leaf blocks */ struct xfs_dir2_leaf_entry *ents1;fs/xfs/xfs_inode.c +0
-0@@ -382,6 +382,14 @@ xfs_isilocked(ASSERT (0 );
fs/xfs/xfs_inode.c xfs_isilocked( · line 392
Quoted 10 lines
fs/xfs/xfs_inode.c +8
-0return 0; } +#else +int +xfs_isilocked ( +xfs_inode_t *ip, +uint lock_flags) +{ +return 0 ; +}
Bah, this doesn't work, never mind. Kill this whole patch.
/me goes back for another cup of coffee.
--D
Quoted 37 lines
fs/xfs/xfs_inode.c +0
-0#endif #ifdef DEBUG fs/xfs/xfs_linux.h +2
-1@@ -260,7 +260,8 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)#else /* !DEBUG && !XFS_WARN */ -#define ASSERT (expr) ((void)0) +#define ASSERT (expr) \ + (likely(expr) ? (void)0 : (void)0)#ifndef STATIC # define STATIC static noinlinefs/xfs/xfs_trans.c +2
-1@@ -421,9 +421,11 @@ xfs_trans_apply_sb_deltas(/* * Check that superblock mods match the mods made to AGF counters. */ +#if defined(DEBUG ) || defined(XFS_WARN )ASSERT ((tp->t_fdblocks_delta + tp->t_res_fdblocks_delta) == (tp->t_ag_freeblks_delta + tp->t_ag_flist_delta + tp->t_ag_btree_delta)); +#endif /* * Only update the superblock counters if we are logging them -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html