mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Joe Perches <joe@perches.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	Andy Whitcroft <apw@canonical.com>,
	Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, users@linux.kernel.org
Subject: Re: [kernel.org users] [PATCH v2] checkpatch: use patch subject when reading from stdin
Date: Tue, 5 May 2020 22:40:15 +0200	[thread overview]
Message-ID: <20200505204015.44ibvg4bapnalrct@pali> (raw)
In-Reply-To: <1b0b4e6562cbbf4621e71042e511ae3cd0b542f6.camel@perches.com>

Hello!

On Tuesday 05 May 2020 12:57:37 Joe Perches wrote:
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index eac40f0abd56a9f4..3355358697d9e790 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -1057,6 +1057,10 @@ for my $filename (@ARGV) {
> >  	}
> >  	while (<$FILE>) {
> >  		chomp;
> > +		if ($vname eq 'Your patch') {
> > +			my ($subject) = $_ =~ /^Subject:\s*(.*)/;
> > +			$vname = '"' . $subject . '"' if $subject;
> > +		}
> >  		push(@rawlines, $_);
> >  	}
> >  	close($FILE);
> 
> There's a less cpu intensive way to do this,
> for small patches, on my little laptop it's a
> few dozen milliseconds faster, and for very
> large patches multiple seconds faster to use
> the following patch:
> 
> Substitute Geert's patch with the below but:
> 
> Acked-by: Joe Perches <joe@perches.com>
> 
> ---
> 
>  scripts/checkpatch.pl | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index f0092104ff7b..29786a097862 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1062,6 +1062,7 @@ for my $filename (@ARGV) {
>  	while (<$FILE>) {
>  		chomp;
>  		push(@rawlines, $_);
> +		$vname = "\"$1\"" if ($filename eq '-' && $_ =~ /^Subject:\s*(.*)/);

Hint: You can use qq operator to make code more readable (no need to
escape quote character). And maybe you should match Subject as
case-insensitive and expects at least one space after colon.
As a Perl developer I would write above code as:

+		$vname = qq("$1") if $filename eq '-' && $_ =~ m/^Subject:\s+(.+)/i;

Anyway, what would happen if subject line contains quotes?

>  	}
>  	close($FILE);
>  
> 

  reply	other threads:[~2020-05-05 20:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 13:26 Geert Uytterhoeven
2020-05-05 19:18 ` Andrew Morton
2020-05-06  6:55   ` Geert Uytterhoeven
2020-05-05 19:57 ` Joe Perches
2020-05-05 20:40   ` Pali Rohár [this message]
2020-05-05 20:54     ` [kernel.org users] " Joe Perches

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=20200505204015.44ibvg4bapnalrct@pali \
    --to=pali@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=geert+renesas@glider.be \
    --cc=joe@perches.com \
    --cc=konstantin@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=users@linux.kernel.org \
    /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®