A little feature addition to allow checkpatch.pl to check patches piped
into it, in addition to specific file arguments.
Signed-off-by: Daniel Walker <dwalker@mvista.com>
---
scripts/checkpatch.pl | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
Index: linux-2.6.23/scripts/checkpatch.pl
===================================================================
--- linux-2.6.23.orig/scripts/checkpatch.pl
+++ linux-2.6.23/scripts/checkpatch.pl
@@ -24,6 +24,7 @@ my $file = 0;
my $check = 0;
my $summary = 1;
my $mailback = 0;
+my $piped = (-t STDIN) ? 0 : 1;
my $root;
GetOptions(
'q|quiet+' => \$quiet,
@@ -43,7 +44,7 @@ GetOptions(
my $exit = 0;
-if ($#ARGV < 0) {
+if ($#ARGV < 0 && !$piped) {
print "usage: $P [options] patchfile\n";
print "version: $V\n";
print "options: -q => quiet\n";
@@ -181,6 +182,18 @@ if ($tree && -f "$root/$removal") {
}
my @rawlines = ();
+
+if ($piped) {
+ while (<STDIN>) {
+ chomp;
+ push(@rawlines, $_);
+ }
+ if (!process("", @rawlines)) {
+ $exit = 1;
+ }
+ @rawlines = ();
+}
+
for my $filename (@ARGV) {
if ($file) {
open(FILE, "diff -u /dev/null $filename|") ||
--
--
--
You can still add - as an argument to check stdin. In which way is this better? regards, -- Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs --
There's was no reason to limit the arguments .. I was using it to do something like the following , git show 9914cad54c79d0b89b1f066c0894f00e1344131c | ./scripts/checkpatch.pl Which I think is useful . Dainel --
Ok, and if you add a - there, it should have the same effect, but for free, doesn't it: git show 9914cad54c79d0b89b1f066c0894f00e1344131c | ./scripts/checkpatch.pl - regards, -- Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs --
Not a particularly attractive command line .. Might still be a good idea to add this since these two forms alluded me, and are likely to allude people new to unix all together (who is more likely to be using this particular tool).. Daniel --
If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack. thanks, -- Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs --
I'm hacking the kernel, and I didn't know the - trick .. So you have your testing case all in one with the patch submitter .. Daniel --
OK, maybe we should base it in doc for patch submitting then? regards, -- Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs --
It's in the bash docs I'm sure, it's just a matter of who ends up reading that part of the docs.. I still think my patch is a good one , we could change the name to "Allow piping with out tricks" I suppose .. Daniel --
Yes, too. And "awk" also supports that. But "/dev/stdin" is also since ages a symlink to Bernd -- Firmix Software GmbH http://www.firmix.at/ mobil: +43 664 4416156 fax: +43 1 7890849-55 Embedded Linux Development and Services --
How about
if ($#ARGV < 0) {
print "usage: $P [options] patchfile\n";
print "version: $V\n";
print "options: -q => quiet\n";
print " --no-tree => run without a kernel tree\n";
print " --terse => one line per report\n";
print " --emacs => emacs compile window format\n";
print " --file => check a source file\n";
print " --strict => enable more subjective tests\n";
print " --root => path to the kernel tree root\n";
+ print "When patchfile is -, read standard input.\n";
exit(1);
}
--
Stefan Richter
-=====-==--- ---= -=-==
http://arcgraph.de/sr/
--
My ACK. regards, -- Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs --
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
---
scripts/checkpatch.pl | 1 +
1 file changed, 1 insertion(+)
Index: linux/scripts/checkpatch.pl
===================================================================
--- linux.orig/scripts/checkpatch.pl
+++ linux/scripts/checkpatch.pl
@@ -53,6 +53,7 @@ if ($#ARGV < 0) {
print " --file => check a source file\n";
print " --strict => enable more subjective tests\n";
print " --root => path to the kernel tree root\n";
+ print "When patchfile is -, read standard input.\n";
exit(1);
}
--
Stefan Richter
-=====-==--- ---= -=-==
http://arcgraph.de/sr/
--
Why add code for a feature which already exists? -- Stefan Richter -=====-==--- ---= -=-== http://arcgraph.de/sr/ --
To make it simpler to use .. A good percentage (if not all) command line unix data processing utils accept piped data directly, without the need for the "-" .. That's the expect usage .. checkpatch.pl doesn't need to deviate from the norm, there is no size constraint, there is no line limit .. So we're not duplicating functionality, we're making the tool conform .. Daniel --
As an absolute minimum this seems reasonable to me. I guess we could make no arguments default to '-' also. There are up and downsides to doing that, as currently no arguments currently tell you the usage and with this patch would point clearly out the '-' option. Just assuming stding would lose easy access to usage, which may actually be more confusing for the beginner. Hmmm. Cirtainly will include this -apw --
The patch that I submitted checks STDIN for piped data, and if there is any it will default to checking that incoming data .. That's regardless of the number of arguments given .. Daniel --
So it does, however that of itself differs from the unix norm; as with this I cannot run checkpatch and "type" (ie paste) a patch fragment to check it. So I don't think we want the semantics as you have there, as its confusing to the experienced user and inconsistent with the norm. Either we should document the standard '-' usage as has been suggested elsewhere or always assume stdin with no parameters. -apw --
I'm not sure I understand what you mean .. Can you give an example? Daniel --
--h (--he --hel --help) suffices due to getopt_long gnu implementation --
I tried the following with my changes, ./scripts/checkpatch.pl - cat | ./scripts/checkpatch.pl Both allowed pasting patches and pressing Ctrl-D , then it processed the patch.. and cat <patchname> | ./scripts/checkpatch.pl Also processed the patch .. Daniel --
Might be. But it works for (almost?) all programs (which do not need seekable input) which absolutely want the input file specified by a parameter. Bernd -- Firmix Software GmbH http://www.firmix.at/ mobil: +43 664 4416156 fax: +43 1 7890849-55 Embedded Linux Development and Services --
| Greg KH | Og dreams of kernels |
| Jens Axboe | [PATCH 31/33] Fusion: sg chaining support |
| Arnd Bergmann | Re: finding your own dead "CONFIG_" variables |
| Mark Brown | [PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset |
| Tony Breeds | [LGUEST] Look in object dir for .config |
git: | |
| Brian Downing | Re: Git in a Nutshell guide |
| John Benes | Re: master has some toys |
| Matthias Lederhofer | [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree |
| Alexander Sulfrian | [RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set |
| Junio C Hamano | Re: Rss produced by git is not valid xml? |
| Linux Kernel Mailing List | iSeries: fix section mismatch in iseries_veth |
| Linux Kernel Mailing List | ixbge: remove TX lock and redo TX accounting. |
| Linux Kernel Mailing List | ixgbe: fix several counter register errata |
| Linux Kernel Mailing List | b43: fix build with CONFIG_SSB_PCIHOST=n |
| Linux Kernel Mailing List | 9p: block-based virtio client |
