From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC53FC5519F for ; Wed, 18 Nov 2020 19:59:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2FA22080A for ; Wed, 18 Nov 2020 19:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726357AbgKRT6u (ORCPT ); Wed, 18 Nov 2020 14:58:50 -0500 Received: from smtprelay0203.hostedemail.com ([216.40.44.203]:55850 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725710AbgKRT6t (ORCPT ); Wed, 18 Nov 2020 14:58:49 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 425BF8384365; Wed, 18 Nov 2020 19:58:48 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: drop19_6100d3c2733c X-Filterd-Recvd-Size: 3328 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Wed, 18 Nov 2020 19:58:47 +0000 (UTC) Message-ID: <12b44d3a477de314320dc9d26b26576875525f27.camel@perches.com> Subject: Re: [PATCH] checkpatch: add --fix option for OPEN_BRACE issues From: Joe Perches To: Dwaipayan Ray Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel , Lukas Bulwahn Date: Wed, 18 Nov 2020 11:58:46 -0800 In-Reply-To: References: <20201118124035.96976-1-dwaipayanray1@gmail.com> <457730448c84136be089748bea69abd2254e3832.camel@perches.com> <754e240d1c88274ce2d94a5b6dbcfff1cc8c9508.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-11-19 at 00:15 +0530, Dwaipayan Ray wrote: > On Thu, Nov 19, 2020 at 12:09 AM Joe Perches wrote: > > > > On Thu, 2020-11-19 at 00:03 +0530, Dwaipayan Ray wrote: > > > On Wed, Nov 18, 2020 at 11:44 PM Joe Perches 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.