From: Joe Perches <joe@perches.com>
To: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
linux-kernel <linux-kernel@vger.kernel.org>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Subject: Re: [PATCH] checkpatch: add --fix option for OPEN_BRACE issues
Date: Wed, 18 Nov 2020 12:39:00 -0800 [thread overview]
Message-ID: <c69f32af186d672c9370750985914b889f6a5b14.camel@perches.com> (raw)
In-Reply-To: <CABJPP5DTBkuzEjs28wufdnOXf61-T=wtoZWiTya_idXfJ92eNQ@mail.gmail.com>
On Thu, 2020-11-19 at 01:52 +0530, Dwaipayan Ray wrote:
> On Thu, Nov 19, 2020 at 1:28 AM Joe Perches <joe@perches.com> wrote:
> > On Thu, 2020-11-19 at 00:15 +0530, Dwaipayan Ray wrote:
> > > On Thu, Nov 19, 2020 at 12:09 AM Joe Perches <joe@perches.com> wrote:
> > > > On Thu, 2020-11-19 at 00:03 +0530, Dwaipayan Ray wrote:
> > > > > On Wed, Nov 18, 2020 at 11:44 PM Joe Perches <joe@perches.com> wrote:
> > > > > > On Wed, 2020-11-18 at 18:10 +0530, Dwaipayan Ray wrote:
> > > > > > > Brace style misuses of the following types are now
> > > > > > > corrected:
> > > > > > []
> > > > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > > > > > []
> > > > > > > @@ -3937,9 +3937,23 @@ sub process {
> > > > > > > #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
> > > > > > >
> > > > > > > if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
> > > > > > > - ERROR("OPEN_BRACE",
> > > > > > > - "that open brace { should be on the previous line\n" .
> > > > > > > - "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
> > > > > > > + if (ERROR("OPEN_BRACE",
> > > > > > > + "that open brace { should be on the previous line\n" .
> > > > > > > + "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n") &&
> > > > > > > + $fix) {
> > > > > > > + my $line1 = $rawlines[$ctx_ln - 2];
> > > > > >
> > > > > > How are you sure that in a patch context this line always starts with /^\+/ ?
> > > > >
> > > > > Hi,
> > > > > I followed it from the other fixes for OPEN_BRACE which were already
> > > > > there. In the patch context if the lines are added then only I think the fix
> > > > > should be triggered. Other instances should not be modified.
> > > >
> > > > As far as I know there are no existing uses of --fix with OPEN_BRACE.
> > > >
> > >
> > > I think you added it via 8d1824780f2f1 ("checkpatch: add --fix option
> > > for a couple OPEN_BRACE misuses")
> >
> > The difference here is that you are dealing with a $stat context and
> > the existing --fix entries are just for single line fixes.
> >
>
> Hi,
> Ya I understand that. Though I am dealing with $stat content,
> I am also directly accessing $rawlines here.
> So I think that should have the proper patch line format, starting
> with + or - or so.
>
> So in this case if the error is triggered, checking for /^+/ should be done
> becase it would be wrong to fix the others with /^[- ]/
>
> Is there something else that I am not getting here?
$stat does not include lines that are skipped if the lines start with -
Patch context may be:
line content
1 func(...
2 - original arguments);
3 + changed);
where $stat does not include the 'original arguments' changed line
func(...,
changed);
but the $rawlines[] entries are consecutive.
Anyway, this needs to be handled very carefully if handled at all.
I think it's easier to avoid handling these cases and let the
patch submitter fix it manually if appropriate.
next prev parent reply other threads:[~2020-11-18 20:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 12:40 Dwaipayan Ray
2020-11-18 18:14 ` Joe Perches
2020-11-18 18:33 ` Dwaipayan Ray
2020-11-18 18:39 ` Joe Perches
2020-11-18 18:45 ` Dwaipayan Ray
2020-11-18 19:58 ` Joe Perches
2020-11-18 20:22 ` Dwaipayan Ray
2020-11-18 20:39 ` Joe Perches [this message]
2020-11-18 20:52 ` 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=c69f32af186d672c9370750985914b889f6a5b14.camel@perches.com \
--to=joe@perches.com \
--cc=dwaipayanray1@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--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®