* [PATCH] checkpatch: don't complain on _Static_assert and _Generic use
@ 2023-11-27 15:18 Przemek Kitszel
2023-11-28 0:46 ` Joe Perches
2023-11-29 8:58 ` Rasmus Villemoes
0 siblings, 2 replies; 6+ messages in thread
From: Przemek Kitszel @ 2023-11-27 15:18 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches, linux-kernel
Cc: Jacob Keller, Dwaipayan Ray, Lukas Bulwahn, Przemek Kitszel
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(+)
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
--
2.38.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] checkpatch: don't complain on _Static_assert and _Generic use
2023-11-27 15:18 [PATCH] checkpatch: don't complain on _Static_assert and _Generic use Przemek Kitszel
@ 2023-11-28 0:46 ` Joe Perches
2023-11-28 10:25 ` Przemek Kitszel
2023-11-29 8:58 ` Rasmus Villemoes
1 sibling, 1 reply; 6+ messages in thread
From: Joe Perches @ 2023-11-28 0:46 UTC (permalink / raw)
To: Przemek Kitszel, Andy Whitcroft, linux-kernel
Cc: Jacob Keller, Dwaipayan Ray, Lukas Bulwahn
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] checkpatch: don't complain on _Static_assert and _Generic use
2023-11-28 0:46 ` Joe Perches
@ 2023-11-28 10:25 ` Przemek Kitszel
2023-11-28 10:52 ` Joe Perches
2023-11-29 0:48 ` Joe Perches
0 siblings, 2 replies; 6+ messages in thread
From: Przemek Kitszel @ 2023-11-28 10:25 UTC (permalink / raw)
To: Joe Perches, Andy Whitcroft, linux-kernel
Cc: Jacob Keller, Dwaipayan Ray, Lukas Bulwahn
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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] checkpatch: don't complain on _Static_assert and _Generic use
2023-11-28 10:25 ` Przemek Kitszel
@ 2023-11-28 10:52 ` Joe Perches
2023-11-29 0:48 ` Joe Perches
1 sibling, 0 replies; 6+ messages in thread
From: Joe Perches @ 2023-11-28 10:52 UTC (permalink / raw)
To: Przemek Kitszel, Andy Whitcroft, linux-kernel
Cc: Jacob Keller, Dwaipayan Ray, Lukas Bulwahn
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 !~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] checkpatch: don't complain on _Static_assert and _Generic use
2023-11-28 10:25 ` Przemek Kitszel
2023-11-28 10:52 ` Joe Perches
@ 2023-11-29 0:48 ` Joe Perches
1 sibling, 0 replies; 6+ messages in thread
From: Joe Perches @ 2023-11-29 0:48 UTC (permalink / raw)
To: Przemek Kitszel, Andy Whitcroft, linux-kernel
Cc: Jacob Keller, Dwaipayan Ray, Lukas Bulwahn
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] checkpatch: don't complain on _Static_assert and _Generic use
2023-11-27 15:18 [PATCH] checkpatch: don't complain on _Static_assert and _Generic use Przemek Kitszel
2023-11-28 0:46 ` Joe Perches
@ 2023-11-29 8:58 ` Rasmus Villemoes
1 sibling, 0 replies; 6+ messages in thread
From: Rasmus Villemoes @ 2023-11-29 8:58 UTC (permalink / raw)
To: Przemek Kitszel, Andy Whitcroft, Joe Perches, linux-kernel
Cc: Jacob Keller, Dwaipayan Ray, Lukas Bulwahn
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-29 8:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-27 15:18 [PATCH] checkpatch: don't complain on _Static_assert and _Generic use Przemek Kitszel
2023-11-28 0:46 ` Joe Perches
2023-11-28 10:25 ` Przemek Kitszel
2023-11-28 10:52 ` Joe Perches
2023-11-29 0:48 ` Joe Perches
2023-11-29 8:58 ` Rasmus Villemoes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®