From: Filipe Manana Date: Tue, 20 Jan 2026 11:29:02 +0000 (+0000) Subject: btrfs: remove pointless out labels from send.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccba88cb6ac0f936c0adcaf4c1a213086c7f3457;p=thirdparty%2Fkernel%2Flinux.git btrfs: remove pointless out labels from send.c Some functions (process_extent(), process_recorded_refs_if_needed(), changed_inode(), compare_refs() and changed_cb()) have an 'out' label that does nothing but return, making it pointless. Simplify this by removing the label and returning instead of gotos plus setting the 'ret' variable. Reviewed-by: Johannes Thumshirn Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index d8127a7120c2d..3dcfdba018b51 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -6449,11 +6449,9 @@ static int process_extent(struct send_ctx *sctx, if (sctx->parent_root && !sctx->cur_inode_new) { ret = is_extent_unchanged(sctx, path, key); if (ret < 0) - goto out; - if (ret) { - ret = 0; + return ret; + if (ret) goto out_hole; - } } else { struct btrfs_file_extent_item *ei; u8 type; @@ -6469,31 +6467,25 @@ static int process_extent(struct send_ctx *sctx, * we have enough commands queued up to justify rev'ing * the send spec. */ - if (type == BTRFS_FILE_EXTENT_PREALLOC) { - ret = 0; - goto out; - } + if (type == BTRFS_FILE_EXTENT_PREALLOC) + return 0; /* Have a hole, just skip it. */ - if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0) { - ret = 0; - goto out; - } + if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0) + return 0; } } ret = find_extent_clone(sctx, path, key->objectid, key->offset, sctx->cur_inode_size, &found_clone); if (ret != -ENOENT && ret < 0) - goto out; + return ret; ret = send_write_or_clone(sctx, path, key, found_clone); if (ret) - goto out; + return ret; out_hole: - ret = maybe_send_hole(sctx, path, key); -out: - return ret; + return maybe_send_hole(sctx, path, key); } static int process_all_extents(struct send_ctx *sctx) @@ -6535,23 +6527,24 @@ static int process_recorded_refs_if_needed(struct send_ctx *sctx, bool at_end, int *pending_move, int *refs_processed) { - int ret = 0; + int ret; if (sctx->cur_ino == 0) - goto out; + return 0; + if (!at_end && sctx->cur_ino == sctx->cmp_key->objectid && sctx->cmp_key->type <= BTRFS_INODE_EXTREF_KEY) - goto out; + return 0; + if (list_empty(&sctx->new_refs) && list_empty(&sctx->deleted_refs)) - goto out; + return 0; ret = process_recorded_refs(sctx, pending_move); if (ret < 0) - goto out; + return ret; *refs_processed = 1; -out: - return ret; + return 0; } static int finish_inode_if_needed(struct send_ctx *sctx, bool at_end) @@ -6768,7 +6761,7 @@ static void close_current_inode(struct send_ctx *sctx) static int changed_inode(struct send_ctx *sctx, enum btrfs_compare_tree_result result) { - int ret = 0; + int ret; struct btrfs_key *key = sctx->cmp_key; struct btrfs_inode_item *left_ii = NULL; struct btrfs_inode_item *right_ii = NULL; @@ -6860,7 +6853,7 @@ static int changed_inode(struct send_ctx *sctx, if (result == BTRFS_COMPARE_TREE_NEW) { if (btrfs_inode_nlink(sctx->left_path->nodes[0], left_ii) == 0) { sctx->ignore_cur_inode = true; - goto out; + return 0; } sctx->cur_inode_gen = left_gen; sctx->cur_inode_new = true; @@ -6888,7 +6881,7 @@ static int changed_inode(struct send_ctx *sctx, old_nlinks = btrfs_inode_nlink(sctx->right_path->nodes[0], right_ii); if (new_nlinks == 0 && old_nlinks == 0) { sctx->ignore_cur_inode = true; - goto out; + return 0; } else if (new_nlinks == 0 || old_nlinks == 0) { sctx->cur_inode_new_gen = 1; } @@ -6914,7 +6907,7 @@ static int changed_inode(struct send_ctx *sctx, ret = process_all_refs(sctx, BTRFS_COMPARE_TREE_DELETED); if (ret < 0) - goto out; + return ret; } /* @@ -6935,11 +6928,11 @@ static int changed_inode(struct send_ctx *sctx, left_ii); ret = send_create_inode_if_needed(sctx); if (ret < 0) - goto out; + return ret; ret = process_all_refs(sctx, BTRFS_COMPARE_TREE_NEW); if (ret < 0) - goto out; + return ret; /* * Advance send_progress now as we did not get * into process_recorded_refs_if_needed in the @@ -6953,10 +6946,10 @@ static int changed_inode(struct send_ctx *sctx, */ ret = process_all_extents(sctx); if (ret < 0) - goto out; + return ret; ret = process_all_new_xattrs(sctx); if (ret < 0) - goto out; + return ret; } } else { sctx->cur_inode_gen = left_gen; @@ -6970,8 +6963,7 @@ static int changed_inode(struct send_ctx *sctx, } } -out: - return ret; + return 0; } /* @@ -7104,20 +7096,20 @@ static int compare_refs(struct send_ctx *sctx, struct btrfs_path *path, u32 item_size; u32 cur_offset = 0; int ref_name_len; - int ret = 0; /* Easy case, just check this one dirid */ if (key->type == BTRFS_INODE_REF_KEY) { dirid = key->offset; - ret = dir_changed(sctx, dirid); - goto out; + return dir_changed(sctx, dirid); } leaf = path->nodes[0]; item_size = btrfs_item_size(leaf, path->slots[0]); ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); while (cur_offset < item_size) { + int ret; + extref = (struct btrfs_inode_extref *)(ptr + cur_offset); dirid = btrfs_inode_extref_parent(leaf, extref); @@ -7127,11 +7119,10 @@ static int compare_refs(struct send_ctx *sctx, struct btrfs_path *path, continue; ret = dir_changed(sctx, dirid); if (ret) - break; + return ret; last_dirid = dirid; } -out: - return ret; + return 0; } /* @@ -7212,12 +7203,12 @@ static int changed_cb(struct btrfs_path *left_path, ret = finish_inode_if_needed(sctx, 0); if (ret < 0) - goto out; + return ret; /* Ignore non-FS objects */ if (key->objectid == BTRFS_FREE_INO_OBJECTID || key->objectid == BTRFS_FREE_SPACE_OBJECTID) - goto out; + return 0; if (key->type == BTRFS_INODE_ITEM_KEY) { ret = changed_inode(sctx, result); @@ -7234,7 +7225,6 @@ static int changed_cb(struct btrfs_path *left_path, ret = changed_verity(sctx, result); } -out: return ret; }