btrfs: simplify local variables in btrfs_ioctl_resize()
authorDavid Sterba <dsterba@suse.com>
Mon, 3 Mar 2025 14:55:32 +0000 (15:55 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Mar 2025 19:35:49 +0000 (20:35 +0100)
Remove some redundant variables and assignments, move variable
declarations to their closest scope.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c

index b05b81a95fc1a35fdec3e70789fbbbf1415bfc64..a7aff4769a58267404aaed45ebbb10e3d5bd66a9 100644 (file)
@@ -1033,17 +1033,14 @@ static noinline int btrfs_ioctl_resize(struct file *file,
                                        void __user *arg)
 {
        BTRFS_DEV_LOOKUP_ARGS(args);
-       struct inode *inode = file_inode(file);
-       struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+       struct btrfs_root *root = BTRFS_I(file_inode(file))->root;
+       struct btrfs_fs_info *fs_info = root->fs_info;
        u64 new_size;
        u64 old_size;
        u64 devid = 1;
-       struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_ioctl_vol_args *vol_args;
-       struct btrfs_trans_handle *trans;
        struct btrfs_device *device = NULL;
        char *sizestr;
-       char *retptr;
        char *devstr = NULL;
        int ret = 0;
        int mod = 0;
@@ -1111,6 +1108,8 @@ static noinline int btrfs_ioctl_resize(struct file *file,
        if (!strcmp(sizestr, "max"))
                new_size = bdev_nr_bytes(device->bdev);
        else {
+               char *retptr;
+
                if (sizestr[0] == '-') {
                        mod = -1;
                        sizestr++;
@@ -1158,6 +1157,8 @@ static noinline int btrfs_ioctl_resize(struct file *file,
        new_size = round_down(new_size, fs_info->sectorsize);
 
        if (new_size > old_size) {
+               struct btrfs_trans_handle *trans;
+
                trans = btrfs_start_transaction(root, 0);
                if (IS_ERR(trans)) {
                        ret = PTR_ERR(trans);