ext4: mballoc: avoid garbage value from err
authorSu Hui <suhui@nfschina.com>
Tue, 25 Jul 2023 04:33:11 +0000 (12:33 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 27 Aug 2023 15:27:12 +0000 (11:27 -0400)
clang's static analysis warning: fs/ext4/mballoc.c
line 4178, column 6, Branch condition evaluates to a garbage value.

err is uninitialized and will be judged when 'len <= 0' or
it first enters the loop while the condition "!ext4_sb_block_valid()"
is true. Although this can't make problems now, it's better to
correct it.

Signed-off-by: Su Hui <suhui@nfschina.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20230725043310.1227621-1-suhui@nfschina.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/mballoc.c

index a807e8bf8664300cc5378a51ba59e722225255b4..1e4c667812a9d42f955ad7f82b14c3cd677730f9 100644 (file)
@@ -4087,7 +4087,7 @@ void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block,
        struct ext4_sb_info *sbi = EXT4_SB(sb);
        ext4_group_t group;
        ext4_grpblk_t blkoff;
-       int i, err;
+       int i, err = 0;
        int already;
        unsigned int clen, clen_changed, thisgrp_len;