aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-11-28 10:06:34 -0500
committerTony Lindgren <tony@atomide.com>2017-11-28 10:06:34 -0500
commit2db57789e6612ce0cf2fcbb577a1c8307b708566 (patch)
treedd9f9e3dffabbf5cb932fcf5055ab329ca940fa0 /scripts/checkpatch.pl
parentf0c96c6d40312b1a76cd36709dc3eb5948c1b97f (diff)
parente9a9bb4e4779ca74cb52a6e2f8acbc0881d3bb18 (diff)
Merge branch 'soc-fixes' into omap-for-v4.15/fixes
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl45
1 files changed, 18 insertions, 27 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dd2c262aebbf..95cda3ecc66b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -454,6 +454,7 @@ our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};
454our $logFunctions = qr{(?x: 454our $logFunctions = qr{(?x:
455 printk(?:_ratelimited|_once|_deferred_once|_deferred|)| 455 printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
456 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| 456 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
457 TP_printk|
457 WARN(?:_RATELIMIT|_ONCE|)| 458 WARN(?:_RATELIMIT|_ONCE|)|
458 panic| 459 panic|
459 MODULE_[A-Z_]+| 460 MODULE_[A-Z_]+|
@@ -2900,8 +2901,9 @@ sub process {
2900 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) { 2901 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) {
2901 $msg_type = ""; 2902 $msg_type = "";
2902 2903
2903 # EFI_GUID is another special case 2904 # More special cases
2904 } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/) { 2905 } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/ ||
2906 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
2905 $msg_type = ""; 2907 $msg_type = "";
2906 2908
2907 # Otherwise set the alternate message types 2909 # Otherwise set the alternate message types
@@ -3103,6 +3105,7 @@ sub process {
3103 $line =~ /^\+[a-z_]*init/ || 3105 $line =~ /^\+[a-z_]*init/ ||
3104 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ || 3106 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
3105 $line =~ /^\+\s*DECLARE/ || 3107 $line =~ /^\+\s*DECLARE/ ||
3108 $line =~ /^\+\s*builtin_[\w_]*driver/ ||
3106 $line =~ /^\+\s*__setup/)) { 3109 $line =~ /^\+\s*__setup/)) {
3107 if (CHK("LINE_SPACING", 3110 if (CHK("LINE_SPACING",
3108 "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) && 3111 "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) &&
@@ -3182,6 +3185,12 @@ sub process {
3182# check we are in a valid C source file if not then ignore this hunk 3185# check we are in a valid C source file if not then ignore this hunk
3183 next if ($realfile !~ /\.(h|c)$/); 3186 next if ($realfile !~ /\.(h|c)$/);
3184 3187
3188# check for unusual line ending [ or (
3189 if ($line =~ /^\+.*([\[\(])\s*$/) {
3190 CHK("OPEN_ENDED_LINE",
3191 "Lines should not end with a '$1'\n" . $herecurr);
3192 }
3193
3185# check if this appears to be the start function declaration, save the name 3194# check if this appears to be the start function declaration, save the name
3186 if ($sline =~ /^\+\{\s*$/ && 3195 if ($sline =~ /^\+\{\s*$/ &&
3187 $prevline =~ /^\+(?:(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*)?($Ident)\(/) { 3196 $prevline =~ /^\+(?:(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*)?($Ident)\(/) {
@@ -3829,28 +3838,10 @@ sub process {
3829 "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); 3838 "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
3830 } 3839 }
3831 3840
3832# printk should use KERN_* levels. Note that follow on printk's on the 3841# printk should use KERN_* levels
3833# same line do not need a level, so we use the current block context 3842 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
3834# to try and find and validate the current printk. In summary the current 3843 WARN("PRINTK_WITHOUT_KERN_LEVEL",
3835# printk includes all preceding printk's which have no newline on the end. 3844 "printk() should include KERN_<LEVEL> facility level\n" . $herecurr);
3836# we assume the first bad printk is the one to report.
3837 if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
3838 my $ok = 0;
3839 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
3840 #print "CHECK<$lines[$ln - 1]\n";
3841 # we have a preceding printk if it ends
3842 # with "\n" ignore it, else it is to blame
3843 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
3844 if ($rawlines[$ln - 1] !~ m{\\n"}) {
3845 $ok = 1;
3846 }
3847 last;
3848 }
3849 }
3850 if ($ok == 0) {
3851 WARN("PRINTK_WITHOUT_KERN_LEVEL",
3852 "printk() should include KERN_ facility level\n" . $herecurr);
3853 }
3854 } 3845 }
3855 3846
3856 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) { 3847 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
@@ -5957,7 +5948,7 @@ sub process {
5957 5948
5958# check for function declarations that have arguments without identifier names 5949# check for function declarations that have arguments without identifier names
5959 if (defined $stat && 5950 if (defined $stat &&
5960 $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s && 5951 $stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
5961 $1 ne "void") { 5952 $1 ne "void") {
5962 my $args = trim($1); 5953 my $args = trim($1);
5963 while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) { 5954 while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
@@ -6109,7 +6100,7 @@ sub process {
6109 next if ($fline =~ /^.[\s$;]*$/); 6100 next if ($fline =~ /^.[\s$;]*$/);
6110 $has_statement = 1; 6101 $has_statement = 1;
6111 $count++; 6102 $count++;
6112 $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/); 6103 $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\s*\(\b|return\b|goto\b|continue\b)/);
6113 } 6104 }
6114 if (!$has_break && $has_statement) { 6105 if (!$has_break && $has_statement) {
6115 WARN("MISSING_BREAK", 6106 WARN("MISSING_BREAK",
@@ -6390,7 +6381,7 @@ sub process {
6390 exit(0); 6381 exit(0);
6391 } 6382 }
6392 6383
6393 if (!$is_patch && $file !~ /cover-letter\.patch$/) { 6384 if (!$is_patch && $filename !~ /cover-letter\.patch$/) {
6394 ERROR("NOT_UNIFIED_DIFF", 6385 ERROR("NOT_UNIFIED_DIFF",
6395 "Does not appear to be a unified-diff format patch\n"); 6386 "Does not appear to be a unified-diff format patch\n");
6396 } 6387 }