[PATCH 20/33] xfs: remove the expr argument to XFS_TEST_ERROR

Andrey Albershteyn
2025-12-03T19:09:21Z

From: Christoph Hellwig <hch@lst.de>

Source kernel commit: 807df3227d7674d7957c576551d552acf15bb96f

Don't pass expr to XFS_TEST_ERROR. Most calls pass a constant false,
and the places that do pass an expression become cleaner by moving it
out.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
[aalbersh: remove argument from a macro and fix call in defer_item.c]
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
libxfs/defer_item.c | 2 +-
libxfs/libxfs_priv.h | 2 +-
libxfs/xfs_ag_resv.c | 7 +++----
libxfs/xfs_alloc.c | 5 ++---
libxfs/xfs_attr_leaf.c | 2 +-
libxfs/xfs_bmap.c | 17 ++++++++---------
libxfs/xfs_btree.c | 2 +-
libxfs/xfs_da_btree.c | 2 +-
libxfs/xfs_dir2.c | 2 +-
libxfs/xfs_exchmaps.c | 4 ++--
libxfs/xfs_ialloc.c | 2 +-
libxfs/xfs_inode_buf.c | 4 ++--
libxfs/xfs_inode_fork.c | 3 +--
libxfs/xfs_metafile.c | 2 +-
libxfs/xfs_refcount.c | 7 +++----
libxfs/xfs_rmap.c | 2 +-
libxfs/xfs_rtbitmap.c | 2 +-
17 files changed, 31 insertions(+), 36 deletions(-)

diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c
index 4530583dda..3dc938d514 100644
--- a/libxfs/defer_item.c
+++ b/libxfs/defer_item.c
@@ -754,7 +754,7 @@
*/
args->trans = tp;

- if (XFS_TEST_ERROR(false, args->dp->i_mount, XFS_ERRTAG_LARP)) {
+ if (XFS_TEST_ERROR(args->dp->i_mount, XFS_ERRTAG_LARP)) {
error = -EIO;
goto out;
}
diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
index 48a84a1089..5474865a67 100644
--- a/libxfs/libxfs_priv.h
+++ b/libxfs/libxfs_priv.h
@@ -185,7 +185,7 @@
#define XFS_STATS_INC(mp, count) do { (mp) = (mp); } while (0)
#define XFS_STATS_DEC(mp, count, x) do { (mp) = (mp); } while (0)
#define XFS_STATS_ADD(mp, count, x) do { (mp) = (mp); } while (0)
-#define XFS_TEST_ERROR(expr,a,b) ( expr )
+#define XFS_TEST_ERROR(a,b) (false)

#define __section(section) __attribute__((__section__(section)))

diff --git a/libxfs/xfs_ag_resv.c b/libxfs/xfs_ag_resv.c
index 83cac20331..842e797b2f 100644
--- a/libxfs/xfs_ag_resv.c
+++ b/libxfs/xfs_ag_resv.c
@@ -91,9 +91,8 @@
trace_xfs_ag_resv_critical(pag, type, avail);

/* Critically low if less than 10% or max btree height remains. */
- return XFS_TEST_ERROR(avail < orig / 10 ||
- avail < mp->m_agbtree_maxlevels,
- mp, XFS_ERRTAG_AG_RESV_CRITICAL);
+ return avail < orig / 10 || avail < mp->m_agbtree_maxlevels ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_CRITICAL);
}

