checkpatch: add warning for unnamed function definition arguments
[cascardo/linux.git] / scripts / checkpatch.pl
index 0ef3d83..3373c65 100755 (executable)
@@ -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;