linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values
@ 2022-12-30 19:59 Gerhard Engleder
  2022-12-30 20:31 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Gerhard Engleder @ 2022-12-30 19:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: apw, joe, dwaipayanray1, lukas.bulwahn, Gerhard Engleder

Since commit 4104a20646 enum values like
ETHTOOL_LINK_MODE_Asym_Pause_BIT are ignored. But there are other enums
like ETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored
because of the not matching '1000baseT' substring.

Extend regex to match also substrings like '1000baseT'.

Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 78cc595b98ce..861fa547001e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5780,7 +5780,7 @@ sub process {
 			if ($var !~ /^$Constant$/ &&
 			    $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
 #Ignore some autogenerated defines and enum values
-			    $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ &&
+			    $var !~ /^(?:[A-Z]+_){1,5}([A-Z]{1,3}[a-z]|[0-9]+[a-z]+[A-Z])/ &&
 #Ignore Page<foo> variants
 			    $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
 #Ignore SI style variants like nS, mV and dB
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values
  2022-12-30 19:59 [PATCH] checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values Gerhard Engleder
@ 2022-12-30 20:31 ` Joe Perches
  2022-12-30 21:15   ` Gerhard Engleder
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2022-12-30 20:31 UTC (permalink / raw)
  To: Gerhard Engleder, linux-kernel; +Cc: apw, dwaipayanray1, lukas.bulwahn

On Fri, 2022-12-30 at 20:59 +0100, Gerhard Engleder wrote:
> Since commit 4104a20646 enum values like
> ETHTOOL_LINK_MODE_Asym_Pause_BIT are ignored. But there are other enums
> like ETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored
> because of the not matching '1000baseT' substring.
> 
> Extend regex to match also substrings like '1000baseT'.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5780,7 +5780,7 @@ sub process {
>  			if ($var !~ /^$Constant$/ &&
>  			    $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
>  #Ignore some autogenerated defines and enum values
> -			    $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ &&
> +			    $var !~ /^(?:[A-Z]+_){1,5}([A-Z]{1,3}[a-z]|[0-9]+[a-z]+[A-Z])/ &&

NAK.

This introduces an unnecessary capture group and as well it would also
allow too many other variants that should get a warning.

Try a git grep using that pattern and see if all the matches are
actually what you want to allow

$ git grep -Poh '\b(?:[A-Z]+_){1,5}([A-Z]{1,3}[a-z]|[0-9]+[a-z]+[A-Z])\w*\b' -- '*.[ch]' | \
  sort | uniq -c | sort -rn
...


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values
  2022-12-30 20:31 ` Joe Perches
@ 2022-12-30 21:15   ` Gerhard Engleder
  2022-12-30 23:52     ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Gerhard Engleder @ 2022-12-30 21:15 UTC (permalink / raw)
  To: Joe Perches, linux-kernel; +Cc: apw, dwaipayanray1, lukas.bulwahn

On 30.12.22 21:31, Joe Perches wrote:
> On Fri, 2022-12-30 at 20:59 +0100, Gerhard Engleder wrote:
>> Since commit 4104a20646 enum values like
>> ETHTOOL_LINK_MODE_Asym_Pause_BIT are ignored. But there are other enums
>> like ETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored
>> because of the not matching '1000baseT' substring.
>>
>> Extend regex to match also substrings like '1000baseT'.
> []
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -5780,7 +5780,7 @@ sub process {
>>   			if ($var !~ /^$Constant$/ &&
>>   			    $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
>>   #Ignore some autogenerated defines and enum values
>> -			    $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ &&
>> +			    $var !~ /^(?:[A-Z]+_){1,5}([A-Z]{1,3}[a-z]|[0-9]+[a-z]+[A-Z])/ &&
> 
> NAK.
> 
> This introduces an unnecessary capture group and as well it would also
> allow too many other variants that should get a warning.

A more exact link mode regex [0-9]+base[A-Z0-9]+_(Half|Full) would
eliminate unwanted matches. Shall I extend the existing regex or
would a separate regex with comment be the better choice?

Gerhard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values
  2022-12-30 21:15   ` Gerhard Engleder
@ 2022-12-30 23:52     ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2022-12-30 23:52 UTC (permalink / raw)
  To: Gerhard Engleder, linux-kernel; +Cc: apw, dwaipayanray1, lukas.bulwahn

On Fri, 2022-12-30 at 22:15 +0100, Gerhard Engleder wrote:
> On 30.12.22 21:31, Joe Perches wrote:
> > On Fri, 2022-12-30 at 20:59 +0100, Gerhard Engleder wrote:
> > > Since commit 4104a20646 enum values like
> > > ETHTOOL_LINK_MODE_Asym_Pause_BIT are ignored. But there are other enums
> > > like ETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored
> > > because of the not matching '1000baseT' substring.
> > > 
> > > Extend regex to match also substrings like '1000baseT'.
> > []
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > []
> > > @@ -5780,7 +5780,7 @@ sub process {
> > >   			if ($var !~ /^$Constant$/ &&
> > >   			    $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
> > >   #Ignore some autogenerated defines and enum values
> > > -			    $var !~ /^(?:[A-Z]+_){1,5}[A-Z]{1,3}[a-z]/ &&
> > > +			    $var !~ /^(?:[A-Z]+_){1,5}([A-Z]{1,3}[a-z]|[0-9]+[a-z]+[A-Z])/ &&
> > 
> > NAK.
> > 
> > This introduces an unnecessary capture group and as well it would also
> > allow too many other variants that should get a warning.
> 
> A more exact link mode regex [0-9]+base[A-Z0-9]+_(Half|Full) would
> eliminate unwanted matches. Shall I extend the existing regex or
> would a separate regex with comment be the better choice?

Maybe $var !~ /^ETHTOOL_/


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-30 23:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-30 19:59 [PATCH] checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values Gerhard Engleder
2022-12-30 20:31 ` Joe Perches
2022-12-30 21:15   ` Gerhard Engleder
2022-12-30 23:52     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).