Re: [PATCH] ext4: fix Wunused-but-set-variable warning in ext4_add_entry()
From: Yunfeng Ye
Date: Tue Dec 17 2019 - 09:47:06 EST
On 2019/12/17 22:38, Ritesh Harjani wrote:
>
>
> On 12/17/19 5:41 PM, Yunfeng Ye wrote:
>> 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@xxxxxxxxxx>
>
> Looks good to me. You may add:
>
> Reviewed-by: Ritesh Harjani <riteshh@xxxxxxxxxxxxx>
>
ok, thanks.
>
>
>> ---
>> Â fs/ext4/namei.c | 4 +++-
>> Â 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
>> index a856997d87b5..617349be460f 100644
>> --- a/fs/ext4/namei.c
>> +++ b/fs/ext4/namei.c
>> @@ -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;
>>
>
>
> .
>