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 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 6DE66C5519F for ; Sun, 22 Nov 2020 11:32:04 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D62E7208C3 for ; Sun, 22 Nov 2020 11:32:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D62E7208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7CD9086A95; Sun, 22 Nov 2020 11:32:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CW1eHbzUtnFz; Sun, 22 Nov 2020 11:32:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 08C2E86A3F; Sun, 22 Nov 2020 11:32:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EDA5CC0891; Sun, 22 Nov 2020 11:32:01 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id EAB47C0052 for ; Sun, 22 Nov 2020 11:31:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DEF6185F7F for ; Sun, 22 Nov 2020 11:31:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lN4gbcZS1nxA for ; Sun, 22 Nov 2020 11:31:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by fraxinus.osuosl.org (Postfix) with ESMTPS id F35F785F69 for ; Sun, 22 Nov 2020 11:31:58 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id B32FC182CED28; Sun, 22 Nov 2020 11:31:57 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: rule91_3104a872735c X-Filterd-Recvd-Size: 3330 Received: from XPS-9350.home (unknown [47.151.128.180]) (Authenticated sender: joe@perches.com) by omf15.hostedemail.com (Postfix) with ESMTPA; Sun, 22 Nov 2020 11:31:56 +0000 (UTC) Message-ID: <9ede7de2b1da90e025e64c86ffbcc7f44843de69.camel@perches.com> From: Joe Perches To: Aditya Srivastava Date: Sun, 22 Nov 2020 03:31:55 -0800 In-Reply-To: <20201122111025.17978-1-yashsri421@gmail.com> References: <1823e72eb92280d30457dda49e0a0036dee15dd3.camel@perches.com> <20201122111025.17978-1-yashsri421@gmail.com> User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [Linux-kernel-mentees] [PATCH v5] checkpatch: add fix option for LOGICAL_CONTINUATIONS X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" On Sun, 2020-11-22 at 16:40 +0530, Aditya Srivastava wrote: > Currently, checkpatch warns if logical continuations are placed at the > start of a line and not at the end of previous line. > = > E.g., running checkpatch on commit 3485507fc272 ("staging: > bcm2835-camera: Reduce length of enum names") reports: > = > CHECK:LOGICAL_CONTINUATIONS: Logical continuations should be on the > previous line > + if (!ret > + && camera_port =3D=3D > = > Provide a simple fix by adding logical operator at the end of previous > line and removing from current line, if both the lines are additions > (ie start with '+') > = > Signed-off-by: Aditya Srivastava > --- > changes in v2: quote $operator at substitution > = > changes in v3: add a check for previous line ending with comment; > If so, insert $operator at the last non-comment, non-whitespace char of t= he previous line > = > changes in v4: improve the matching mechanism by matching line terminatio= n at comment or white space; > insert the operator before comments (if any) separated by a whitespace; > append the comment and its pre-whitespace after the inserted operator (if= comment was present), > ie if no comment was present nothing will be inserted after the operator > = > changes in v5: improve regex for comment and line end with '$;' > = > =A0scripts/checkpatch.pl | 13 +++++++++++-- > =A01 file changed, 11 insertions(+), 2 deletions(-) > = > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 5b1a5a65e69a..708a56f31466 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -3553,8 +3553,17 @@ sub process { > =A0 > = > =A0# check for && or || at the start of a line > =A0 if ($rawline =3D~ /^\+\s*(&&|\|\|)/) { > - CHK("LOGICAL_CONTINUATIONS", > - "Logical continuations should be on the previous line\n" . $herep= rev); > + my $operator =3D $1; > + if (CHK("LOGICAL_CONTINUATIONS", > + "Logical continuations should be on the previous line\n" . $hereprev= ) && > + $fix && $prevrawline =3D~ /^\+/) { > + # add logical operator to the previous line, remove from current line > + if ($prevline =3D~ /[\s$;]*$/) { > + my $line_end =3D substr($prevrawline, $-[0]); > + $fixed[$fixlinenr - 1] =3D~ s/\Q$line_end\E/ $operator$line_end/; > + } > + $fixed[$fixlinenr] =3D~ s/\Q$operator\E\s*//; > + } > =A0 } > =A0 > = > =A0# check indentation starts on a tab stop _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees