bcachefs: Simplify code in bch2_dev_alloc()
authorYouling Tang <tangyouling@kylinos.cn>
Wed, 16 Oct 2024 01:49:11 +0000 (09:49 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:17 +0000 (01:36 -0500)
- Remove unnecessary variable 'ret'.
- Remove unnecessary bch2_dev_free() operations.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/super.c

index 7e0ff17a6dbb21ad6b4911cacc21ec36a4162133..ab678231afd4689d7fd181514fd5a5deecbe50d1 100644 (file)
@@ -1369,7 +1369,6 @@ static int bch2_dev_alloc(struct bch_fs *c, unsigned dev_idx)
 {
        struct bch_member member = bch2_sb_member_get(c->disk_sb.sb, dev_idx);
        struct bch_dev *ca = NULL;
-       int ret = 0;
 
        if (bch2_fs_init_fault("dev_alloc"))
                goto err;
@@ -1381,10 +1380,8 @@ static int bch2_dev_alloc(struct bch_fs *c, unsigned dev_idx)
        ca->fs = c;
 
        bch2_dev_attach(c, ca, dev_idx);
-       return ret;
+       return 0;
 err:
-       if (ca)
-               bch2_dev_free(ca);
        return -BCH_ERR_ENOMEM_dev_alloc;
 }