mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Dwaipayan Ray <dwaipayanray1@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com
Subject: Re: [PATCH] checkpatch: do not allow using -f/--file option without a filename
Date: Sat, 05 Jun 2021 12:32:19 -0700	[thread overview]
Message-ID: <0c0bdfa2c0c1f2c7ebdcbe7d4a1366c1697ce57a.camel@perches.com> (raw)
In-Reply-To: <20210605191754.28165-1-dwaipayanray1@gmail.com>

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;



  reply	other threads:[~2021-06-05 19:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-05 19:17 Dwaipayan Ray
2021-06-05 19:32 ` Joe Perches [this message]
2021-06-07  5:11   ` Lukas Bulwahn
2021-06-07  5:53     ` Dwaipayan Ray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c0bdfa2c0c1f2c7ebdcbe7d4a1366c1697ce57a.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=dwaipayanray1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®