diff options
author | Joe Perches <joe@perches.com> | 2014-01-27 20:07:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 00:02:40 -0500 |
commit | b36190c5f85724da1871bfb8eddbeb77a45c4952 (patch) | |
tree | d424160e8bed505f1073709e0d5504068784f8d2 /scripts | |
parent | a3978a519461b095b776f44a86079f5448c96963 (diff) |
checkpatch.pl: check for function declarations without arguments
Functions like this one are evil:
void foo()
{
...
}
Because these functions allow variadic arguments without
checking the arguments at all.
Original patch by Richard Weinberger.
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Borislav Petkov <bp@alien8.de>
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 | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1dbd6d1cd1b5..0ea2a1e24ade 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -2665,6 +2665,15 @@ sub process { | |||
2665 | $herecurr); | 2665 | $herecurr); |
2666 | } | 2666 | } |
2667 | 2667 | ||
2668 | # check for function declarations without arguments like "int foo()" | ||
2669 | if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) { | ||
2670 | if (ERROR("FUNCTION_WITHOUT_ARGS", | ||
2671 | "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) && | ||
2672 | $fix) { | ||
2673 | $fixed[$linenr - 1] =~ s/(\b($Type)\s+($Ident))\s*\(\s*\)/$2 $3(void)/; | ||
2674 | } | ||
2675 | } | ||
2676 | |||
2668 | # check for uses of DEFINE_PCI_DEVICE_TABLE | 2677 | # check for uses of DEFINE_PCI_DEVICE_TABLE |
2669 | if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) { | 2678 | if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) { |
2670 | if (WARN("DEFINE_PCI_DEVICE_TABLE", | 2679 | if (WARN("DEFINE_PCI_DEVICE_TABLE", |