Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp158166pxu; Sun, 22 Nov 2020 03:37:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFKckLPOcB0aNIjOzSbg1yKXdiQp0AXPzFV1sPl/rh2lFLrXPGMNwVRHyIRCKVGDqOYChw X-Received: by 2002:a05:6402:cbb:: with SMTP id cn27mr6267239edb.275.1606045068719; Sun, 22 Nov 2020 03:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606045068; cv=none; d=google.com; s=arc-20160816; b=ZQB3SEXMOy2kdujalMyjvd4FAsMlQaCLutbTX3O1PGg3jxJoWeztk/D0ywBSU1HzDD Mm68YCJazs/r6SgIGMkeBXFmkjDK0JuLNsnb6WVixBEAQuruLVOfvVgI+yjbtjw/Zm+v sslZ12oz60hXJW3U0VKmxhkyfPBZ7n4+EQwGHUhv/urHdZIRlTjOuyE88X0xH+/rT+K/ SX9vJFgZ2sM+j6CfWkzoDqfK/cPKmdE1lmsxvKg4kZDK8z1c/GrzE5hTFs9TNgBDDhDL ZQpgRMSNFg0zLE0WfmvJeEloahc8I6Ww1xFwN1hVk3f51I6m1baReHu1jQGlzS5AmXxI kdZg== 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=vJuprQNNS8hcaOGNwnd2b1CWCOkW/K104/qMgsuNbXQ=; b=x4CkpenrEy31EkL35IWT77BUXoA1lRbKlhbtdXbXeI9B0haPiPaBOTV1O+RMkOG3Ne 9itnf/d5mGLdDjjEhhk+cI6ezxv56ZOj8FQl09T/Dty1EV7AyHJoHMp2VogFOOE1lbEo AbRfdvnbzZzSBd2VY4z2XpxfEjOeSFHpGd3IiUxLCk3cLjcstXe5wHIcbaQjVo1DcqGv mXwPeLgxisR1WFBmYWJKYO81Zj10zFt0/eCbBNSJe73+i8cIRaTdr6jFgD2XrRrflYqI ZjybZR3tcewWBDUggBf6BDbzwrVLyX7EXvB3b30MTqtDqz2a9qQkWgrQOhzPnXa+b7iu WUKA== 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 k5si4769781ejk.655.2020.11.22.03.36.58; Sun, 22 Nov 2020 03:37:48 -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 S1727663AbgKVLc5 (ORCPT + 99 others); Sun, 22 Nov 2020 06:32:57 -0500 Received: from smtprelay0007.hostedemail.com ([216.40.44.7]:49308 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727373AbgKVLc4 (ORCPT ); Sun, 22 Nov 2020 06:32:56 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id 3C55B248D; Sun, 22 Nov 2020 11:32:55 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:968:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2197:2199:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3353:3622:3653:3865:3866:3867:3868:3870:3871:3872:4321:5007:7903:10004:10400:10848:11232:11658:11914:12297:12438:12555:12740:12895:13069:13161:13229:13311:13357:13439:13894:14181:14659:14721:21080:21221:21451:21627:21774:30030:30054:30070: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: jelly52_1906f722735c X-Filterd-Recvd-Size: 2531 Received: from XPS-9350.home (unknown [47.151.128.180]) (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA; Sun, 22 Nov 2020 11:32:54 +0000 (UTC) Message-ID: <368300090d93ad66f7fb19076d076d4321a04c42.camel@perches.com> Subject: Re: [PATCH v5] checkpatch: add fix option for LOGICAL_CONTINUATIONS From: Joe Perches To: Aditya Srivastava Cc: lukas.bulwahn@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org Date: Sun, 22 Nov 2020 03:32:53 -0800 In-Reply-To: <20201122111025.17978-1-yashsri421@gmail.com> References: <1823e72eb92280d30457dda49e0a0036dee15dd3.camel@perches.com> <20201122111025.17978-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-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 == > > 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 '+') Not quite yet. > changes in v5: improve regex for comment and line end with '$;' [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -3553,8 +3553,17 @@ 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 =~ /^\+/) { > + # add logical operator to the previous line, remove from current line > + if ($prevline =~ /[\s$;]*$/) { This if is misleading as it will always match at least the EOL > + my $line_end = substr($prevrawline, $-[0]); > + $fixed[$fixlinenr - 1] =~ s/\Q$line_end\E/ $operator$line_end/; It makes it seem as if this part is only done when the test is true. The test is always true.