lkml.org 
[lkml]   [2021]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] checkpatch: do not allow using -f/--file option without a filename
Date
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.

Link: https://lore.kernel.org/lkml/294bb4a2c3f5f8cf4a744cf59bfd37562653afb9.camel@perches.com/T/#t
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
scripts/checkpatch.pl | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3e1795311c87..7dff9206f9f0 100755
--- 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;
--
2.28.0
\
 
 \ /
  Last update: 2021-06-05 21:19    [W:0.045 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site