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 9D536C2D0E4 for ; Fri, 20 Nov 2020 17:26:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D6C12225B for ; Fri, 20 Nov 2020 17:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728584AbgKTR0z (ORCPT ); Fri, 20 Nov 2020 12:26:55 -0500 Received: from smtprelay0023.hostedemail.com ([216.40.44.23]:51214 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728366AbgKTR0z (ORCPT ); Fri, 20 Nov 2020 12:26:55 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 4E7F3181D3030; Fri, 20 Nov 2020 17:26:54 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: stick91_05052de2734d X-Filterd-Recvd-Size: 3077 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA; Fri, 20 Nov 2020 17:26:53 +0000 (UTC) Message-ID: <08f164e93dc40e066e81c4021485d27d5ad5a6b7.camel@perches.com> Subject: Re: [PATCH v3] checkpatch: add fix option for ASSIGNMENT_CONTINUATIONS From: Joe Perches To: Aditya Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com Date: Fri, 20 Nov 2020 09:26:52 -0800 In-Reply-To: <48f56f40-a365-faac-542d-0e120fcf4365@gmail.com> References: <20201117171856.13284-1-yashsri421@gmail.com> <48f56f40-a365-faac-542d-0e120fcf4365@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 Fri, 2020-11-20 at 16:11 +0530, Aditya wrote: > On 17/11/20 10:48 pm, 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. > > > > 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 ('/=') > > > >  scripts/checkpatch.pl | 10 ++++++++-- > >  1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > index c9aaaa443265..d5bc4d8e4f6c 100755 > > --- a/scripts/checkpatch.pl > > +++ b/scripts/checkpatch.pl > > @@ -3542,8 +3542,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/$operator\s*//; > > + } > >   } > >   > > > >  # check for && or || at the start of a line > > > > Hi Joe > This patch probably got missed. Please review :) Did you look at $Assignment? Did you see it can be /= ? If it is, what happens in the $fixed[$fixlinenr] line?