Skip to content

Commit 0d6d7c6

Browse files
nathanchanceaalexandrovich
authored andcommitted
fs/ntfs3: Don't use uni1 uninitialized in ntfs_d_compare()
Clang warns: fs/ntfs3/namei.c:445:7: error: variable 'uni1' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (toupper(c1) != toupper(c2)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/ctype.h:64:20: note: expanded from macro 'toupper' #define toupper(c) __toupper(c) ^ fs/ntfs3/namei.c:487:12: note: uninitialized use occurs here __putname(uni1); ^~~~ ./include/linux/fs.h:2789:65: note: expanded from macro '__putname' #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) ^~~~ fs/ntfs3/namei.c:445:3: note: remove the 'if' if its condition is always false if (toupper(c1) != toupper(c2)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/ntfs3/namei.c:434:7: error: variable 'uni1' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (!lm--) { ^~~~~ fs/ntfs3/namei.c:487:12: note: uninitialized use occurs here __putname(uni1); ^~~~ ./include/linux/fs.h:2789:65: note: expanded from macro '__putname' #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) ^~~~ fs/ntfs3/namei.c:434:3: note: remove the 'if' if its condition is always false if (!lm--) { ^~~~~~~~~~~~ fs/ntfs3/namei.c:430:22: note: initialize the variable 'uni1' to silence this warning struct cpu_str *uni1, *uni2; ^ = NULL 2 errors generated. There is no point in calling __putname() in these particular error paths, as there has been no corresponding __getname() call yet. Just return directly in these blocks to clear up the warning. Fixes: a3a956c ("fs/ntfs3: Add option "nocase"") Link: ClangBuiltLinux/linux#1729 Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
1 parent d45da67 commit 0d6d7c6

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

fs/ntfs3/namei.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,21 +431,17 @@ static int ntfs_d_compare(const struct dentry *dentry, unsigned int len1,
431431

432432
/* First try fast implementation. */
433433
for (;;) {
434-
if (!lm--) {
435-
ret = len1 == len2 ? 0 : 1;
436-
goto out;
437-
}
434+
if (!lm--)
435+
return len1 == len2 ? 0 : 1;
438436

439437
if ((c1 = *n1++) == (c2 = *n2++))
440438
continue;
441439

442440
if (c1 >= 0x80 || c2 >= 0x80)
443441
break;
444442

445-
if (toupper(c1) != toupper(c2)) {
446-
ret = 1;
447-
goto out;
448-
}
443+
if (toupper(c1) != toupper(c2))
444+
return 1;
449445
}
450446

451447
/*

0 commit comments

Comments
 (0)