X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=contrib%2Fscripts%2Fcheckpatch.pl;h=b9d5a3492096730fd37ab281f5a538277ca9eefe;hb=2247cf23ce55398ea4bebc1f8093275534736a0a;hp=e91aeb3fb95fc55752f581eece9d8d99572f5575;hpb=3201740760d241dee935e4a66935b1bc81ac6380;p=fs%2Flustre-release.git diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index e91aeb3..b9d5a349 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -2894,6 +2894,10 @@ sub process { if ($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(?:KERN_\S+\s*|[^"]*))?($String\s*(?:|,|\)\s*;)\s*)$/ && length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) { $msg_type = ""; + # a Lustre message that contains embedded formatting + } elsif ($line =~ /^\+\s*(?:$logFunctions\s*\()?($String(?:DFID|DOSTID)$String\s*(?:|,|\)\s*;)?\s*)$/ && + length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) { + $msg_type = "" # lines with only strings (w/ possible termination) # #defines with only strings @@ -5168,31 +5172,42 @@ sub process { } } -# try to replace assertions with error handling +# Lustre try to replace assertions with error handling if ($line =~ /\bLASSERTF?\s*\(/) { WARN("LASSERT", - "try to replace assertions with error handling\n" . + "Try to replace assertions with error handling\n" . $herecurr); } -# avoid new console messages - if ($line =~ /\bLCONSOLE[A-Z_]*\s*\(/) { - WARN("LCONSOLE", - "avoid adding new console messages\n" . - $herecurr); - } +# Lustre minimize new CERROR messages + if ($line =~ /\b(CEMERG|CERROR|CNETERR|CWARN|LCONSOLE)\s*\(/) { + if ($rawline !~ /\(\"\%s: /) { + WARN("CERROR_DEV", + "Console messages should start with '%s:' to print device name\n" . $herecurr) + } -# minimize new CERROR messages - if ($line =~ /\bC(EMERG|ERROR|NETERR|WARN)\s*\(/) { - WARN("CERROR", - "think hard when adding new CERROR messages\n" . - $herecurr); + # Check for "rc = %d" or "rc = %ld" at the end of errors + if ($line !~ /LCONSOLE/ && $rawline !~ /: rc = \%l?d\\n\",/) { + WARN("CERROR_RET", + "Console messages should end with ': rc = %d' or 'rc = %ld'\n" . $herecurr); + } + + # This is fine as we are only matching the first part. + if ($line =~ /(CEMERG|CERROR|CNETERR)/) { + WARN("CERROR", + "Errors should be useful to fix failure conditions, not status/debug\n" . $herecurr); + } + } +# Lustre avoid unlimited message printing to the console + if ($line =~ /CDEBUG\((D_ERROR|D_WARNING|D_CONSOLE|[a-z])/) { + WARN("CDEBUG_LIMIT", + "CDEBUG does not rate-limit console messages, use CDEBUG_LIMIT\n". $herecurr); } -# don't allow GPLv3 license files +# Lustre don't allow GPLv3 license files if ($rawline =~ /version 3/) { WARN("GPLV3", - "using GPLv3 is usually wrong\n" . $herecurr); + "Using GPLv3 is usually wrong\n" . $herecurr); } # check for single line unbalanced braces @@ -5769,7 +5784,7 @@ sub process { for (my $count = $linenr; $count <= $lc; $count++) { my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0)); $fmt =~ s/%%//g; - if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNO]).)/) { + if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNOx]).)/) { $bad_extension = $1; last; } @@ -6116,7 +6131,7 @@ sub process { next if ($fline =~ /^.[\s$;]*$/); $has_statement = 1; $count++; - $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/); + $has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|return\b|goto\b|continue\b)/i); } if (!$has_break && $has_statement) { WARN("MISSING_BREAK",