Re: [PATCH] checkpatch.pl: fix naked sscanf false positives

Joe Perches
2016-02-06T05:26:31Z

On Fri, 2016-02-05 at 00:29 -0800, Kevin Wern wrote:
> There is a section of checkpatch.pl that intends to ensure the return
> value of sscanf is always checked.  However, in certain cases, like in
> drivers/staging/dgnc/dgnc.mod.c, the symbol for sscanf is used without
> calling the function:
>
> static const struct modversion_info ____versions[]
> __used
> __attribute__((section("__versions"))) = {
> ...
> { 0x20c55ae0, __VMLINUX_SYMBOL_STR(sscanf) },
> ...
> };
>
> This currently results in a warning, which is undesirable. We should
> adjust the script's first regex condition to match *calls* to sscanf,
> not just the symbol itself.
>
> Signed-off-by: Kevin Wern <kevin.m.wern@gmail.com>
> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 0147c91..199247d 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5452,7 +5452,7 @@ sub process {
>  # check for naked sscanf
>   if ($^V && $^V ge 5.10.0 &&
>       defined $stat &&
> -     $line =~ /\bsscanf\b/ &&
> +     $line =~ /\bsscanf\b\s*$balanced_parens/ &&

No, that won't work.  That's what the $stat line is for

I suppose it could be /\bsscanf\s*\(/ though
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html