History

checkpatch: extend CamelCase types and ignore existing CamelCase uses in a patch

Extend the CamelCase words found to include structure members. In https://lkml.org/lkml/2013/9/3/318 Sarah Sharp (mostly) wrote: "In general, if checkpatch.pl complains about a variable a patch introduces that's CamelCase, you should pay attention to it. Otherwise, [] ignore it." So, if checking a patch, scan the original patched file if it's available and add any preexisting CamelCase types so reuses do not generate CamelCase messages. That also means Andrew's not so cruelly spurned anymore. https://lkml.org/lkml/2013/2/22/426

Joe Perches committed 13 years ago

Commit d8b07711 parent 84731621 file · +10 −2Browse files

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

Unified · Split

scripts/checkpatch.pl+10−2
@@ -443,7 +443,7 @@ sub seed_camelcase_file { · 442 unmodified lines
443443 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
444444 $camelcase{$1} = 1;
445445 }
446− elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) {
446+ elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
447447 $camelcase{$1} = 1;
448448 }
449449 }
@@ -1612,6 +1612,8 @@ sub process { · 1162 unmodified lines
16121612 my @setup_docs = ();
16131613 my $setup_docs = 0;
16141614
1615+ my $camelcase_file_seeded = 0;
1616+
16151617 sanitise_line_reset();
16161618 my $line;
16171619 foreach my $rawline (@rawlines) {
@@ -3394,7 +3396,13 @@ sub process { · 1776 unmodified lines
33943396 while ($var =~ m{($Ident)}g) {
33953397 my $word = $1;
33963398 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
3397− seed_camelcase_includes() if ($check);
3399+ if ($check) {
3400+ seed_camelcase_includes();
3401+ if (!$file && !$camelcase_file_seeded) {
3402+ seed_camelcase_file($realfile);
3403+ $camelcase_file_seeded = 1;
3404+ }
3405+ }
33983406 if (!defined $camelcase{$word}) {
33993407 $camelcase{$word} = 1;
34003408 CHK("CAMELCASE",