/*
@@ -202,7 +201,7 @@
return -EINVAL;
}

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_AG_RESV_FAIL))
error = -ENOSPC;
else
error = xfs_dec_fdblocks(mp, hidden_space, true);
diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
index a9fb29ea99..311f5342d6 100644
--- a/libxfs/xfs_alloc.c
+++ b/libxfs/xfs_alloc.c
@@ -3317,7 +3317,7 @@
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_agf_verify(bp);
- if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
+ if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_ALLOC_READ_AGF))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
}
@@ -4015,8 +4015,7 @@
ASSERT(len != 0);
ASSERT(type != XFS_AG_RESV_AGFL);

- if (XFS_TEST_ERROR(false, mp,
- XFS_ERRTAG_FREE_EXTENT))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
return -EIO;

error = xfs_free_extent_fix_freelist(tp, pag, &agbp);
diff --git a/libxfs/xfs_attr_leaf.c b/libxfs/xfs_attr_leaf.c
index cfb8d40e51..29e9a419d0 100644
--- a/libxfs/xfs_attr_leaf.c
+++ b/libxfs/xfs_attr_leaf.c
@@ -1209,7 +1209,7 @@

trace_xfs_attr_leaf_to_node(args);

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_ATTR_LEAF_TO_NODE)) {
error = -EIO;
goto out;
}
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index e6a1922abb..f2f616e521 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -3648,8 +3648,7 @@
/* Trim the allocation back to the maximum an AG can fit. */
args.maxlen = min(ap->length, mp->m_ag_max_usable);

- if (unlikely(XFS_TEST_ERROR(false, mp,
- XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
+ if (unlikely(XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT)))
error = xfs_bmap_exact_minlen_extent_alloc(ap, &args);
else if ((ap->datatype & XFS_ALLOC_USERDATA) &&
xfs_inode_is_filestream(ap->ip))
@@ -3835,7 +3834,7 @@
}

if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -4186,7 +4185,7 @@
(XFS_BMAPI_PREALLOC | XFS_BMAPI_ZERO));

if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -4531,7 +4530,7 @@
(XFS_BMAPI_ATTRFORK | XFS_BMAPI_PREALLOC));

if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5665,7 +5664,7 @@
int logflags = 0;

if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5781,7 +5780,7 @@
int logflags = 0;

if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -5886,7 +5885,7 @@
int i = 0;

if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ifp)) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_BMAPIFORMAT)) {
xfs_bmap_mark_sick(ip, whichfork);
return -EFSCORRUPTED;
}
@@ -6051,7 +6050,7 @@

trace_xfs_bmap_deferred(bi);

- if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
+ if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_BMAP_FINISH_ONE))
return -EIO;

switch (bi->bi_type) {
diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index 8576611994..1404d86fb9 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -303,7 +303,7 @@

fa = __xfs_btree_check_block(cur, block, level, bp);
if (XFS_IS_CORRUPT(mp, fa != NULL) ||
- XFS_TEST_ERROR(false, mp, xfs_btree_block_errtag(cur))) {
+ XFS_TEST_ERROR(mp, xfs_btree_block_errtag(cur))) {
if (bp)
trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_btree_mark_sick(cur);
diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c
index af3fcdf5e4..37be99bd54 100644
--- a/libxfs/xfs_da_btree.c
+++ b/libxfs/xfs_da_btree.c
@@ -561,7 +561,7 @@

trace_xfs_da_split(state->args);

- if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
+ if (XFS_TEST_ERROR(state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
return -EIO;

/*
diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c
index 1285019b67..d5f2e516e5 100644
--- a/libxfs/xfs_dir2.c
+++ b/libxfs/xfs_dir2.c
@@ -222,7 +222,7 @@
bool ino_ok = xfs_verify_dir_ino(mp, ino);

if (XFS_IS_CORRUPT(mp, !ino_ok) ||
- XFS_TEST_ERROR(false, mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_DIR_INO_VALIDATE)) {
xfs_warn(mp, "Invalid inode number 0x%Lx",
(unsigned long long) ino);
return -EFSCORRUPTED;
diff --git a/libxfs/xfs_exchmaps.c b/libxfs/xfs_exchmaps.c
index 2d75135494..8e39324d42 100644
--- a/libxfs/xfs_exchmaps.c
+++ b/libxfs/xfs_exchmaps.c
@@ -613,7 +613,7 @@
return error;
}

- if (XFS_TEST_ERROR(false, tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
+ if (XFS_TEST_ERROR(tp->t_mountp, XFS_ERRTAG_EXCHMAPS_FINISH_ONE))
return -EIO;

/* If we still have work to do, ask for a new transaction. */
@@ -879,7 +879,7 @@
&new_nextents))
return -EFBIG;

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
new_nextents > 10)
return -EFBIG;

diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 0efad4cfda..9f4ec7bbc0 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -2701,7 +2701,7 @@
xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else {
fa = xfs_agi_verify(bp);
- if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
+ if (fa || XFS_TEST_ERROR(mp, XFS_ERRTAG_IALLOC_READ_AGI))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
}
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 4eca3d6dd6..e2c87ca03c 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -58,8 +58,8 @@
di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
xfs_dinode_good_version(mp, dip->di_version) &&
xfs_verify_agino_or_null(bp->b_pag, unlinked_ino);
- if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
- XFS_ERRTAG_ITOBP_INOTOBP))) {
+ if (unlikely(!di_ok ||
+ XFS_TEST_ERROR(mp, XFS_ERRTAG_ITOBP_INOTOBP))) {
if (readahead) {
bp->b_flags &= ~XBF_DONE;
xfs_buf_ioerror(bp, -EIO);
diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c
index 52740e8e88..329d52cc52 100644
--- a/libxfs/xfs_inode_fork.c
+++ b/libxfs/xfs_inode_fork.c
@@ -754,8 +754,7 @@
if (nr_exts < ifp->if_nextents)
return -EFBIG;

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) &&
- nr_exts > 10)
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REDUCE_MAX_IEXTENTS) && nr_exts > 10)
return -EFBIG;

