Skip to content

Commit adb2da8

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: prefer ftrace over function entry/exit printks
Prefer using ftrace over function entry/exit logging messages. Warn with various function entry/exit only logging that only use __func__ with or without descriptive decoration. Link: https://lkml.kernel.org/r/47c01081533a417c99c9a80a4cd537f8c308503f.camel@perches.com Signed-off-by: Joe Perches <joe@perches.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ea7dbab commit adb2da8

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎scripts/checkpatch.pl‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,30 @@ sub hash_show_words {
507507
Cc:
508508
)};
509509

510+
our $tracing_logging_tags = qr{(?xi:
511+
[=-]*> |
512+
<[=-]* |
513+
\[ |
514+
\] |
515+
start |
516+
called |
517+
entered |
518+
entry |
519+
enter |
520+
in |
521+
inside |
522+
here |
523+
begin |
524+
exit |
525+
end |
526+
done |
527+
leave |
528+
completed |
529+
out |
530+
return |
531+
[\.\!:\s]*
532+
)};
533+
510534
sub edit_distance_min {
511535
my (@arr) = @_;
512536
my $len = scalar @arr;
@@ -5972,6 +5996,17 @@ sub process {
59725996
"Prefer using '\"%s...\", __func__' to using '$context_function', this function's name, in a string\n" . $herecurr);
59735997
}
59745998

5999+
# check for unnecessary function tracing like uses
6000+
# This does not use $logFunctions because there are many instances like
6001+
# 'dprintk(FOO, "%s()\n", __func__);' which do not match $logFunctions
6002+
if ($rawline =~ /^\+.*\([^"]*"$tracing_logging_tags{0,3}%s(?:\s*\(\s*\)\s*)?$tracing_logging_tags{0,3}(?:\\n)?"\s*,\s*__func__\s*\)\s*;/) {
6003+
if (WARN("TRACING_LOGGING",
6004+
"Unnecessary ftrace-like logging - prefer using ftrace\n" . $herecurr) &&
6005+
$fix) {
6006+
fix_delete_line($fixlinenr, $rawline);
6007+
}
6008+
}
6009+
59756010
# check for spaces before a quoted newline
59766011
if ($rawline =~ /^.*\".*\s\\n/) {
59776012
if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",

0 commit comments

Comments
 (0)