aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/checkpatch.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 77740252bbed..862cc7a740e2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4314,6 +4314,27 @@ sub process {
4314 "unchecked sscanf return value\n" . "$here\n$stat_real\n"); 4314 "unchecked sscanf return value\n" . "$here\n$stat_real\n");
4315 } 4315 }
4316 4316
4317# check for simple sscanf that should be kstrto<foo>
4318 if ($^V && $^V ge 5.10.0 &&
4319 defined $stat &&
4320 $line =~ /\bsscanf\b/) {
4321 my $lc = $stat =~ tr@\n@@;
4322 $lc = $lc + $linenr;
4323 my $stat_real = raw_line($linenr, 0);
4324 for (my $count = $linenr + 1; $count <= $lc; $count++) {
4325 $stat_real = $stat_real . "\n" . raw_line($count, 0);
4326 }
4327 if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
4328 my $format = $6;
4329 my $count = $format =~ tr@%@%@;
4330 if ($count == 1 &&
4331 $format =~ /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/) {
4332 WARN("SSCANF_TO_KSTRTO",
4333 "Prefer kstrto<type> to single variable sscanf\n" . "$here\n$stat_real\n");
4334 }
4335 }
4336 }
4337
4317# check for new externs in .h files. 4338# check for new externs in .h files.
4318 if ($realfile =~ /\.h$/ && 4339 if ($realfile =~ /\.h$/ &&
4319 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) { 4340 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {