Re: [PATCH] checkpatch.pl: Check for function declarations withoutarguments

From: Borislav Petkov
Date: Mon Nov 18 2013 - 18:30:38 EST


On Mon, Nov 18, 2013 at 03:23:01PM -0800, Joe Perches wrote:
> 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 <richard@xxxxxx>
> Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
> ---
> scripts/checkpatch.pl | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 61090e0..2e1ff0c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2634,6 +2634,15 @@ sub process {
> $herecurr);
> }
>
> +# check for function declarations without arguments like "int foo()"
> + if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
> + if (ERROR("FUNCTION_WITHOUT_ARGS",
> + "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&

I liked the nice preaching comment better - this one is boring.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
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/