Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3079549pxu; Sun, 29 Nov 2020 14:32:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyq35ISUS5ujqWWwgfY0rfciwXOS2c9+Vr8LbuPtnltfgdp5899hYtTEBUicb11l0/gFhJ+ X-Received: by 2002:a17:906:7118:: with SMTP id x24mr7153769ejj.333.1606689167308; Sun, 29 Nov 2020 14:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606689167; cv=none; d=google.com; s=arc-20160816; b=TwI4SPqNVLhHu5G2FR9uPIFwCVK8cOr4ReDa70HxofnO5Y9DWIS4PWtA1wgPcdu6o9 5Og/a8biAboA5ZFKfdY3nOdssOzXIAC4S+Z+owGNJDlgSC8f4vlxyGjxjaZfVWguvAs3 LdL5Luytat4MNOV2MCYLQbB6y4ke6LsT3TpsuMrY2i/ua4oUzcMeOhAQU/bXgIO+cKjA e/UeyHRXkX6FbwKM5t7gI/FEa1d6v0dXRF6c1OPiMxEldbakIX8iY2oSNfw8Ro+JY6OH 4ERgqciRqaFZgbXsIowK60MWeJPXtZN5wc0vXDqvx+7nTWt+BslcJ6+oS/9GcQxWNlCz ECjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=uaLHqcvnmgtX+te+RAhjBPdxSA9W8kQ1pfQlDUzZ5XE=; b=KO2UhReugI4sYWbvmZzrUuUsmeHZd+TzazF1eTx0UW0q6WHp5oUIcJP6L6I5U6nem5 rlrKtNybKnrb4uj1uw3WSLnnEoebXWBfCIUIZE3McPT8CQeWZkMbUXopgpYvauYAjJf2 PB3fjdZXAw+RvxrUDa/E7Qjqxa1QHTX107wjd4yG+mW8saZwZOyOac1obTI2oQzby6eM Xv0vPdtMbekFL4oTc0xUJJ+QReAUZJEQkc8UelC6Yexfj573xI6DLG7IToJixUZ+U1RG BXzxUuBL5OTl3szFE8BArVY9QGUJzXmvvDJg9IJDjbATnYb5vMC/ogl10qIHA94bCi1c laHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si9908631edt.219.2020.11.29.14.32.13; Sun, 29 Nov 2020 14:32:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726701AbgK2W2L (ORCPT + 99 others); Sun, 29 Nov 2020 17:28:11 -0500 Received: from smtprelay0216.hostedemail.com ([216.40.44.216]:49248 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725950AbgK2W2K (ORCPT ); Sun, 29 Nov 2020 17:28:10 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 63192100E7B40; Sun, 29 Nov 2020 22:27:29 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:334:355:368:369:379:599:800:960:968:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2197:2198:2199:2200:2393:2559:2562:2693:2828:2903:2911:3138:3139:3140:3141:3142:3355:3622:3653:3865:3866:3867:3868:3870:3873:4321:4425:5007:7514:7903:8531:10004:10400:10848:11232:11658:11914:12294:12297:12438:12555:12740:12895:13095:13439:13894:14180:14181:14659:14721:21060:21063:21080:21221:21433:21451:21627:21774:30030:30054:30070:30089:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: wheel10_07047072739c X-Filterd-Recvd-Size: 3936 Received: from XPS-9350.home (unknown [47.151.128.180]) (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA; Sun, 29 Nov 2020 22:27:28 +0000 (UTC) Message-ID: <45c8575f69602a3ad6bc3129ab99905e9f233af0.camel@perches.com> Subject: Re: [PATCH v7] checkpatch: add fix option for LOGICAL_CONTINUATIONS From: Joe Perches To: Aditya , Andrew Morton Cc: lukas.bulwahn@gmail.com, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Date: Sun, 29 Nov 2020 14:27:27 -0800 In-Reply-To: References: <20201123102818.24364-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 Sun, 2020-11-29 at 14:25 +0530, Aditya wrote: > On 23/11/20 3:58 pm, 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. Acked-by: Joe Perches > > > > 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 == > > > > Provide a simple fix by inserting logical operator at the last > > non-comment, non-whitespace char of the 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 the previous line > > > > changes in v4: improve the matching mechanism by matching line termination 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 '$;' > > > > changes in v6: remove if-check; modify commit message > > > > changes in v7: add an extra '$' symbol at '$fixed[$fixlinenr - 1]' regex substitution to ensure match at line end > > > > ?scripts/checkpatch.pl | 12 ++++++++++-- > > ?1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > index 5b1a5a65e69a..fb3c50e0bde2 100755 > > --- a/scripts/checkpatch.pl > > +++ b/scripts/checkpatch.pl > > @@ -3553,8 +3553,16 @@ sub process { > > ? > > > > ?# check for && or || at the start of a line > > ? if ($rawline =~ /^\+\s*(&&|\|\|)/) { > > - CHK("LOGICAL_CONTINUATIONS", > > - "Logical continuations should be on the previous line\n" . $hereprev); > > + my $operator = $1; > > + if (CHK("LOGICAL_CONTINUATIONS", > > + "Logical continuations should be on the previous line\n" . $hereprev) && > > + $fix && $prevrawline =~ /^\+/) { > > + # insert logical operator at last non-comment, non-whitepsace char on previous line > > + $prevline =~ /[\s$;]*$/; > > + my $line_end = substr($prevrawline, $-[0]); > > + $fixed[$fixlinenr - 1] =~ s/\Q$line_end\E$/ $operator$line_end/; > > + $fixed[$fixlinenr] =~ s/\Q$operator\E\s*//; > > + } > > ? } > > ? > > > > ?# check indentation starts on a tab stop > > > > Hi Joe > You probably missed this patch. Please review :) > > Thanks > Aditya