CDEBUG|CERROR|CNETERR|CEMERG|CL_LOCK_DEBUG|CWARN|DEBUG_REQ|LCONSOLE_[A-Z]*|
panic|
MODULE_[A-Z_]+|
- seq_vprintf|seq_printf|seq_puts
+ seq_vprintf|seq_printf|seq_puts|
+ printf|fprintf
)};
our $signature_tags = qr{(?xi:
for (my $linenr = $first_line; $linenr < $end_line; $linenr++) {
my $line = $rawlines[$linenr - 1];
#warn " $line\n";
+ next if ($line =~ /^-/); # ignore lines removed by patch
if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
$in_comment = 1;
}
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
}
}
-# 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" or "rc = %zd"
+ # at the end of errors
+ if ($line !~ /LCONSOLE/ &&
+ $rawline !~ /: rc = \%l|z?d\\n\",/) {
+ WARN("CERROR_RET",
+ "Console messages should end with ': rc = %[lz]d'\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
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;
}
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",