From: Lukas Bulwahn <lukas.bulwahn@gmail.com>
To: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [Linux-kernel-mentees] [PATCH] checkpatch: fix author Signed-off-by warning for split From: header
Date: Sat, 19 Sep 2020 09:25:32 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.21.2009190911580.3948@felia> (raw)
In-Reply-To: <CABJPP5D2h95X7WWzP0Nq+e2QcuPbrpp-noFmR9ZJvUw3GszVZA@mail.gmail.com>
On Sat, 19 Sep 2020, Dwaipayan Ray wrote:
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > > index 504d2e431c60..8c4119ca7d17 100755
> > > --- a/scripts/checkpatch.pl
> > > +++ b/scripts/checkpatch.pl
> > > @@ -2347,6 +2347,7 @@ sub process {
> > > my $signoff = 0;
> > > my $author = '';
> > > my $authorsignoff = 0;
> > > + my $prevheader = 0;
> > > my $is_patch = 0;
> > > my $is_binding_patch = -1;
> > > my $in_header_lines = $file ? 0 : 1;
> > > @@ -2658,12 +2659,22 @@ sub process {
> > > }
> > > }
> > >
> > > +# Check the patch for a split From:
> > > + if ($author eq '' && decode("MIME-Header", $prevheader) =~ /^From:\s*(.*)/) {
> >
> > How about extending to check if $prevheader is not 0?
> >
> > > + $author = $1.$line;
> > > + $author = encode("utf8", $author) if ($prevheader =~ /=\?utf-8\?/i);
> > > + $author =~ s/"//g;
> > > + $author = reformat_email($author);
> > > + $prevheader = '';
> > > + }
> > > +
> > > # Check the patch for a From:
> > > if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> > > $author = $1;
> > > $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
> > > $author =~ s/"//g;
> > > $author = reformat_email($author);
> > > + $prevheader = $line;
> > > }
> > >
> >
> > So here we see two almost identical parts of code now, right?
> >
> > Either use a small function or restructure the code such that the
> > differences are in two branches and the common code is part of one common
> > control flow. You are a good programmer, you can figure this out.
> >
>
> Hi,
> I have changed the structure around a bit.
>
Next time, please just send a proper PATCH v2 when you rework a patch.
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 504d2e431c60..86975baead22 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1210,6 +1210,16 @@ sub reformat_email {
> return format_email($email_name, $email_address);
> }
>
> +sub format_author_email {
> + my ($email, $from) = @_;
> +
> + $email = encode("utf8", $email) if ($from =~ /=\?utf-8\?/i);
> + $email =~ s/"//g;
> + $email = reformat_email($email);
> +
> + return $email;
> +}
> +
> sub same_email_addresses {
> my ($email1, $email2) = @_;
>
> @@ -2347,6 +2357,7 @@ sub process {
> my $signoff = 0;
> my $author = '';
> my $authorsignoff = 0;
> + my $prevheader = '';
> my $is_patch = 0;
> my $is_binding_patch = -1;
> my $in_header_lines = $file ? 0 : 1;
> @@ -2658,12 +2669,21 @@ sub process {
> }
> }
>
> +# Check the patch for a split From:
> + if($prevheader ne '') {
> + if ($author eq '' && decode("MIME-Header", $prevheader) =~
> /^From:\s*(.*)/) {
> + my $email = $1.$line;
> + $author = format_author_email($email, $prevheader);
> + }
> + $prevheader = '';
> + }
> +
> # Check the patch for a From:
> if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> - $author = $1;
> - $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
> - $author =~ s/"//g;
> - $author = reformat_email($author);
> + $author = format_author_email($1, $line);
> + if($author eq '') {
> + $prevheader = $line;
> + }
> }
>
> # Check the patch for a signoff:
>
> Is it good to go? I shall mail it in then.
>
Yes, I think it is good for a first submission.
Please use ./scripts/get_maintainers.pl to find the developers to send
this patch to.
Also CC: me and the linux-kernel-mentees mailing list.
Once, the list is on the linux-kernel mailing list, we will start
reviewing and testing your patch.
Lukas
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
prev parent reply other threads:[~2020-09-19 7:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-18 12:29 [Linux-kernel-mentees] [PATCH] checkpatch: fix author Signed-off-by warning for split From: header Dwaipayan Ray
2020-09-18 12:58 ` Lukas Bulwahn
2020-09-18 15:05 ` Dwaipayan Ray
2020-09-19 5:57 ` Dwaipayan Ray
2020-09-19 7:25 ` Lukas Bulwahn [this message]
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=alpine.DEB.2.21.2009190911580.3948@felia \
--to=lukas.bulwahn@gmail.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.