diff options
author | Andy Whitcroft <apw@shadowen.org> | 2008-04-29 03:59:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:05 -0400 |
commit | 171ae1a491e216ef728436f9cc958e05cccf5a27 (patch) | |
tree | 528f106389a8136c55b4fc95b8677301aa7d7047 /scripts | |
parent | ee8900c9c7cc92db02b7edfa26ae3b2c9b2434f9 (diff) |
update checkpatch.pl to version 0.17
This version brings improvements to external declaration detection, fixes to
quote tracking, fixes to unary tracking, some clarification of wording, and
the usual slew of fixes for false positives.
Of note:
- much better unary tracking across preprocessor directives
- UTF8 checks highlight the character at fault
- widening of mutex detection
Andy Whitcroft (17):
Version: 0.17
values: __attribute__ carries through the previous type
quotes: should only follow "positive" lines
clarify the indent tabs over spaces wording
loosen NR_CPUS check for array range initialisers
detect external function declarations without an extern prefix
function declaration arguments should be with the identifier
DEFINE_MUTEX should report in line with struct mutex
NR_CPUS is valid in preprocessor statements
comment detection should not start on the @@ line
types: add support for #undef
tighten mutex/completion reports to usage
allow export of function pointers
values: preprocessor #define is out of line maintain values
values: #define does not always have parentheses
unary '*' may be const
utf8 checks should report location of the invalid character
Wolfram Sang (1):
make checkpatch.pl really skip <asm/irq.h>
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
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 | 131 |
1 files changed, 90 insertions, 41 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 64ec4b8a51b..fd21b5eaed3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -9,7 +9,7 @@ use strict; | |||
9 | my $P = $0; | 9 | my $P = $0; |
10 | $P =~ s@.*/@@g; | 10 | $P =~ s@.*/@@g; |
11 | 11 | ||
12 | my $V = '0.16'; | 12 | my $V = '0.17'; |
13 | 13 | ||
14 | use Getopt::Long qw(:config no_auto_abbrev); | 14 | use Getopt::Long qw(:config no_auto_abbrev); |
15 | 15 | ||
@@ -131,6 +131,17 @@ our $NonptrType; | |||
131 | our $Type; | 131 | our $Type; |
132 | our $Declare; | 132 | our $Declare; |
133 | 133 | ||
134 | our $UTF8 = qr { | ||
135 | [\x09\x0A\x0D\x20-\x7E] # ASCII | ||
136 | | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | ||
137 | | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | ||
138 | | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | ||
139 | | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | ||
140 | | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | ||
141 | | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | ||
142 | | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 | ||
143 | }x; | ||
144 | |||
134 | our @typeList = ( | 145 | our @typeList = ( |
135 | qr{void}, | 146 | qr{void}, |
136 | qr{char}, | 147 | qr{char}, |
@@ -692,7 +703,7 @@ sub annotate_values { | |||
692 | while (length($cur)) { | 703 | while (length($cur)) { |
693 | @av_paren_type = ('E') if ($#av_paren_type < 0); | 704 | @av_paren_type = ('E') if ($#av_paren_type < 0); |
694 | print " <" . join('', @av_paren_type) . | 705 | print " <" . join('', @av_paren_type) . |
695 | "> <$type> " if ($dbg_values > 1); | 706 | "> <$type> <$av_pending>" if ($dbg_values > 1); |
696 | if ($cur =~ /^(\s+)/o) { | 707 | if ($cur =~ /^(\s+)/o) { |
697 | print "WS($1)\n" if ($dbg_values > 1); | 708 | print "WS($1)\n" if ($dbg_values > 1); |
698 | if ($1 =~ /\n/ && $av_preprocessor) { | 709 | if ($1 =~ /\n/ && $av_preprocessor) { |
@@ -705,9 +716,18 @@ sub annotate_values { | |||
705 | $type = 'T'; | 716 | $type = 'T'; |
706 | 717 | ||
707 | } elsif ($cur =~ /^(#\s*define\s*$Ident)(\(?)/o) { | 718 | } elsif ($cur =~ /^(#\s*define\s*$Ident)(\(?)/o) { |
708 | print "DEFINE($1)\n" if ($dbg_values > 1); | 719 | print "DEFINE($1,$2)\n" if ($dbg_values > 1); |
709 | $av_preprocessor = 1; | 720 | $av_preprocessor = 1; |
710 | $av_pending = 'N'; | 721 | push(@av_paren_type, $type); |
722 | if ($2 ne '') { | ||
723 | $av_pending = 'N'; | ||
724 | } | ||
725 | $type = 'E'; | ||
726 | |||
727 | } elsif ($cur =~ /^(#\s*undef\s*$Ident)/o) { | ||
728 | print "UNDEF($1)\n" if ($dbg_values > 1); | ||
729 | $av_preprocessor = 1; | ||
730 | push(@av_paren_type, $type); | ||
711 | 731 | ||
712 | } elsif ($cur =~ /^(#\s*(?:ifdef|ifndef|if))/o) { | 732 | } elsif ($cur =~ /^(#\s*(?:ifdef|ifndef|if))/o) { |
713 | print "PRE_START($1)\n" if ($dbg_values > 1); | 733 | print "PRE_START($1)\n" if ($dbg_values > 1); |
@@ -715,7 +735,7 @@ sub annotate_values { | |||
715 | 735 | ||
716 | push(@av_paren_type, $type); | 736 | push(@av_paren_type, $type); |
717 | push(@av_paren_type, $type); | 737 | push(@av_paren_type, $type); |
718 | $type = 'N'; | 738 | $type = 'E'; |
719 | 739 | ||
720 | } elsif ($cur =~ /^(#\s*(?:else|elif))/o) { | 740 | } elsif ($cur =~ /^(#\s*(?:else|elif))/o) { |
721 | print "PRE_RESTART($1)\n" if ($dbg_values > 1); | 741 | print "PRE_RESTART($1)\n" if ($dbg_values > 1); |
@@ -723,7 +743,7 @@ sub annotate_values { | |||
723 | 743 | ||
724 | push(@av_paren_type, $av_paren_type[$#av_paren_type]); | 744 | push(@av_paren_type, $av_paren_type[$#av_paren_type]); |
725 | 745 | ||
726 | $type = 'N'; | 746 | $type = 'E'; |
727 | 747 | ||
728 | } elsif ($cur =~ /^(#\s*(?:endif))/o) { | 748 | } elsif ($cur =~ /^(#\s*(?:endif))/o) { |
729 | print "PRE_END($1)\n" if ($dbg_values > 1); | 749 | print "PRE_END($1)\n" if ($dbg_values > 1); |
@@ -734,11 +754,16 @@ sub annotate_values { | |||
734 | # one does, and continue as if the #endif was not here. | 754 | # one does, and continue as if the #endif was not here. |
735 | pop(@av_paren_type); | 755 | pop(@av_paren_type); |
736 | push(@av_paren_type, $type); | 756 | push(@av_paren_type, $type); |
737 | $type = 'N'; | 757 | $type = 'E'; |
738 | 758 | ||
739 | } elsif ($cur =~ /^(\\\n)/o) { | 759 | } elsif ($cur =~ /^(\\\n)/o) { |
740 | print "PRECONT($1)\n" if ($dbg_values > 1); | 760 | print "PRECONT($1)\n" if ($dbg_values > 1); |
741 | 761 | ||
762 | } elsif ($cur =~ /^(__attribute__)\s*\(?/o) { | ||
763 | print "ATTR($1)\n" if ($dbg_values > 1); | ||
764 | $av_pending = $type; | ||
765 | $type = 'N'; | ||
766 | |||
742 | } elsif ($cur =~ /^(sizeof)\s*(\()?/o) { | 767 | } elsif ($cur =~ /^(sizeof)\s*(\()?/o) { |
743 | print "SIZEOF($1)\n" if ($dbg_values > 1); | 768 | print "SIZEOF($1)\n" if ($dbg_values > 1); |
744 | if (defined $2) { | 769 | if (defined $2) { |
@@ -930,7 +955,7 @@ sub process { | |||
930 | # edge is a close comment then we must be in a comment | 955 | # edge is a close comment then we must be in a comment |
931 | # at context start. | 956 | # at context start. |
932 | my $edge; | 957 | my $edge; |
933 | for (my $ln = $linenr; $ln < ($linenr + $realcnt); $ln++) { | 958 | for (my $ln = $linenr + 1; $ln < ($linenr + $realcnt); $ln++) { |
934 | next if ($line =~ /^-/); | 959 | next if ($line =~ /^-/); |
935 | ($edge) = ($rawlines[$ln - 1] =~ m@(/\*|\*/)@); | 960 | ($edge) = ($rawlines[$ln - 1] =~ m@(/\*|\*/)@); |
936 | last if (defined $edge); | 961 | last if (defined $edge); |
@@ -951,9 +976,9 @@ sub process { | |||
951 | ##print "COMMENT:$in_comment edge<$edge> $rawline\n"; | 976 | ##print "COMMENT:$in_comment edge<$edge> $rawline\n"; |
952 | sanitise_line_reset($in_comment); | 977 | sanitise_line_reset($in_comment); |
953 | 978 | ||
954 | } elsif ($realcnt) { | 979 | } elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) { |
955 | # Standardise the strings and chars within the input to | 980 | # Standardise the strings and chars within the input to |
956 | # simplify matching. | 981 | # simplify matching -- only bother with positive lines. |
957 | $line = sanitise_line($rawline); | 982 | $line = sanitise_line($rawline); |
958 | } | 983 | } |
959 | push(@lines, $line); | 984 | push(@lines, $line); |
@@ -1066,17 +1091,14 @@ sub process { | |||
1066 | 1091 | ||
1067 | # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php | 1092 | # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php |
1068 | if (($realfile =~ /^$/ || $line =~ /^\+/) && | 1093 | if (($realfile =~ /^$/ || $line =~ /^\+/) && |
1069 | !($rawline =~ m/^( | 1094 | $rawline !~ m/^$UTF8*$/) { |
1070 | [\x09\x0A\x0D\x20-\x7E] # ASCII | 1095 | my ($utf8_prefix) = ($rawline =~ /^($UTF8*)/); |
1071 | | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | 1096 | |
1072 | | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | 1097 | my $blank = copy_spacing($rawline); |
1073 | | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | 1098 | my $ptr = substr($blank, 0, length($utf8_prefix)) . "^"; |
1074 | | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | 1099 | my $hereptr = "$hereline$ptr\n"; |
1075 | | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | 1100 | |
1076 | | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | 1101 | ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); |
1077 | | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 | ||
1078 | )*$/x )) { | ||
1079 | ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $herecurr); | ||
1080 | } | 1102 | } |
1081 | 1103 | ||
1082 | #ignore lines being removed | 1104 | #ignore lines being removed |
@@ -1112,7 +1134,7 @@ sub process { | |||
1112 | if ($rawline =~ /^\+\s* \t\s*\S/ || | 1134 | if ($rawline =~ /^\+\s* \t\s*\S/ || |
1113 | $rawline =~ /^\+\s* \s*/) { | 1135 | $rawline =~ /^\+\s* \s*/) { |
1114 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; | 1136 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; |
1115 | ERROR("use tabs not spaces\n" . $herevet); | 1137 | ERROR("code indent should use tabs where possible\n" . $herevet); |
1116 | } | 1138 | } |
1117 | 1139 | ||
1118 | # check for RCS/CVS revision markers | 1140 | # check for RCS/CVS revision markers |
@@ -1121,35 +1143,40 @@ sub process { | |||
1121 | } | 1143 | } |
1122 | 1144 | ||
1123 | # Check for potential 'bare' types | 1145 | # Check for potential 'bare' types |
1146 | my ($stat, $cond); | ||
1124 | if ($realcnt) { | 1147 | if ($realcnt) { |
1125 | my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); | 1148 | ($stat, $cond) = ctx_statement_block($linenr, |
1126 | $s =~ s/\n./ /g; | 1149 | $realcnt, 0); |
1127 | $s =~ s/{.*$//; | 1150 | $stat =~ s/\n./\n /g; |
1151 | $cond =~ s/\n./\n /g; | ||
1152 | |||
1153 | my $s = $stat; | ||
1154 | $s =~ s/{.*$//s; | ||
1128 | 1155 | ||
1129 | # Ignore goto labels. | 1156 | # Ignore goto labels. |
1130 | if ($s =~ /$Ident:\*$/) { | 1157 | if ($s =~ /$Ident:\*$/s) { |
1131 | 1158 | ||
1132 | # Ignore functions being called | 1159 | # Ignore functions being called |
1133 | } elsif ($s =~ /^.\s*$Ident\s*\(/) { | 1160 | } elsif ($s =~ /^.\s*$Ident\s*\(/s) { |
1134 | 1161 | ||
1135 | # definitions in global scope can only start with types | 1162 | # definitions in global scope can only start with types |
1136 | } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b/) { | 1163 | } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b/s) { |
1137 | possible($1, $s); | 1164 | possible($1, $s); |
1138 | 1165 | ||
1139 | # declarations always start with types | 1166 | # declarations always start with types |
1140 | } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:const\s+)?($Ident)\b(:?\s+$Sparse)?\s*\**\s*$Ident\s*(?:;|=|,)/) { | 1167 | } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:const\s+)?($Ident)\b(:?\s+$Sparse)?\s*\**\s*$Ident\s*(?:;|=|,)/s) { |
1141 | possible($1, $s); | 1168 | possible($1, $s); |
1142 | } | 1169 | } |
1143 | 1170 | ||
1144 | # any (foo ... *) is a pointer cast, and foo is a type | 1171 | # any (foo ... *) is a pointer cast, and foo is a type |
1145 | while ($s =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/g) { | 1172 | while ($s =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/sg) { |
1146 | possible($1, $s); | 1173 | possible($1, $s); |
1147 | } | 1174 | } |
1148 | 1175 | ||
1149 | # Check for any sort of function declaration. | 1176 | # Check for any sort of function declaration. |
1150 | # int foo(something bar, other baz); | 1177 | # int foo(something bar, other baz); |
1151 | # void (*store_gdt)(x86_descr_ptr *); | 1178 | # void (*store_gdt)(x86_descr_ptr *); |
1152 | if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/) { | 1179 | if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/s) { |
1153 | my ($name_len) = length($1); | 1180 | my ($name_len) = length($1); |
1154 | 1181 | ||
1155 | my $ctx = $s; | 1182 | my $ctx = $s; |
@@ -1282,6 +1309,7 @@ sub process { | |||
1282 | ($prevline !~ /^ }/) && | 1309 | ($prevline !~ /^ }/) && |
1283 | ($prevline !~ /^.DECLARE_$Ident\(\Q$name\E\)/) && | 1310 | ($prevline !~ /^.DECLARE_$Ident\(\Q$name\E\)/) && |
1284 | ($prevline !~ /^.LIST_HEAD\(\Q$name\E\)/) && | 1311 | ($prevline !~ /^.LIST_HEAD\(\Q$name\E\)/) && |
1312 | ($prevline !~ /^.$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(/) && | ||
1285 | ($prevline !~ /\b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[)/)) { | 1313 | ($prevline !~ /\b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[)/)) { |
1286 | WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); | 1314 | WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); |
1287 | } | 1315 | } |
@@ -1512,7 +1540,10 @@ sub process { | |||
1512 | if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { | 1540 | if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { |
1513 | ERROR("space required before that '$op' $at\n" . $hereptr); | 1541 | ERROR("space required before that '$op' $at\n" . $hereptr); |
1514 | } | 1542 | } |
1515 | if ($ctx =~ /.xW/) { | 1543 | if ($op eq '*' && $cc =~/\s*const\b/) { |
1544 | # A unary '*' may be const | ||
1545 | |||
1546 | } elsif ($ctx =~ /.xW/) { | ||
1516 | ERROR("space prohibited after that '$op' $at\n" . $hereptr); | 1547 | ERROR("space prohibited after that '$op' $at\n" . $hereptr); |
1517 | } | 1548 | } |
1518 | 1549 | ||
@@ -1617,7 +1648,7 @@ sub process { | |||
1617 | 1648 | ||
1618 | # Check for illegal assignment in if conditional. | 1649 | # Check for illegal assignment in if conditional. |
1619 | if ($line =~ /\bif\s*\(/) { | 1650 | if ($line =~ /\bif\s*\(/) { |
1620 | my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); | 1651 | my ($s, $c) = ($stat, $cond); |
1621 | 1652 | ||
1622 | if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) { | 1653 | if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) { |
1623 | ERROR("do not use assignment in if condition\n" . $herecurr); | 1654 | ERROR("do not use assignment in if condition\n" . $herecurr); |
@@ -1695,7 +1726,7 @@ sub process { | |||
1695 | #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) | 1726 | #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) |
1696 | if ($tree && $rawline =~ m{^.\#\s*include\s*\<asm\/(.*)\.h\>}) { | 1727 | if ($tree && $rawline =~ m{^.\#\s*include\s*\<asm\/(.*)\.h\>}) { |
1697 | my $checkfile = "$root/include/linux/$1.h"; | 1728 | my $checkfile = "$root/include/linux/$1.h"; |
1698 | if (-f $checkfile && $1 ne 'irq.h') { | 1729 | if (-f $checkfile && $1 ne 'irq') { |
1699 | WARN("Use #include <linux/$1.h> instead of <asm/$1.h>\n" . | 1730 | WARN("Use #include <linux/$1.h> instead of <asm/$1.h>\n" . |
1700 | $herecurr); | 1731 | $herecurr); |
1701 | } | 1732 | } |
@@ -1910,7 +1941,8 @@ sub process { | |||
1910 | } | 1941 | } |
1911 | 1942 | ||
1912 | # check for spinlock_t definitions without a comment. | 1943 | # check for spinlock_t definitions without a comment. |
1913 | if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) { | 1944 | if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ || |
1945 | $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) { | ||
1914 | my $which = $1; | 1946 | my $which = $1; |
1915 | if (!ctx_has_comment($first_line, $linenr)) { | 1947 | if (!ctx_has_comment($first_line, $linenr)) { |
1916 | CHK("$1 definition without comment\n" . $herecurr); | 1948 | CHK("$1 definition without comment\n" . $herecurr); |
@@ -1940,8 +1972,22 @@ sub process { | |||
1940 | } | 1972 | } |
1941 | 1973 | ||
1942 | # check for new externs in .c files. | 1974 | # check for new externs in .c files. |
1943 | if ($line =~ /^.\s*extern\s/ && ($realfile =~ /\.c$/)) { | 1975 | if ($realfile =~ /\.c$/ && defined $stat && |
1944 | WARN("externs should be avoided in .c files\n" . $herecurr); | 1976 | $stat =~ /^.(?:extern\s+)?$Type\s+$Ident(\s*)\(/s) |
1977 | { | ||
1978 | my $paren_space = $1; | ||
1979 | |||
1980 | my $s = $stat; | ||
1981 | if (defined $cond) { | ||
1982 | substr($s, 0, length($cond), ''); | ||
1983 | } | ||
1984 | if ($s =~ /^\s*;/) { | ||
1985 | WARN("externs should be avoided in .c files\n" . $herecurr); | ||
1986 | } | ||
1987 | |||
1988 | if ($paren_space =~ /\n/) { | ||
1989 | WARN("arguments for function declarations should follow identifier\n" . $herecurr); | ||
1990 | } | ||
1945 | } | 1991 | } |
1946 | 1992 | ||
1947 | # checks for new __setup's | 1993 | # checks for new __setup's |
@@ -1964,11 +2010,11 @@ sub process { | |||
1964 | } | 2010 | } |
1965 | 2011 | ||
1966 | # check for semaphores used as mutexes | 2012 | # check for semaphores used as mutexes |
1967 | if ($line =~ /\b(DECLARE_MUTEX|init_MUTEX)\s*\(/) { | 2013 | if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) { |
1968 | WARN("mutexes are preferred for single holder semaphores\n" . $herecurr); | 2014 | WARN("mutexes are preferred for single holder semaphores\n" . $herecurr); |
1969 | } | 2015 | } |
1970 | # check for semaphores used as mutexes | 2016 | # check for semaphores used as mutexes |
1971 | if ($line =~ /\binit_MUTEX_LOCKED\s*\(/) { | 2017 | if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) { |
1972 | WARN("consider using a completion\n" . $herecurr); | 2018 | WARN("consider using a completion\n" . $herecurr); |
1973 | } | 2019 | } |
1974 | # recommend strict_strto* over simple_strto* | 2020 | # recommend strict_strto* over simple_strto* |
@@ -1979,8 +2025,11 @@ sub process { | |||
1979 | # use of NR_CPUS is usually wrong | 2025 | # use of NR_CPUS is usually wrong |
1980 | # ignore definitions of NR_CPUS and usage to define arrays as likely right | 2026 | # ignore definitions of NR_CPUS and usage to define arrays as likely right |
1981 | if ($line =~ /\bNR_CPUS\b/ && | 2027 | if ($line =~ /\bNR_CPUS\b/ && |
1982 | $line !~ /^.#\s*define\s+NR_CPUS\s+/ && | 2028 | $line !~ /^.#\s*if\b.*\bNR_CPUS\b/ && |
1983 | $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/) | 2029 | $line !~ /^.#\s*define\b.*\bNR_CPUS\b/ && |
2030 | $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ && | ||
2031 | $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ && | ||
2032 | $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/) | ||
1984 | { | 2033 | { |
1985 | WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); | 2034 | WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); |
1986 | } | 2035 | } |