Commit 2e984bad authored by Joseph Qi's avatar Joseph Qi Committed by Darrick J. Wong

xfs: remove unneeded return value check for *init_cursor()

Since *init_cursor() can always return a valid cursor, the NULL check
in caller is unneeded. So clean them up.
This also keeps the behavior consistent with other callers.
Signed-off-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 7bc1fea9
...@@ -639,8 +639,6 @@ xfs_bmbt_change_owner( ...@@ -639,8 +639,6 @@ xfs_bmbt_change_owner(
ASSERT(XFS_IFORK_PTR(ip, whichfork)->if_format == XFS_DINODE_FMT_BTREE); ASSERT(XFS_IFORK_PTR(ip, whichfork)->if_format == XFS_DINODE_FMT_BTREE);
cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork); cur = xfs_bmbt_init_cursor(ip->i_mount, tp, ip, whichfork);
if (!cur)
return -ENOMEM;
cur->bc_ino.flags |= XFS_BTCUR_BMBT_INVALID_OWNER; cur->bc_ino.flags |= XFS_BTCUR_BMBT_INVALID_OWNER;
error = xfs_btree_change_owner(cur, new_owner, buffer_list); error = xfs_btree_change_owner(cur, new_owner, buffer_list);
......
...@@ -672,11 +672,6 @@ xfs_inobt_cur( ...@@ -672,11 +672,6 @@ xfs_inobt_cur(
return error; return error;
cur = xfs_inobt_init_cursor(mp, tp, *agi_bpp, agno, which); cur = xfs_inobt_init_cursor(mp, tp, *agi_bpp, agno, which);
if (!cur) {
xfs_trans_brelse(tp, *agi_bpp);
*agi_bpp = NULL;
return -ENOMEM;
}
*curpp = cur; *curpp = cur;
return 0; return 0;
} }
......
...@@ -1179,10 +1179,6 @@ xfs_refcount_finish_one( ...@@ -1179,10 +1179,6 @@ xfs_refcount_finish_one(
return error; return error;
rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno); rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno);
if (!rcur) {
error = -ENOMEM;
goto out_cur;
}
rcur->bc_ag.refc.nr_ops = nr_ops; rcur->bc_ag.refc.nr_ops = nr_ops;
rcur->bc_ag.refc.shape_changes = shape_changes; rcur->bc_ag.refc.shape_changes = shape_changes;
} }
...@@ -1217,11 +1213,6 @@ xfs_refcount_finish_one( ...@@ -1217,11 +1213,6 @@ xfs_refcount_finish_one(
trace_xfs_refcount_finish_one_leftover(mp, agno, type, trace_xfs_refcount_finish_one_leftover(mp, agno, type,
bno, blockcount, new_agbno, *new_len); bno, blockcount, new_agbno, *new_len);
return error; return error;
out_cur:
xfs_trans_brelse(tp, agbp);
return error;
} }
/* /*
......
...@@ -2404,10 +2404,6 @@ xfs_rmap_finish_one( ...@@ -2404,10 +2404,6 @@ xfs_rmap_finish_one(
return -EFSCORRUPTED; return -EFSCORRUPTED;
rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno); rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno);
if (!rcur) {
error = -ENOMEM;
goto out_cur;
}
} }
*pcur = rcur; *pcur = rcur;
...@@ -2446,11 +2442,6 @@ xfs_rmap_finish_one( ...@@ -2446,11 +2442,6 @@ xfs_rmap_finish_one(
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
} }
return error; return error;
out_cur:
xfs_trans_brelse(tp, agbp);
return error;
} }
/* /*
......
...@@ -829,8 +829,6 @@ xrep_agi_calc_from_btrees( ...@@ -829,8 +829,6 @@ xrep_agi_calc_from_btrees(
cur = xfs_inobt_init_cursor(mp, sc->tp, agi_bp, sc->sa.agno, cur = xfs_inobt_init_cursor(mp, sc->tp, agi_bp, sc->sa.agno,
XFS_BTNUM_FINO); XFS_BTNUM_FINO);
if (error)
goto err;
error = xfs_btree_count_blocks(cur, &blocks); error = xfs_btree_count_blocks(cur, &blocks);
if (error) if (error)
goto err; goto err;
......
...@@ -558,10 +558,6 @@ xchk_bmap_check_ag_rmaps( ...@@ -558,10 +558,6 @@ xchk_bmap_check_ag_rmaps(
return error; return error;
cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf, agno); cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, agf, agno);
if (!cur) {
error = -ENOMEM;
goto out_agf;
}
sbcri.sc = sc; sbcri.sc = sc;
sbcri.whichfork = whichfork; sbcri.whichfork = whichfork;
...@@ -570,7 +566,6 @@ xchk_bmap_check_ag_rmaps( ...@@ -570,7 +566,6 @@ xchk_bmap_check_ag_rmaps(
error = 0; error = 0;
xfs_btree_del_cursor(cur, error); xfs_btree_del_cursor(cur, error);
out_agf:
xfs_trans_brelse(sc->tp, agf); xfs_trans_brelse(sc->tp, agf);
return error; return error;
} }
......
...@@ -466,8 +466,6 @@ xchk_ag_btcur_init( ...@@ -466,8 +466,6 @@ xchk_ag_btcur_init(
/* Set up a bnobt cursor for cross-referencing. */ /* Set up a bnobt cursor for cross-referencing. */
sa->bno_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp, sa->bno_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp,
agno, XFS_BTNUM_BNO); agno, XFS_BTNUM_BNO);
if (!sa->bno_cur)
goto err;
} }
if (sa->agf_bp && if (sa->agf_bp &&
...@@ -475,8 +473,6 @@ xchk_ag_btcur_init( ...@@ -475,8 +473,6 @@ xchk_ag_btcur_init(
/* Set up a cntbt cursor for cross-referencing. */ /* Set up a cntbt cursor for cross-referencing. */
sa->cnt_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp, sa->cnt_cur = xfs_allocbt_init_cursor(mp, sc->tp, sa->agf_bp,
agno, XFS_BTNUM_CNT); agno, XFS_BTNUM_CNT);
if (!sa->cnt_cur)
goto err;
} }
/* Set up a inobt cursor for cross-referencing. */ /* Set up a inobt cursor for cross-referencing. */
...@@ -484,8 +480,6 @@ xchk_ag_btcur_init( ...@@ -484,8 +480,6 @@ xchk_ag_btcur_init(
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_INO)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_INO)) {
sa->ino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp, sa->ino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp,
agno, XFS_BTNUM_INO); agno, XFS_BTNUM_INO);
if (!sa->ino_cur)
goto err;
} }
/* Set up a finobt cursor for cross-referencing. */ /* Set up a finobt cursor for cross-referencing. */
...@@ -493,8 +487,6 @@ xchk_ag_btcur_init( ...@@ -493,8 +487,6 @@ xchk_ag_btcur_init(
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_FINO)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_FINO)) {
sa->fino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp, sa->fino_cur = xfs_inobt_init_cursor(mp, sc->tp, sa->agi_bp,
agno, XFS_BTNUM_FINO); agno, XFS_BTNUM_FINO);
if (!sa->fino_cur)
goto err;
} }
/* Set up a rmapbt cursor for cross-referencing. */ /* Set up a rmapbt cursor for cross-referencing. */
...@@ -502,8 +494,6 @@ xchk_ag_btcur_init( ...@@ -502,8 +494,6 @@ xchk_ag_btcur_init(
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_RMAP)) {
sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp, sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp,
agno); agno);
if (!sa->rmap_cur)
goto err;
} }
/* Set up a refcountbt cursor for cross-referencing. */ /* Set up a refcountbt cursor for cross-referencing. */
...@@ -511,13 +501,9 @@ xchk_ag_btcur_init( ...@@ -511,13 +501,9 @@ xchk_ag_btcur_init(
xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_REFC)) { xchk_ag_btree_healthy_enough(sc, sa->pag, XFS_BTNUM_REFC)) {
sa->refc_cur = xfs_refcountbt_init_cursor(mp, sc->tp, sa->refc_cur = xfs_refcountbt_init_cursor(mp, sc->tp,
sa->agf_bp, agno); sa->agf_bp, agno);
if (!sa->refc_cur)
goto err;
} }
return 0; return 0;
err:
return -ENOMEM;
} }
/* Release the AG header context and btree cursors. */ /* Release the AG header context and btree cursors. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment