Messages in this thread | | | Subject | Re: [PATCH] checkpatch.pl: Check for functions without a real prototype | From | Joe Perches <> | Date | Fri, 16 Mar 2012 16:31:47 -0700 |
| |
On Sat, 2012-03-17 at 00:04 +0100, Richard Weinberger wrote: > Functions like this one are evil: > void foo() > { > ... > } [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -2304,6 +2304,19 @@ sub process { [] > + if ($line=~/$Type\s*$Ident\(\)/) {
Perhaps this should be: if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
> + ERROR("FUNCTION_NO_PROTOTYPE", > +"Function without a real prototype\n" . $herecurr .
Sensible, but maybe: "Bad function definition - $1() should probably be $1(void)\n"
> +"Thou 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");
Humorous once, painful in twice, annoying after.
cheers, Joe
| |