ext4: fix unused-but-set-variable warning in ext4_add_entry()
authorYunfeng Ye <yeyunfeng@huawei.com>
Tue, 17 Dec 2019 14:46:49 +0000 (22:46 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 22 Dec 2019 02:00:53 +0000 (21:00 -0500)
Warning is found when compile with "-Wunused-but-set-variable":

fs/ext4/namei.c: In function ‘ext4_add_entry’:
fs/ext4/namei.c:2167:23: warning: variable ‘sbi’ set but not used
[-Wunused-but-set-variable]
  struct ext4_sb_info *sbi;
                       ^~~
Fix this by moving the variable @sbi under CONFIG_UNICODE.

Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/cb5eb904-224a-9701-c38f-cb23514b1fff@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/namei.c

index 9e6d14748b5a53d6380a513cb99439c91ceaa0aa..1cb42d94078479dc9a9e107c79e361e0c385a02b 100644 (file)
@@ -2164,7 +2164,9 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
        struct buffer_head *bh = NULL;
        struct ext4_dir_entry_2 *de;
        struct super_block *sb;
+#ifdef CONFIG_UNICODE
        struct ext4_sb_info *sbi;
+#endif
        struct ext4_filename fname;
        int     retval;
        int     dx_fallback=0;
@@ -2176,12 +2178,12 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
                csum_size = sizeof(struct ext4_dir_entry_tail);
 
        sb = dir->i_sb;
-       sbi = EXT4_SB(sb);
        blocksize = sb->s_blocksize;
        if (!dentry->d_name.len)
                return -EINVAL;
 
 #ifdef CONFIG_UNICODE
+       sbi = EXT4_SB(sb);
        if (ext4_has_strict_mode(sbi) && IS_CASEFOLDED(dir) &&
            sbi->s_encoding && utf8_validate(sbi->s_encoding, &dentry->d_name))
                return -EINVAL;