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 9AC4DC5519F for ; Wed, 18 Nov 2020 18:40:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41EB5208C3 for ; Wed, 18 Nov 2020 18:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726619AbgKRSjr (ORCPT ); Wed, 18 Nov 2020 13:39:47 -0500 Received: from smtprelay0082.hostedemail.com ([216.40.44.82]:51182 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726181AbgKRSjq (ORCPT ); Wed, 18 Nov 2020 13:39:46 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id DBB3612C7; Wed, 18 Nov 2020 18:39:45 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: spark29_2f061692733c X-Filterd-Recvd-Size: 2679 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf18.hostedemail.com (Postfix) with ESMTPA; Wed, 18 Nov 2020 18:39:44 +0000 (UTC) Message-ID: <754e240d1c88274ce2d94a5b6dbcfff1cc8c9508.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 10:39:43 -0800 In-Reply-To: References: <20201118124035.96976-1-dwaipayanray1@gmail.com> <457730448c84136be089748bea69abd2254e3832.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: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.