btrfs: remove pointless out labels from ioctl.c

Some functions (__btrfs_ioctl_snap_create(), btrfs_ioctl_subvol_setflags()
and copy_to_sk()) 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 up the 'ret' variable.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana 2026-01-20 11:25:31 +00:00 committed by David Sterba
parent 51b1fcf71c
commit 01f93271ed

View File

@ -1176,7 +1176,7 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
bool readonly,
struct btrfs_qgroup_inherit *inherit)
{
int ret = 0;
int ret;
struct qstr qname = QSTR_INIT(name, strlen(name));
if (!S_ISDIR(file_inode(file)->i_mode))
@ -1184,7 +1184,7 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
ret = mnt_want_write_file(file);
if (ret)
goto out;
return ret;
if (strchr(name, '/')) {
ret = -EINVAL;
@ -1236,7 +1236,6 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
}
out_drop_write:
mnt_drop_write_file(file);
out:
return ret;
}
@ -1352,14 +1351,14 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
struct btrfs_trans_handle *trans;
u64 root_flags;
u64 flags;
int ret = 0;
int ret;
if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
return -EPERM;
ret = mnt_want_write_file(file);
if (ret)
goto out;
return ret;
if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FIRST_FREE_OBJECTID) {
ret = -EINVAL;
@ -1428,7 +1427,6 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
up_write(&fs_info->subvol_sem);
out_drop_write:
mnt_drop_write_file(file);
out:
return ret;
}
@ -1494,10 +1492,8 @@ static noinline int copy_to_sk(struct btrfs_path *path,
continue;
if (sizeof(sh) + item_len > *buf_size) {
if (*num_found) {
ret = 1;
goto out;
}
if (*num_found)
return 1;
/*
* return one empty item back for v1, which does not
@ -1509,10 +1505,8 @@ static noinline int copy_to_sk(struct btrfs_path *path,
ret = -EOVERFLOW;
}
if (sizeof(sh) + item_len + *sk_offset > *buf_size) {
ret = 1;
goto out;
}
if (sizeof(sh) + item_len + *sk_offset > *buf_size)
return 1;
sh.objectid = key->objectid;
sh.type = key->type;
@ -1526,10 +1520,8 @@ static noinline int copy_to_sk(struct btrfs_path *path,
* problem. Otherwise we'll fault and then copy the buffer in
* properly this next time through
*/
if (copy_to_user_nofault(ubuf + *sk_offset, &sh, sizeof(sh))) {
ret = 0;
goto out;
}
if (copy_to_user_nofault(ubuf + *sk_offset, &sh, sizeof(sh)))
return 0;
*sk_offset += sizeof(sh);
@ -1541,22 +1533,20 @@ static noinline int copy_to_sk(struct btrfs_path *path,
*/
if (read_extent_buffer_to_user_nofault(leaf, up,
item_off, item_len)) {
ret = 0;
*sk_offset -= sizeof(sh);
goto out;
return 0;
}
*sk_offset += item_len;
}
(*num_found)++;
if (ret) /* -EOVERFLOW from above */
goto out;
/* -EOVERFLOW from above. */
if (ret)
return ret;
if (*num_found >= sk->nr_items) {
ret = 1;
goto out;
}
if (*num_found >= sk->nr_items)
return 1;
}
advance_key:
ret = 0;
@ -1576,7 +1566,7 @@ static noinline int copy_to_sk(struct btrfs_path *path,
key->objectid++;
} else
ret = 1;
out:
/*
* 0: all items from this leaf copied, continue with next
* 1: * more items can be copied, but unused buffer is too small