bcachefs: Fix -Wc23-extensions in bch2_check_dirents()
authorNathan Chancellor <nathan@kernel.org>
Wed, 4 Jun 2025 19:38:27 +0000 (12:38 -0700)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 4 Jun 2025 20:45:38 +0000 (16:45 -0400)
Clang warns (or errors with CONFIG_WERROR=y):

  fs/bcachefs/fsck.c:2325:2: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
   2325 |         int ret = bch2_trans_run(c,
        |         ^

On clang-17 and older, this is an unconditional error:

  fs/bcachefs/fsck.c:2325:2: error: expected expression
   2325 |         int ret = bch2_trans_run(c,
        |         ^

Move the declaration of ret to the top of the function to resolve both
ways this issue manifests.

Fixes: c72def523799 ("bcachefs: Run check_dirents second time if required")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fsck.c

index 458f61c..dedb80f 100644 (file)
@@ -2313,10 +2313,11 @@ int bch2_check_dirents(struct bch_fs *c)
        struct snapshots_seen s;
        struct bch_hash_info hash_info;
        bool need_second_pass = false, did_second_pass = false;
+       int ret;
 
        snapshots_seen_init(&s);
 again:
-       int ret = bch2_trans_run(c,
+       ret = bch2_trans_run(c,
                for_each_btree_key_commit(trans, iter, BTREE_ID_dirents,
                                POS(BCACHEFS_ROOT_INO, 0),
                                BTREE_ITER_prefetch|BTREE_ITER_all_snapshots, k,