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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 0BE66C63697 for ; Sat, 21 Nov 2020 12:10:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6EF222226 for ; Sat, 21 Nov 2020 12:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727591AbgKUMKc (ORCPT ); Sat, 21 Nov 2020 07:10:32 -0500 Received: from smtprelay0030.hostedemail.com ([216.40.44.30]:39332 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727191AbgKUMKc (ORCPT ); Sat, 21 Nov 2020 07:10:32 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id BB7C0837F24A; Sat, 21 Nov 2020 12:10:30 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: drain07_1a158e527354 X-Filterd-Recvd-Size: 2923 Received: from XPS-9350.home (unknown [47.151.128.180]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Sat, 21 Nov 2020 12:10:29 +0000 (UTC) Message-ID: Subject: Re: [PATCH v4] checkpatch: add fix option for ASSIGNMENT_CONTINUATIONS From: Joe Perches To: Aditya Srivastava , Andrew Morton Cc: lukas.bulwahn@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Date: Sat, 21 Nov 2020 04:10:28 -0800 In-Reply-To: <20201121120407.22942-1-yashsri421@gmail.com> References: <1d7692d0-359f-6b6a-32d4-1627ebd8b100@gmail.com> <20201121120407.22942-1-yashsri421@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 Sat, 2020-11-21 at 17:34 +0530, Aditya Srivastava wrote: > Currently, checkpatch warns us if an assignment operator is placed > at the start of a line and not at the end of previous line. Right, thanks. Acked-by: Joe Perches > > E.g., running checkpatch on commit 8195b1396ec8 ("hv_netvsc: fix > deadlock on hotplug") reports: > > CHECK: Assignment operator '=' should be on the previous line > + struct netvsc_device *nvdev > + = container_of(w, struct netvsc_device, subchan_work); > > Provide a simple fix by appending assignment operator to the previous > line and removing from the current line, if both the lines are additions > (ie start with '+') > > Signed-off-by: Aditya Srivastava > --- > Changes in v2: > add check if both the lines are additions (ie start with '+') > > Changes in v3: > quote $operator; test with division assignment operator ('/=') > > Changes in v4: > fix incorrect use of quote > >  scripts/checkpatch.pl | 10 ++++++++-- >  1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 2749f32dffe9..d4c8d42cb13e 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -3533,8 +3533,14 @@ sub process { >   > >  # check for assignments on the start of a line >   if ($sline =~ /^\+\s+($Assignment)[^=]/) { > - CHK("ASSIGNMENT_CONTINUATIONS", > - "Assignment operator '$1' should be on the previous line\n" . $hereprev); > + my $operator = $1; > + if (CHK("ASSIGNMENT_CONTINUATIONS", > + "Assignment operator '$1' should be on the previous line\n" . $hereprev) && > + $fix && $prevrawline =~ /^\+/) { > + # add assignment operator to the previous line, remove from current line > + $fixed[$fixlinenr - 1] .= " $operator"; > + $fixed[$fixlinenr] =~ s/\Q$operator\E\s*//; > + } >   } >   > >  # check for && or || at the start of a line