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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 5C95EC4727E for ; Thu, 1 Oct 2020 15:36:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 284BD206C1 for ; Thu, 1 Oct 2020 15:36:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eAIryjrG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732755AbgJAPg5 (ORCPT ); Thu, 1 Oct 2020 11:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732104AbgJAPgr (ORCPT ); Thu, 1 Oct 2020 11:36:47 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37F8EC0613D0 for ; Thu, 1 Oct 2020 08:36:46 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id z26so5993608oih.12 for ; Thu, 01 Oct 2020 08:36:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KTRcLiitCGxtErYo95DQsuhS+3OUv5XK3IV763QSggk=; b=eAIryjrGkerzMGunb1ZsmgjTEM6lxDD9ynZkPH6JSZRoOCVtbiBQ9lnOdtK1vRhDda iV2Uwnxf7YD4ZzGTXuc1D91QRjfrGEmJlykSRyYduyZ7LvfCLRWNayoLerQVmPpV7XLI ZhNj8NBOmSJPfd89OtYYnxCdzkKyxsoILt0Y1ZCcujnXmQqqBB/zRbTszNS4gGeGsRI7 LsmSikTfFgOXC+HBrTsOkmJbCwFguMFRbV8oeWtcQ59XmYERg9oTjo3HiXXgJ5IOhJH1 YPN2NYuAaSh0JvTQmMBXmD0q1YndiHnf62j0WZYkOXUI2n/3JxMf57CMFilRWJKLj8oB DbFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KTRcLiitCGxtErYo95DQsuhS+3OUv5XK3IV763QSggk=; b=IF6Ct0Fa0Fzpescdu8mBUl8HHa+k1Cbd4MUarTeCMTDx89GFIV92NK+vZHwU4huetk oiMkzB0X2RdxPGI6GIDrTkvgJcdGsSDaHJmhOSeZ6D8cIPz6MVDvbl2Fpe38sMzlXH9a TOo0OgX3jQLGtb5Z2hkjH3r2/+XLeuWhD5d8KbkIjIIr119opjc8SmdF88nmv+t/mgmR 1NiI8WyB0tIg7GeOFvFMRSETRnRduCwehNifwzYv3Rmg821cVaeIaZLAQ2z4ap0zksid JJVXOcv6rsWi+E0YJbT+VaQZ1TpJh5xYePgGNelI868LaPWEY6u4cD6p0UKm7B2BVx1g t9aA== X-Gm-Message-State: AOAM533jAYdmVeYGo5EPg9jsqLu/TYwQLGgPsB1IePuxpa1y6p+ortGR KoVuKXGmZQCTdYsGtnj2h7lmI0u9ADB+3yQ6VRcNPbQ0A4OJkQ== X-Google-Smtp-Source: ABdhPJxpPLsfUZNUyhh5FlvHaLwRFS9ey7i+2W4qyQeVK5y8yLqt8zz98x9DwIGkY+BvHmS93cOgBJdKSmLm0uUu3cU= X-Received: by 2002:a05:6808:6:: with SMTP id u6mr347726oic.74.1601566605366; Thu, 01 Oct 2020 08:36:45 -0700 (PDT) MIME-Version: 1.0 References: <20201001103314.136645-1-dwaipayanray1@gmail.com> <8e110121c89414ab1601071868dbcf410195a209.camel@perches.com> <361bda20762efce0e374bd2ba7c82d1c64628a67.camel@perches.com> In-Reply-To: From: Dwaipayan Ray Date: Thu, 1 Oct 2020 21:06:22 +0530 Message-ID: Subject: Re: [PATCH RFC] checkpatch: fix multi-statement macro checks To: Joe Perches Cc: linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Lukas Bulwahn Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > All I'm trying to point out to you is that $Constant\s*$Constant > > isn't a proper test as the first $Constant will pull the test > > entire sequence of digits and the second $Constant will not be > > met. > > > > It may take some conversion of the collapsing of the dstat > > block to work appropriately > > > > > > # Flatten any parentheses and braces > > while ($dstat =~ s/\([^\(\)]*\)/1/ || > > $dstat =~ s/\{[^\{\}]*\}/1/ || > > $dstat =~ s/.\[[^\[\]]*\]/1/) > > { > > } > > > > Maybe the /1/ should be / 1 / but I didn't look to see what > > happens to the exclusion tests below that. > > I think your patch would work well enough if the /1/ bits > here were simply changed to /1u/. > > 1 is a $Constant as it's just a number. > 11 though is also a $Constant. > 1u is also a $Constant but it stops the acquisition of > digits that 11 would not and the sequence of > "while1u1u" should match your newly introduced test > of $Constant\s*$Constant as "while11" would not match. > > Hi, That's an amazing idea! I tried it and this time it seems to detect it properly. Also this fixes the similar case in for(...) {...}. It should not have any side effects also for other checks. Pretty amazing. I will rewrite the patch with your suggestion and send it back. Thanks, Dwaipayan.