diff options
author | Joe Perches <joe@perches.com> | 2016-10-11 23:52:16 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-12 01:06:31 +0300 |
commit | ca0d8929e75ab1f860f61208d46955f280a1b05e (patch) | |
tree | 5e13f83f48303772b88c38b38194ab1fdcebf132 /scripts | |
parent | 5207649b7b1d2b1e1f8c97df91debfaa8de37669 (diff) |
checkpatch: add warning for unnamed function definition arguments
Function definitions without identifiers like
int foo(int)
are not preferred. Emit a warning when they occur.
Link: http://lkml.kernel.org/r/94fe6378504745991b650f48fc92bb4648f25706.1474925354.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0ef3d837f2aa..3373c65fef1c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5794,6 +5794,19 @@ sub process { "externs should be avoided in .c files\n" . $herecurr); } + if ($realfile =~ /\.[ch]$/ && defined $stat && + $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s && + $1 ne "void") { + my $args = trim($1); + while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) { + my $arg = trim($1); + if ($arg =~ /^$Type$/ && $arg !~ /enum\s+$Ident$/) { + WARN("FUNCTION_ARGUMENTS", + "function definition argument '$arg' should also have an identifier name\n" . $herecurr); + } + } + } + # checks for new __setup's if ($rawline =~ /\b__setup\("([^"]*)"/) { my $name = $1; |