if (nr_exts > xfs_iext_max_nextents(has_large, whichfork)) {
diff --git a/libxfs/xfs_metafile.c b/libxfs/xfs_metafile.c
index 6ded87d09a..9c3751f581 100644
--- a/libxfs/xfs_metafile.c
+++ b/libxfs/xfs_metafile.c
@@ -119,7 +119,7 @@
div_u64(mp->m_metafile_resv_target, 10)))
return true;

- return XFS_TEST_ERROR(false, mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
+ return XFS_TEST_ERROR(mp, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
}

/* Allocate a block from the metadata file's reservation. */
diff --git a/libxfs/xfs_refcount.c b/libxfs/xfs_refcount.c
index 4d31c3379d..f9714acd9a 100644
--- a/libxfs/xfs_refcount.c
+++ b/libxfs/xfs_refcount.c
@@ -1111,8 +1111,7 @@
* refcount continue update "error" has been injected.
*/
if (cur->bc_refc.nr_ops > 2 &&
- XFS_TEST_ERROR(false, cur->bc_mp,
- XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
+ XFS_TEST_ERROR(cur->bc_mp, XFS_ERRTAG_REFCOUNT_CONTINUE_UPDATE))
return false;

if (cur->bc_refc.nr_ops == 0)
@@ -1396,7 +1395,7 @@

trace_xfs_refcount_deferred(mp, ri);

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
return -EIO;

/*
@@ -1509,7 +1508,7 @@

trace_xfs_refcount_deferred(mp, ri);

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
return -EIO;

/*
diff --git a/libxfs/xfs_rmap.c b/libxfs/xfs_rmap.c
index 8c0c22a349..33e856875d 100644
--- a/libxfs/xfs_rmap.c
+++ b/libxfs/xfs_rmap.c
@@ -2689,7 +2689,7 @@

trace_xfs_rmap_deferred(mp, ri);

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_RMAP_FINISH_ONE))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_RMAP_FINISH_ONE))
return -EIO;

/*
diff --git a/libxfs/xfs_rtbitmap.c b/libxfs/xfs_rtbitmap.c
index 34425a9336..354ebb8d06 100644
--- a/libxfs/xfs_rtbitmap.c
+++ b/libxfs/xfs_rtbitmap.c
@@ -1062,7 +1062,7 @@
ASSERT(rbmip->i_itemp != NULL);
xfs_assert_ilocked(rbmip, XFS_ILOCK_EXCL);

- if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_FREE_EXTENT))
+ if (XFS_TEST_ERROR(mp, XFS_ERRTAG_FREE_EXTENT))
return -EIO;

error = xfs_rtcheck_alloc_range(&args, start, len);

--
- Andrey