Commit 323c1260 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: warn on CamelCase variable names

Store the camelcase variables in a hash and only emit a warning on the
first use of each new variable.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 74349bcc
...@@ -1398,6 +1398,8 @@ sub process { ...@@ -1398,6 +1398,8 @@ sub process {
my %suppress_export; my %suppress_export;
my $suppress_statement = 0; my $suppress_statement = 0;
my %camelcase = ();
# Pre-scan the patch sanitizing the lines. # Pre-scan the patch sanitizing the lines.
# Pre-scan the patch looking for any __setup documentation. # Pre-scan the patch looking for any __setup documentation.
# #
...@@ -2905,12 +2907,17 @@ sub process { ...@@ -2905,12 +2907,17 @@ sub process {
} }
} }
#studly caps, commented out until figure out how to distinguish between use of existing and adding new #CamelCase
# if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { while ($line =~ m{($Constant|$Lval)}g) {
# print "No studly caps, use _\n"; my $var = $1;
# print "$herecurr"; if ($var !~ /$Constant/ &&
# $clean = 0; $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ &&
# } !defined $camelcase{$var}) {
$camelcase{$var} = 1;
WARN("CAMELCASE",
"Avoid CamelCase: <$var>\n" . $herecurr);
}
}
#no spaces allowed after \ in define #no spaces allowed after \ in define
if ($line=~/\#\s*define.*\\\s$/) { if ($line=~/\#\s*define.*\\\s$/) {
......
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