Skip to content

Commit 20fb05a

Browse files
fdmananakdave
authored andcommitted
btrfs: use a single variable for return value at run_delayed_extent_op()
Instead of using a 'ret' and an 'err' variable at run_delayed_extent_op() for tracking the return value, use a single one ('ret'). This simplifies the code, makes it comply with most of the existing code and it's less prone for logic errors as time has proven over and over in the btrfs code. Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent e721043 commit 20fb05a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

fs/btrfs/extent-tree.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,6 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
16021602
struct extent_buffer *leaf;
16031603
u32 item_size;
16041604
int ret;
1605-
int err = 0;
16061605
int metadata = 1;
16071606

16081607
if (TRANS_ABORTED(trans))
@@ -1629,10 +1628,8 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
16291628
again:
16301629
ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
16311630
if (ret < 0) {
1632-
err = ret;
16331631
goto out;
1634-
}
1635-
if (ret > 0) {
1632+
} else if (ret > 0) {
16361633
if (metadata) {
16371634
if (path->slots[0] > 0) {
16381635
path->slots[0]--;
@@ -1653,7 +1650,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
16531650
goto again;
16541651
}
16551652
} else {
1656-
err = -EUCLEAN;
1653+
ret = -EUCLEAN;
16571654
btrfs_err(fs_info,
16581655
"missing extent item for extent %llu num_bytes %llu level %d",
16591656
head->bytenr, head->num_bytes, extent_op->level);
@@ -1665,11 +1662,11 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
16651662
item_size = btrfs_item_size(leaf, path->slots[0]);
16661663

16671664
if (unlikely(item_size < sizeof(*ei))) {
1668-
err = -EUCLEAN;
1665+
ret = -EUCLEAN;
16691666
btrfs_err(fs_info,
16701667
"unexpected extent item size, has %u expect >= %zu",
16711668
item_size, sizeof(*ei));
1672-
btrfs_abort_transaction(trans, err);
1669+
btrfs_abort_transaction(trans, ret);
16731670
goto out;
16741671
}
16751672

@@ -1679,7 +1676,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
16791676
btrfs_mark_buffer_dirty(leaf);
16801677
out:
16811678
btrfs_free_path(path);
1682-
return err;
1679+
return ret;
16831680
}
16841681

16851682
static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,

0 commit comments

Comments
 (0)