Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1584736pxb; Fri, 1 Oct 2021 14:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx37qZq3SZ+c0RP2ROHose8V5B9oJfCZP4Z/A49UhOb02nbtYMjWBA+QG79Y0Atf1J9R9tj X-Received: by 2002:a17:906:31d7:: with SMTP id f23mr128841ejf.190.1633122397585; Fri, 01 Oct 2021 14:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633122397; cv=none; d=google.com; s=arc-20160816; b=nhoaON0V9dpCe/eEcCUIHcGO4q901Y0J7m3k4Twoq2qTLQSO+YmgJQi8GSyGw+dXhS cHN9JLPxG4Ee75vj5n8r+Wct3SsCKU9dj1WoyUor8xRTnLaf2xuoV+/F4uFG83S9XyFk VBEhhCZEzgW9YDSL82CLflrGMgkkc5SAJHUAf8I4TsMMNSd9Nvnv/NXsAskcN7uc+u8v YgR6qZYiZmZU+NUr57Q+FHlRAOGMCywgsZGAwgAjhtcybKKJKp8ZK2VvEF9Jcs8+nbcr m4KDczF6tsS9fw9zBR98w45j7ljTryMpCdiN+OQMRxQcWmOOujgf/qyOVC+irRTWZj9l AE9w== 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=BOiZnIibe3yiBZd09H1g/CENdPtMCJXaPRsHcj/8/Lg=; b=xlHfsjlwC8n/oGo3USkavrAJ/JY+tA6UEkSAbfTiQIsWtTiN+xokUT33Y8bD1KGVh1 72kwSF7ae4oKQr/K/FsE0oMbyrqCCMThgRqy1sk0og663XK5mT9OwUer+Rw33TwsJGYp YT799m24gH5bXA7/YyLK9zufRCrEH+Vh1Bv6H5yAUyJJ+gMMNs5b7ZLJkFmkR18fnREa C40z0adih+dwO++nwL9mgIoc+S+gL90xgDF5fU43f5KeOya+FQlpD4ShfgdqQeDwjBIE mzf9mn2GAVU+09zHYPbNNoDMo9KtxHIwTXFghEw1mKKsRrGFytjhKCBqukCV8Xh7Z2mw sHAw== 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 13si9046770ejg.193.2021.10.01.14.06.11; Fri, 01 Oct 2021 14:06:37 -0700 (PDT) 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 S1354977AbhJAUYK (ORCPT + 99 others); Fri, 1 Oct 2021 16:24:10 -0400 Received: from smtprelay0193.hostedemail.com ([216.40.44.193]:52488 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229888AbhJAUYJ (ORCPT ); Fri, 1 Oct 2021 16:24:09 -0400 Received: from omf02.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id D3D661802B415; Fri, 1 Oct 2021 20:22:23 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA id EC6441D42F6; Fri, 1 Oct 2021 20:22:22 +0000 (UTC) Message-ID: <91569a87ac55da392fa894e8ad55292b98c558f3.camel@perches.com> Subject: Re: [PATCH] checkpatch: add check for continue statement in UNNECESSARY_ELSE From: Joe Perches To: Utkarsh Verma , Andy Whitcroft Cc: Dwaipayan Ray , Lukas Bulwahn , linux-kernel@vger.kernel.org Date: Fri, 01 Oct 2021 13:22:13 -0700 In-Reply-To: <20211001192628.19179-1-utkarshverma294@gmail.com> References: <20211001190927.GA18097@uver-machine> <20211001192628.19179-1-utkarshverma294@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: EC6441D42F6 X-Spam-Status: No, score=1.67 X-Stat-Signature: m6bekyi3afgc46tzyz46y4jygydzi1ba X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18wKpUgeD3fuGtE65P1O3GH+WpzJXivWjU= X-HE-Tag: 1633119742-206079 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2021-10-02 at 00:56 +0530, Utkarsh Verma wrote: > UNNECESSARY_ELSE only checks for the usage of else after a return or > break. But the same logic is also true for continue statement. > > else used after a continue statement is unnecessary. So add a test > for continue statement also. > > Signed-off-by: Utkarsh Verma > --- > ?scripts/checkpatch.pl | 5 +++-- > ?1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index c27d2312cfc3..f5a911aa6b64 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -4011,15 +4011,16 @@ sub process { > ? > > ?# check indentation of any line with a bare else > ?# (but not if it is a multiple line "if (foo) return bar; else return baz;") > -# if the previous line is a break or return and is indented 1 tab more... > +# if the previous line is a break or continue or return and is indented 1 tab more... > ? if ($sline =~ /^\+([\t]+)(?:}[ \t]*)?else(?:[ \t]*{)?\s*$/) { > ? my $tabs = length($1) + 1; > ? if ($prevline =~ /^\+\t{$tabs,$tabs}break\b/ || > + $prevline =~ /^\+\t{$tabs,$tabs}continue\b/ || I suppose this is ok. I'd generally write this on one line. if ($prevline =~ /^\+\t{$tabs,$tabs}(?:break|continue)\b/ ||