Skip to content

Commit 16b7f3c

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: avoid warning about uninitialized_var()
WARNING: function definition argument 'flags' should also have an identifier name #26: FILE: drivers/tty/serial/sh-sci.c:1348: + unsigned long uninitialized_var(flags); Special-case uninitialized_var() to prevent this. Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Tested-by: Andrew Morton <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 50c9290 commit 16b7f3c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

scripts/checkpatch.pl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,7 +4071,7 @@ sub process {
40714071
}
40724072

40734073
# check for function declarations without arguments like "int foo()"
4074-
if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
4074+
if ($line =~ /(\b$Type\s*$Ident)\s*\(\s*\)/) {
40754075
if (ERROR("FUNCTION_WITHOUT_ARGS",
40764076
"Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&
40774077
$fix) {
@@ -6287,13 +6287,17 @@ sub process {
62876287
}
62886288

62896289
# check for function declarations that have arguments without identifier names
6290+
# while avoiding uninitialized_var(x)
62906291
if (defined $stat &&
6291-
$stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
6292-
$1 ne "void") {
6293-
my $args = trim($1);
6292+
$stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:($Ident)|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
6293+
(!defined($1) ||
6294+
(defined($1) && $1 ne "uninitialized_var")) &&
6295+
$2 ne "void") {
6296+
my $args = trim($2);
62946297
while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
62956298
my $arg = trim($1);
6296-
if ($arg =~ /^$Type$/ && $arg !~ /enum\s+$Ident$/) {
6299+
if ($arg =~ /^$Type$/ &&
6300+
$arg !~ /enum\s+$Ident$/) {
62976301
WARN("FUNCTION_ARGUMENTS",
62986302
"function definition argument '$arg' should also have an identifier name\n" . $herecurr);
62996303
}

0 commit comments

Comments
 (0)