History

checkpatch: allow certain SI units with three characters

Checkpatch flags CamelCase identifiers in strict mode, but it has a feature to ignore parts with only two characters to allow for SI units like mV or uA. Unfortunately, not all SI units fit in two characters, and not all are lower case followed by upper case. This patch adds hardcoded detection for frequency and 1024-based size units (Hz/KHz/MHz/GHz/THz and KiB/MiB/GiB/TiB), since allowing any three character combinations might be too lenient. The list can later be expanded as needed.

Julius Werner committed 11 years ago

Commit f5123571 parent ea4acbb1 file · +3 −1Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+3−1
@@ -4104,7 +4104,9 @@ sub process { · 4103 unmodified lines
4104#Ignore Page<foo> variants4104#Ignore Page<foo> variants
4105 $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&4105 $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
4106#Ignore SI style variants like nS, mV and dB (ie: max_uV, regulator_min_uA_show)4106#Ignore SI style variants like nS, mV and dB (ie: max_uV, regulator_min_uA_show)
4107 $var !~ /^(?:[a-z_]*?)_?[a-z][A-Z](?:_[a-z_]+)?$/) {4107 $var !~ /^(?:[a-z_]*?)_?[a-z][A-Z](?:_[a-z_]+)?$/ &&
4108#Ignore some three character SI units explicitly, like MiB and KHz
4109 $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
4108 while ($var =~ m{($Ident)}g) {4110 while ($var =~ m{($Ident)}g) {
4109 my $word = $1;4111 my $word = $1;
4110 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);4112 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);