Message ID | 20231127151847.52945-1-przemyslaw.kitszel@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3372538vqx; Mon, 27 Nov 2023 10:46:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbE+SUxU3TuEULl5nHOkO2SG7nHFhmwvCRKrTkn1IqiqvGAReiW1O8zh3qzGGTSYgMhaDp X-Received: by 2002:a17:90b:1894:b0:280:23e4:4326 with SMTP id mn20-20020a17090b189400b0028023e44326mr20895233pjb.14.1701110792240; Mon, 27 Nov 2023 10:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701110792; cv=none; d=google.com; s=arc-20160816; b=mCphtvEorj03PVWG+b5Plh6e+17vGqPrQ5YxnyDMkqh7AXrJsP1FaaqFmgfr7q85VH gVwoGIU1kOAcraFAAnuP7uMGUCQIr/9NK5Y2jO6Kaoi+yfq8EgiMZXcpQtI9dS+3DEf/ y8vfRJ/BGwMDH0R7AyrN/RuXqEPNJ8nWY9k37lULYFNRO7GCfieIDkjJ7efvw8aRv6xA hQdWlzAucr6mDqsLfcl2P8Zhr2BY6WFdgfyuZmjPnqwY42uv6w38eLCiWgBwSWx8ptn2 qZZhxINnBjzcrVF/iDN60m9qz+759Dg3UVZ5s7Mc8phnBbG7HLZ57HkCTDxMjR6pa8md 4iqw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xcgPR/W0Qk8pVo8YiAr9/5+HeJXhyENySPmeAW8zspQ=; fh=0Oym5LRsAwjcLW+pRwFQwl7J17c3sCxvXGaz0azWl50=; b=Yf8Ru75RdPHX73BK5+9AhXwhK4g//pEpPN+y9e2zcR7HZmLXz6gsSG9zxDsrKntkN6 WGnPaU9gyZu+Alc6tZ25ZkvjDHVGeNgMB+PoLiAE1LTv0WzfjekmEChiqwjWqRNZZnlC ocxTVjCHRBDthh/BPJa1Nt2jNqSdU1b9uyU4TFjfV5VMC3r8eUG6HBv0sXMo8sHXjLHH aNzuxD0zG4CpQTtNfVK8SA2mDq09O8v8DPmfIdN04rNUkaVTu2oasTtnTLTJ8GYp8P9z giScKbd0YbJBha0rsDiNz+iGLl5IiFIpGcEWO4TzaAn9CC6iN7hgNDBqUVjfyPp1dmXa ZDXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JJ9ex7dY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id pw15-20020a17090b278f00b00285b937aebdsi4402218pjb.74.2023.11.27.10.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 10:46:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JJ9ex7dY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D911C80775B6; Mon, 27 Nov 2023 10:45:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbjK0Spk (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 27 Nov 2023 13:45:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231160AbjK0Spi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Nov 2023 13:45:38 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BCDED4D for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 10:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701110745; x=1732646745; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=w8mCutCC19in3O0r6xFHrBQ9usF9ky+mfdbMKE3QEkw=; b=JJ9ex7dYzN7x+KgHqbGHT0P/tWFrD0uHACj79sV1GZGovzlqb15eFuDa ipz4mehlIbCdXNyWWdIKUZ+rftJGnVLwZhzwmnrEf5ZebEjNfLtS3abez TmXQ2QH4wBbdlMUU2B0Kiimzb+y0moPumz/D98imZlH/iC8OvEGwoJfcI GJJqJ0NuEMbxoDrX2StbNDIO6oBsUS/u/AC2zp6Z5qDL/xqU6StsEX1VU ntwjM/ZOpE4xf31p7UuxcZavP7HaPo8Ya8Uoxe9nzc5KuhIQwez8C5HvQ suvuxQoG/Ca9gE7M4c1RBoIS0BQ3GTrno4oCIP8VUI/Rsov983pS6RNgg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="372934731" X-IronPort-AV: E=Sophos;i="6.04,231,1695711600"; d="scan'208";a="372934731" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 10:45:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="838800667" X-IronPort-AV: E=Sophos;i="6.04,231,1695711600"; d="scan'208";a="838800667" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga004.fm.intel.com with ESMTP; 27 Nov 2023 10:45:43 -0800 Received: from pkitszel-desk.tendawifi.com (unknown [10.255.201.71]) by irvmail002.ir.intel.com (Postfix) with ESMTP id CA049434C1; Mon, 27 Nov 2023 15:19:06 +0000 (GMT) From: Przemek Kitszel <przemyslaw.kitszel@intel.com> To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>, linux-kernel@vger.kernel.org Cc: Jacob Keller <jacob.e.keller@intel.com>, Dwaipayan Ray <dwaipayanray1@gmail.com>, Lukas Bulwahn <lukas.bulwahn@gmail.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com> Subject: [PATCH] checkpatch: don't complain on _Static_assert and _Generic use Date: Mon, 27 Nov 2023 16:18:47 +0100 Message-Id: <20231127151847.52945-1-przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 10:45:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783743950505586992 X-GMAIL-MSGID: 1783743950505586992 |
Series |
checkpatch: don't complain on _Static_assert and _Generic use
|
|
Commit Message
Przemek Kitszel
Nov. 27, 2023, 3:18 p.m. UTC
Improve CamelCase recognition logic to avoid reporting on _Static_assert()
and _Generic() use.
Other C keywords, such as _Bool, are intentionally omitted, as those
should be rather avoided in new source code.
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
scripts/checkpatch.pl | 2 ++
1 file changed, 2 insertions(+)
Comments
On Mon, 2023-11-27 at 16:18 +0100, Przemek Kitszel wrote: > Improve CamelCase recognition logic to avoid reporting on _Static_assert() > and _Generic() use. > > Other C keywords, such as _Bool, are intentionally omitted, as those > should be rather avoided in new source code. [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -5839,6 +5839,8 @@ sub process { > #CamelCase > if ($var !~ /^$Constant$/ && > $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && > +#Ignore C keywords > + $var !~ /_Static_assert|_Generic/ && You'll need $var != /^(?:_Static_assert|_Generic)$/ && to avoid words that contain either > #Ignore some autogenerated defines and enum values > $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ && > #Ignore Page<foo> variants
On 11/28/23 01:46, Joe Perches wrote: > On Mon, 2023-11-27 at 16:18 +0100, Przemek Kitszel wrote: >> Improve CamelCase recognition logic to avoid reporting on _Static_assert() >> and _Generic() use. >> >> Other C keywords, such as _Bool, are intentionally omitted, as those >> should be rather avoided in new source code. > [] >> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > [] >> @@ -5839,6 +5839,8 @@ sub process { >> #CamelCase >> if ($var !~ /^$Constant$/ && >> $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && >> +#Ignore C keywords >> + $var !~ /_Static_assert|_Generic/ && > > You'll need > > $var != /^(?:_Static_assert|_Generic)$/ && > > to avoid words that contain either you are correct, thanks also good to use non-capturing group :) I will resend after usual 24h > > >> #Ignore some autogenerated defines and enum values >> $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ && >> #Ignore Page<foo> variants >
On Tue, 2023-11-28 at 11:25 +0100, Przemek Kitszel wrote: > On 11/28/23 01:46, Joe Perches wrote: > > On Mon, 2023-11-27 at 16:18 +0100, Przemek Kitszel wrote: > > > Improve CamelCase recognition logic to avoid reporting on _Static_assert() > > > and _Generic() use. > > > > > > Other C keywords, such as _Bool, are intentionally omitted, as those > > > should be rather avoided in new source code. > > [] > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > [] > > > @@ -5839,6 +5839,8 @@ sub process { > > > #CamelCase > > > if ($var !~ /^$Constant$/ && > > > $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && > > > +#Ignore C keywords > > > + $var !~ /_Static_assert|_Generic/ && > > > > You'll need > > > > $var != /^(?:_Static_assert|_Generic)$/ && > > > > to avoid words that contain either > > you are correct, thanks > > also good to use non-capturing group :), for Well mostly correct minus the mindless typing of != instead of !~
On Tue, 2023-11-28 at 11:25 +0100, Przemek Kitszel wrote: > On 11/28/23 01:46, Joe Perches wrote: > > On Mon, 2023-11-27 at 16:18 +0100, Przemek Kitszel wrote: > > > Improve CamelCase recognition logic to avoid reporting on _Static_assert() > > > and _Generic() use. > > > > > > Other C keywords, such as _Bool, are intentionally omitted, as those > > > should be rather avoided in new source code. > > [] > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > [] > > > @@ -5839,6 +5839,8 @@ sub process { > > > #CamelCase > > > if ($var !~ /^$Constant$/ && > > > $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && > > > +#Ignore C keywords > > > + $var !~ /_Static_assert|_Generic/ && > > > > You'll need > > > > $var != /^(?:_Static_assert|_Generic)$/ && Hi again. btw: Looks like adding _Pragma would be useful too. $ git grep -ohP '\b_\w+' -- '*.[ch]' | \ sort | uniq -c | sort -rn | \ grep -P '[a-z][A-Z]|[A-Z][a-z]' | \ head -30 377 __Value 206 __pH2CCmd 152 __pTxDesc 78 _Pragma 54 __pRxDesc 52 __pRxStatusDesc 50 _Generic 48 _Static_assert 41 _PyUnicode_FromString 30 _pEleStart 29 _PyLong_FromLong 26 _NonStandardParameter 24 _txOff 24 _TransportAddress 23 _txOn 23 _Bool 22 _Lxx 21 _Exx 19 _min_uV 18 _StateArray 18 _NonClockInfoArray 18 _ClockInfoArray 16 _8Mx32 16 _32Mx16 16 _16Mx32 16 _16Mx16 15 _REGIc 13 _step_uV 13 _Set_Drv_Extra 13 __PageMovable
On 27/11/2023 16.18, Przemek Kitszel wrote: > Improve CamelCase recognition logic to avoid reporting on _Static_assert() > and _Generic() use. > _Generic I understand, because that can reasonably be used in new macros. But is there ever any reason for introducing new uses of _Static_assert when we already have the static_assert() wrapper? Shouldn't people use that instead of the raw keyword? > Other C keywords, such as _Bool, are intentionally omitted, as those > should be rather avoided in new source code. ... in exactly the same way that we have 'typedef _Bool bool;' and then prefer people to spell it 'bool'. Rasmus
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7d16f863edf1..7f01bc8be2de 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5839,6 +5839,8 @@ sub process { #CamelCase if ($var !~ /^$Constant$/ && $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && +#Ignore C keywords + $var !~ /_Static_assert|_Generic/ && #Ignore some autogenerated defines and enum values $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ && #Ignore Page<foo> variants