[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c0bdfa2c0c1f2c7ebdcbe7d4a1366c1697ce57a.camel@perches.com>
Date: Sat, 05 Jun 2021 12:32:19 -0700
From: Joe Perches <joe@...ches.com>
To: Dwaipayan Ray <dwaipayanray1@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, lukas.bulwahn@...il.com
Subject: Re: [PATCH] checkpatch: do not allow using -f/--file option without
a filename
On Sun, 2021-06-06 at 00:47 +0530, Dwaipayan Ray wrote:
> When checkpatch is run without a filename, it reads from stdin.
> But if --file option is used along with that, it may generate
> false positives.
>
> Consider the following test file:
> $cat test.c
> int x = a - b;
>
> $cat test.c | ./scripts/checkpatch.pl -f
> WARNING: It's generally not useful to have the filename in the file
> +int x = a - b;
>
> This is a false positive and occurs because $realfile is set to "-".
> Also since checkpatch relies on the file's extension to run specific
> checks for c files, assembly files, etc, most of the checks are
> not run as well.
>
> So it is better to disable -f/--file option when checkpatch is
> run without a filename.
That's a reasonable commit message, thanks.
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -331,6 +331,7 @@ help(0) if ($help);
>
>
> die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix));
> die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse);
> +die "$P: -f/--file requires at least one filename\n" if ($file && $#ARGV < 0);
>
> if ($color =~ /^[01]$/) {
> $color = !$color;
Powered by blists - more mailing lists