Re: [PATCH] checkpatch.pl: Check for functions without a realprototype

From: Joe Perches
Date: Fri Mar 16 2012 - 19:32:10 EST


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/