@@ -609,12 +609,9 @@ xfs_agfl_read_verify(
if (!xfs_sb_version_hascrc(&mp->m_sb))
return;
- if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF))
+ if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF) ||
+ !xfs_agfl_verify(vc, bp))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_agfl_verify(vc, bp))
- xfs_verifier_error(bp, vc);
- }
}
static void
@@ -2635,14 +2632,11 @@ xfs_agf_read_verify(
{
struct xfs_mount *mp = bp->b_target->bt_mount;
- if (xfs_sb_version_hascrc(&mp->m_sb) &&
- !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF))
+ if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+ !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF)) ||
+ XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
+ mp, XFS_ERRTAG_ALLOC_READ_AGF))
xfs_verifier_error(bp, vc);
- else {
- if (XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
- mp, XFS_ERRTAG_ALLOC_READ_AGF))
- xfs_verifier_error(bp, vc);
- }
}
static void
@@ -346,12 +346,9 @@ xfs_allocbt_read_verify(
struct xfs_vc *vc,
struct xfs_buf *bp)
{
- if (!xfs_btree_sblock_verify_crc(vc, bp))
+ if (!xfs_btree_sblock_verify_crc(vc, bp) ||
+ !xfs_allocbt_verify(vc, bp))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_allocbt_verify(vc, bp))
- xfs_verifier_error(bp, vc);
- }
if (bp->b_error)
trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -357,13 +357,10 @@ xfs_attr3_leaf_read_verify(
{
struct xfs_mount *mp = bp->b_target->bt_mount;
- if (xfs_sb_version_hascrc(&mp->m_sb) &&
- !xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF))
+ if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+ !xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF)) ||
+ !xfs_attr3_leaf_verify(vc, bp))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_attr3_leaf_verify(vc, bp))
- xfs_verifier_error(bp, vc);
- }
}
const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
@@ -77,13 +77,10 @@ xfs_dir3_block_read_verify(
{
struct xfs_mount *mp = bp->b_target->bt_mount;
- if (xfs_sb_version_hascrc(&mp->m_sb) &&
- !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
+ if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+ !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF)) ||
+ !xfs_dir3_block_verify(vc, bp))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_dir3_block_verify(vc, bp))
- xfs_verifier_error(bp, vc);
- }
}
static void
@@ -304,13 +304,10 @@ xfs_dir3_data_read_verify(
{
struct xfs_mount *mp = bp->b_target->bt_mount;
- if (xfs_sb_version_hascrc(&mp->m_sb) &&
- !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
+ if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+ !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF)) ||
+ !xfs_dir3_data_verify(vc, bp))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_dir3_data_verify(vc, bp))
- xfs_verifier_error(bp, vc);
- }
}
static void
@@ -183,13 +183,10 @@ __read_verify(
{
struct xfs_mount *mp = bp->b_target->bt_mount;
- if (xfs_sb_version_hascrc(&mp->m_sb) &&
- !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF))
+ if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+ !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF)) ||
+ !xfs_dir3_leaf_verify(vc, bp, magic))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_dir3_leaf_verify(vc, bp, magic))
- xfs_verifier_error(bp, vc);
- }
}
static void
@@ -116,13 +116,10 @@ xfs_dir3_free_read_verify(
{
struct xfs_mount *mp = bp->b_target->bt_mount;
- if (xfs_sb_version_hascrc(&mp->m_sb) &&
- !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF))
+ if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+ !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF)) ||
+ !xfs_dir3_free_verify(vc, bp))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_dir3_free_verify(vc, bp))
- xfs_verifier_error(bp, vc);
- }
}
static void
@@ -2555,14 +2555,11 @@ xfs_agi_read_verify(
{
struct xfs_mount *mp = bp->b_target->bt_mount;
- if (xfs_sb_version_hascrc(&mp->m_sb) &&
- !xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF))
+ if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+ !xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF)) ||
+ XFS_TEST_ERROR(!xfs_agi_verify(vc, bp),
+ mp, XFS_ERRTAG_IALLOC_READ_AGI))
xfs_verifier_error(bp, vc);
- else {
- if (XFS_TEST_ERROR(!xfs_agi_verify(vc, bp),
- mp, XFS_ERRTAG_IALLOC_READ_AGI))
- xfs_verifier_error(bp, vc);
- }
}
static void
@@ -124,12 +124,9 @@ xfs_symlink_read_verify(
if (!xfs_sb_version_hascrc(&mp->m_sb))
return;
- if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF))
+ if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF) ||
+ !xfs_symlink_verify(vc, bp))
xfs_verifier_error(bp, vc);
- else {
- if (!xfs_symlink_verify(vc, bp))
- xfs_verifier_error(bp, vc);
- }
}
static void
Now that failaddr and errno are set within the validating functions, the if/else is unnecessary and we can do a compound test of crc || validated, i.e. if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF) || !xfs_agfl_verify(vc, bp)) xfs_verifier_error(bp, vc); This condenses the code a bit and makes it a little nicer. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- fs/xfs/libxfs/xfs_alloc.c | 18 ++++++------------ fs/xfs/libxfs/xfs_alloc_btree.c | 7 ++----- fs/xfs/libxfs/xfs_attr_leaf.c | 9 +++------ fs/xfs/libxfs/xfs_dir2_block.c | 9 +++------ fs/xfs/libxfs/xfs_dir2_data.c | 9 +++------ fs/xfs/libxfs/xfs_dir2_leaf.c | 9 +++------ fs/xfs/libxfs/xfs_dir2_node.c | 9 +++------ fs/xfs/libxfs/xfs_ialloc.c | 11 ++++------- fs/xfs/libxfs/xfs_symlink_remote.c | 7 ++----- 9 files changed, 29 insertions(+), 59 deletions(-)