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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 855CFC2B9F4 for ; Mon, 28 Jun 2021 07:52:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EA6861990 for ; Mon, 28 Jun 2021 07:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232383AbhF1Hyn (ORCPT ); Mon, 28 Jun 2021 03:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbhF1Hyl (ORCPT ); Mon, 28 Jun 2021 03:54:41 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 630CEC061574 for ; Mon, 28 Jun 2021 00:52:15 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id l21-20020a05600c1d15b02901e7513b02dbso7648068wms.2 for ; Mon, 28 Jun 2021 00:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=26Jo7b1uCcAsRn7cA2/UX0PAm6+96/bC+S5nPYvJDSs=; b=d/FLb0ur37yuvi/he3rJ4++VzOSF9BgsmO7AnOKJaMPVCqDjbfyONooNEP62zZFOlu 2NyFCToeZGGdFkXuf6bOuhgWGJD7Vc1V4GKMroCPY6Gz7Gd7CUh9IGASAPhP+sG1M1OM RGvibommRmMaBdxFs996P+K50jJGrgqOLdVhaEP7KqaU4XeWopFwzmljenckuB41bscq PRH2FvQ8zGpaTQaw7ylPTYUuQB9KI5ccN5aMXpto+GZMut7P62R/EMDSjHWADEvimZUZ /3I394wdpriRggUihQq42fGvGf8ej3ZcIu139+J5iq7Z+HrsHANwdL7aE6oXU9WOWyOx Xb/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=26Jo7b1uCcAsRn7cA2/UX0PAm6+96/bC+S5nPYvJDSs=; b=rk5oDWRlAcizPOg5EVzyywZZ/NOC5D4zkvxpwxoUGhMCMkPz8kDErzQ7gEN+J7yqEu N6CtsKQ9qa0YSM1ZJdNBVwmE3jRu1dAPjil55GctxHwsfmhp+WBvPvV74ikJ6gUszYHD bFl3CzDvh6MqXIjTPmIPuDDb5dUPLElGHaoIiV6BYMhFLzqYmvwm5JZjL7C5s6zof3TN 1S6POFqEi0f8UZyajGOlBvnZVaN90tU+U6EzAE0qH2M1mcOXDaFgvQlAGnOscX8rwMj+ 212+MnjzJGZTo065eNmRh1ECqG7VWpZ6KH4tC52ulgkno1UNQpeQ8IRCHRzjN5X5sc5C jltg== X-Gm-Message-State: AOAM530Qvhzsyx3tJnyEZRyHKq+rJAObXOAKZ0fDNemhXPbtmnb0iy2O 1Gdxxasu1J1GpnyVgLL5ICcfUM2XIng= X-Google-Smtp-Source: ABdhPJyEs4DQY1q9IDG/fz/JGbGFyvIJQcb6b1lWA7LabpLizJxLmgFKid93Qh6/jk5JTWQ3WRrRgg== X-Received: by 2002:a7b:c104:: with SMTP id w4mr24726348wmi.87.1624866733991; Mon, 28 Jun 2021 00:52:13 -0700 (PDT) Received: from [10.8.0.150] ([195.53.121.100]) by smtp.gmail.com with ESMTPSA id e12sm14094999wrw.34.2021.06.28.00.52.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Jun 2021 00:52:13 -0700 (PDT) Subject: Re: [PATCH v2] checkpatch: Fix regex for do without braces To: Dwaipayan Ray , joe@perches.com, apw@canonical.com Cc: lukas.bulwahn@gmail.com, linux-kernel@vger.kernel.org References: <20210627184909.6000-1-dwaipayanray1@gmail.com> From: "Alejandro Colomar (man-pages)" Message-ID: Date: Mon, 28 Jun 2021 09:52:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210627184909.6000-1-dwaipayanray1@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/27/21 8:49 PM, Dwaipayan Ray wrote: > The regular expression for detecting do without braces > also passes when checkpatch encounters the "double" > keyword. This causes wrong recalculation of $stat in > checkpatch which can cause false positives. > > Fix the regex to avoid the above. Also update the comments > for the check. > > Reported-by: Alejandro Colomar > Signed-off-by: Dwaipayan Ray Reviewed-by: Alejandro Colomar Tested-by: Alejandro Colomar (is Acked-by/Reviewed-by implied by Tested-by?) > --- > > Changes in v2: > - Check word boundary on both sides of do > > scripts/checkpatch.pl | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 8d19beca3538..64036e7eff71 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -5488,9 +5488,8 @@ sub process { > } > } > > -# Check for illegal assignment in if conditional -- and check for trailing > -# statements after the conditional. > - if ($line =~ /do\s*(?!{)/) { > +# If we have sufficient context detect and handle do without braces ({). s/context detect/context, detect/ > + if ($line =~ /\bdo\b\s*(?!{)/) { > ($stat, $cond, $line_nr_next, $remain_next, $off_next) = > ctx_statement_block($linenr, $realcnt, 0) > if (!defined $stat); > @@ -5511,6 +5510,9 @@ sub process { > $offset} = 1; > } > } > + > +# Check for illegal assignment in if conditional -- and check for trailing > +# statements after the conditional. > if (!defined $suppress_whiletrailers{$linenr} && > defined($stat) && defined($cond) && > $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) { > -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/