mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
xfs: kill the XFS_WANT_CORRUPT_* macros
The XFS_WANT_CORRUPT_* macros conceal subtle side effects such as the creation of local variables and redirections of the code flow. This is pretty ugly, so replace them with explicit XFS_IS_CORRUPT tests that remove both of those ugly points. The change was performed with the following coccinelle script: @@ expression mp, test; identifier label; @@ - XFS_WANT_CORRUPTED_GOTO(mp, test, label); + if (XFS_IS_CORRUPT(mp, !test)) { error = -EFSCORRUPTED; goto label; } @@ expression mp, test; @@ - XFS_WANT_CORRUPTED_RETURN(mp, test); + if (XFS_IS_CORRUPT(mp, !test)) return -EFSCORRUPTED; @@ expression mp, lval, rval; @@ - XFS_IS_CORRUPT(mp, !(lval == rval)) + XFS_IS_CORRUPT(mp, lval != rval) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 && e2)) + XFS_IS_CORRUPT(mp, !e1 || !e2) @@ expression e1, e2; @@ - !(e1 == e2) + e1 != e2 @@ expression e1, e2, e3, e4, e5, e6; @@ - !(e1 == e2 && e3 == e4) || e5 != e6 + e1 != e2 || e3 != e4 || e5 != e6 @@ expression e1, e2, e3, e4, e5, e6; @@ - !(e1 == e2 || (e3 <= e4 && e5 <= e6)) + e1 != e2 && (e3 > e4 || e5 > e6) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 <= e2)) + XFS_IS_CORRUPT(mp, e1 > e2) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 < e2)) + XFS_IS_CORRUPT(mp, e1 >= e2) @@ expression mp, e1; @@ - XFS_IS_CORRUPT(mp, !!e1) + XFS_IS_CORRUPT(mp, e1) @@ expression mp, e1, e2; @@ - XFS_IS_CORRUPT(mp, !(e1 || e2)) + XFS_IS_CORRUPT(mp, !e1 && !e2) @@ expression mp, e1, e2, e3, e4; @@ - XFS_IS_CORRUPT(mp, !(e1 == e2) && !(e3 == e4)) + XFS_IS_CORRUPT(mp, e1 != e2 && e3 != e4) @@ expression mp, e1, e2, e3, e4; @@ - XFS_IS_CORRUPT(mp, !(e1 <= e2) || !(e3 >= e4)) + XFS_IS_CORRUPT(mp, e1 > e2 || e3 < e4) @@ expression mp, e1, e2, e3, e4; @@ - XFS_IS_CORRUPT(mp, !(e1 == e2) && !(e3 <= e4)) + XFS_IS_CORRUPT(mp, e1 != e2 && e3 > e4) Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
1ec28615d2
commit
f9e0370648
9 changed files with 956 additions and 329 deletions
|
@ -1971,7 +1971,8 @@ xfs_btree_lookup(
|
|||
error = xfs_btree_increment(cur, 0, &i);
|
||||
if (error)
|
||||
goto error0;
|
||||
XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1))
|
||||
return -EFSCORRUPTED;
|
||||
*stat = 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2426,7 +2427,10 @@ xfs_btree_lshift(
|
|||
if (error)
|
||||
goto error0;
|
||||
i = xfs_btree_firstrec(tcur, level);
|
||||
XFS_WANT_CORRUPTED_GOTO(tcur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
error = xfs_btree_decrement(tcur, level, &i);
|
||||
if (error)
|
||||
|
@ -2593,7 +2597,10 @@ xfs_btree_rshift(
|
|||
if (error)
|
||||
goto error0;
|
||||
i = xfs_btree_lastrec(tcur, level);
|
||||
XFS_WANT_CORRUPTED_GOTO(tcur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(tcur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
error = xfs_btree_increment(tcur, level, &i);
|
||||
if (error)
|
||||
|
@ -3447,7 +3454,10 @@ xfs_btree_insert(
|
|||
goto error0;
|
||||
}
|
||||
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
level++;
|
||||
|
||||
/*
|
||||
|
@ -3851,15 +3861,24 @@ xfs_btree_delrec(
|
|||
* Actually any entry but the first would suffice.
|
||||
*/
|
||||
i = xfs_btree_lastrec(tcur, level);
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
error = xfs_btree_increment(tcur, level, &i);
|
||||
if (error)
|
||||
goto error0;
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
i = xfs_btree_lastrec(tcur, level);
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
/* Grab a pointer to the block. */
|
||||
right = xfs_btree_get_block(tcur, level, &rbp);
|
||||
|
@ -3903,12 +3922,18 @@ xfs_btree_delrec(
|
|||
rrecs = xfs_btree_get_numrecs(right);
|
||||
if (!xfs_btree_ptr_is_null(cur, &lptr)) {
|
||||
i = xfs_btree_firstrec(tcur, level);
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
error = xfs_btree_decrement(tcur, level, &i);
|
||||
if (error)
|
||||
goto error0;
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3922,13 +3947,19 @@ xfs_btree_delrec(
|
|||
* previous block.
|
||||
*/
|
||||
i = xfs_btree_firstrec(tcur, level);
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
error = xfs_btree_decrement(tcur, level, &i);
|
||||
if (error)
|
||||
goto error0;
|
||||
i = xfs_btree_firstrec(tcur, level);
|
||||
XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0);
|
||||
if (XFS_IS_CORRUPT(cur->bc_mp, i != 1)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto error0;
|
||||
}
|
||||
|
||||
/* Grab a pointer to the block. */
|
||||
left = xfs_btree_get_block(tcur, level, &lbp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue