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 F1926C3E8C5 for ; Wed, 18 Nov 2020 18:14:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9EC0D24248 for ; Wed, 18 Nov 2020 18:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726195AbgKRSOz (ORCPT ); Wed, 18 Nov 2020 13:14:55 -0500 Received: from smtprelay0161.hostedemail.com ([216.40.44.161]:54512 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725947AbgKRSOz (ORCPT ); Wed, 18 Nov 2020 13:14:55 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 4E8C28384364; Wed, 18 Nov 2020 18:14:54 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: brick87_4d0cbfa2733c X-Filterd-Recvd-Size: 2134 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Wed, 18 Nov 2020 18:14:53 +0000 (UTC) Message-ID: <457730448c84136be089748bea69abd2254e3832.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@vger.kernel.org, lukas.bulwahn@gmail.com Date: Wed, 18 Nov 2020 10:14:52 -0800 In-Reply-To: <20201118124035.96976-1-dwaipayanray1@gmail.com> References: <20201118124035.96976-1-dwaipayanray1@gmail.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 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 /^\+/ ? > + my $line2 = $rawlines[$ctx_ln - 1]; > + fix_delete_line($ctx_ln - 2, $line1); > + fix_delete_line($ctx_ln - 1, $line2); > + > + my $fixedline = rtrim($line1) . " {"; > + fix_insert_line($ctx_ln - 1, $fixedline); > + $fixedline = $line2; > + $fixedline =~ s/^(.\s*)\{\s*/$1\t/; > + if ($fixedline !~ /^\+\s*$/) { > + fix_insert_line($ctx_ln - 1, $fixedline); > + } > + }