checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values
PATCH 1/1 checkpatch: Ignore ETHTOOL_LINK_MODE_ enum values
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'.
--- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
@@ -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
Signature · 1 line
2.30.2
Quoted 6 lines · Gerhard Engleder
Since commit
4104a20646enum values likeETHTOOL_LINK_MODE_Asym_Pause_BITare ignored. But there are other enums likeETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored because of the not matching '1000baseT' substring.Extend regex to match also substrings like '1000baseT'.
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
scripts/checkpatch.pl sub process { · line 5783
Quoted 6 lines
scripts/checkpatch.pl +1
-1@@ -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
...Quoted 19 lines · Joe Perches
Quoted 6 lines · Gerhard Engleder
Since commit
4104a20646enum values likeETHTOOL_LINK_MODE_Asym_Pause_BITare ignored. But there are other enums likeETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored because of the not matching '1000baseT' substring.Extend regex to match also substrings like '1000baseT'.
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0[]
scripts/checkpatch.pl sub process { · line 5783
Quoted 6 lines
scripts/checkpatch.pl +1
-1@@ -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.
Quoted 2 lines
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
Joe Perches
maintainerQuoted 20 lines · Gerhard Engleder
Quoted 19 lines · Joe Perches
Quoted 6 lines · Gerhard Engleder
Since commit
4104a20646enum values likeETHTOOL_LINK_MODE_Asym_Pause_BITare ignored. But there are other enums likeETHTOOL_LINK_MODE_1000baseT_Full_BIT, which are not ignored because of the not matching '1000baseT' substring.Extend regex to match also substrings like '1000baseT'.
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0[]
scripts/checkpatch.pl sub process { · line 5783
Quoted 6 lines
scripts/checkpatch.pl +1
-1@@ -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.
Quoted 6 lines
Quoted 2 lines
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_/