* [PATCH v2] checkpatch.pl: Check for functions without a real prototype
@ 2013-11-22 22:17 Elena Ufimtseva
2013-11-22 22:45 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Elena Ufimtseva @ 2013-11-22 22:17 UTC (permalink / raw)
To: apw, joe; +Cc: linux-kernel, Elena Ufimtseva
Based on Richard Weinberger patch https://lkml.org/lkml/2012/3/16/510
Functions like this one are evil:
void foo()
{
...
}
Signed-off-by: Elena Ufimtseva <ufimtseva@gmail.com>
---
Changes since v1:
- added white space in regular expression between (), based
on comments from Joe Perches.
scripts/checkpatch.pl | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 61090e0..08c95c0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2785,6 +2785,19 @@ sub process {
"open brace '{' following function declarations go on the next line\n" . $herecurr);
}
+ if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
+ ERROR("FUNCTION_NO_PROTOTYPE",
+"Bad function definition - $1() should probably be $1(void)\n" . $herecurr .
+"\nThou shalt not, in the language of C, under any circumstances, on the
+pain of death, declare or define a function with an empty set of
+parentheses, for though in the language of C++ it meaneth the same as
+(void), in C it meaneth (...) which is of meaningless as there be no
+anchor argument by which the types of the varadic arguments can be
+expressed, and which misleadeth the compiler into allowing unsavory code
+and in some cases generate really ugly stuff for varadic handling.
+ -hpa\n");
+ }
+
# open braces for enum, union and struct go on the same line.
if ($line =~ /^.\s*{/ &&
$prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
--
1.7.10.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] checkpatch.pl: Check for functions without a real prototype
2013-11-22 22:17 [PATCH v2] checkpatch.pl: Check for functions without a real prototype Elena Ufimtseva
@ 2013-11-22 22:45 ` Joe Perches
2013-11-22 22:48 ` Elena Ufimtseva
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2013-11-22 22:45 UTC (permalink / raw)
To: Elena Ufimtseva; +Cc: apw, linux-kernel
On Fri, 2013-11-22 at 17:17 -0500, Elena Ufimtseva wrote:
> Based on Richard Weinberger patch https://lkml.org/lkml/2012/3/16/510
> Functions like this one are evil:
>
> void foo()
> {
> ...
> }
[]
> - added white space in regular expression between (), based
> on comments from Joe Perches.
Thanks Elena, but this is already applied in -next.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] checkpatch.pl: Check for functions without a real prototype
2013-11-22 22:45 ` Joe Perches
@ 2013-11-22 22:48 ` Elena Ufimtseva
0 siblings, 0 replies; 3+ messages in thread
From: Elena Ufimtseva @ 2013-11-22 22:48 UTC (permalink / raw)
To: Joe Perches; +Cc: apw, linux-kernel
On Fri, Nov 22, 2013 at 5:45 PM, Joe Perches <joe@perches.com> wrote:
> On Fri, 2013-11-22 at 17:17 -0500, Elena Ufimtseva wrote:
>> Based on Richard Weinberger patch https://lkml.org/lkml/2012/3/16/510
>> Functions like this one are evil:
>>
>> void foo()
>> {
>> ...
>> }
> []
>> - added white space in regular expression between (), based
>> on comments from Joe Perches.
>
> Thanks Elena, but this is already applied in -next.
>
>
No problem, thanks Joe )
--
Elena
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-22 22:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-22 22:17 [PATCH v2] checkpatch.pl: Check for functions without a real prototype Elena Ufimtseva
2013-11-22 22:45 ` Joe Perches
2013-11-22 22:48 ` Elena Ufimtseva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®