diff options
| author | Joe Perches <joe@perches.com> | 2012-12-17 19:02:07 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:19 -0500 |
| commit | 323c1260ba2c4b5c4b2a1e9ab6657cde54ccf554 (patch) | |
| tree | fcc114327e37918e20e42a2f4ed00e3b7f158cec /scripts | |
| parent | 74349bccedb3e34b4f1fd9c7efd2dda7905e3335 (diff) | |
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: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9de3a69260e1..1d6e4c541370 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -1398,6 +1398,8 @@ sub process { | |||
| 1398 | my %suppress_export; | 1398 | my %suppress_export; |
| 1399 | my $suppress_statement = 0; | 1399 | my $suppress_statement = 0; |
| 1400 | 1400 | ||
| 1401 | my %camelcase = (); | ||
| 1402 | |||
| 1401 | # Pre-scan the patch sanitizing the lines. | 1403 | # Pre-scan the patch sanitizing the lines. |
| 1402 | # Pre-scan the patch looking for any __setup documentation. | 1404 | # Pre-scan the patch looking for any __setup documentation. |
| 1403 | # | 1405 | # |
| @@ -2905,12 +2907,17 @@ sub process { | |||
| 2905 | } | 2907 | } |
| 2906 | } | 2908 | } |
| 2907 | 2909 | ||
| 2908 | #studly caps, commented out until figure out how to distinguish between use of existing and adding new | 2910 | #CamelCase |
| 2909 | # if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { | 2911 | while ($line =~ m{($Constant|$Lval)}g) { |
| 2910 | # print "No studly caps, use _\n"; | 2912 | my $var = $1; |
| 2911 | # print "$herecurr"; | 2913 | if ($var !~ /$Constant/ && |
| 2912 | # $clean = 0; | 2914 | $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && |
| 2913 | # } | 2915 | !defined $camelcase{$var}) { |
| 2916 | $camelcase{$var} = 1; | ||
| 2917 | WARN("CAMELCASE", | ||
| 2918 | "Avoid CamelCase: <$var>\n" . $herecurr); | ||
| 2919 | } | ||
| 2920 | } | ||
| 2914 | 2921 | ||
| 2915 | #no spaces allowed after \ in define | 2922 | #no spaces allowed after \ in define |
| 2916 | if ($line=~/\#\s*define.*\\\s$/) { | 2923 | if ($line=~/\#\s*define.*\\\s$/) { |
