Commit d8b07710 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

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/426Signed-off-by: default avatarJoe Perches <joe@perches.com>
Suggested-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
Suggested-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 84731623
...@@ -443,7 +443,7 @@ sub seed_camelcase_file { ...@@ -443,7 +443,7 @@ sub seed_camelcase_file {
if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) { if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
$camelcase{$1} = 1; $camelcase{$1} = 1;
} }
elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) { elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
$camelcase{$1} = 1; $camelcase{$1} = 1;
} }
} }
...@@ -1612,6 +1612,8 @@ sub process { ...@@ -1612,6 +1612,8 @@ sub process {
my @setup_docs = (); my @setup_docs = ();
my $setup_docs = 0; my $setup_docs = 0;
my $camelcase_file_seeded = 0;
sanitise_line_reset(); sanitise_line_reset();
my $line; my $line;
foreach my $rawline (@rawlines) { foreach my $rawline (@rawlines) {
...@@ -3394,7 +3396,13 @@ sub process { ...@@ -3394,7 +3396,13 @@ sub process {
while ($var =~ m{($Ident)}g) { while ($var =~ m{($Ident)}g) {
my $word = $1; my $word = $1;
next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/); next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
seed_camelcase_includes() if ($check); if ($check) {
seed_camelcase_includes();
if (!$file && !$camelcase_file_seeded) {
seed_camelcase_file($realfile);
$camelcase_file_seeded = 1;
}
}
if (!defined $camelcase{$word}) { if (!defined $camelcase{$word}) {
$camelcase{$word} = 1; $camelcase{$word} = 1;
CHK("CAMELCASE", CHK("CAMELCASE",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment