Merge git://git.infradead.org/users/eparis/audit
[firefly-linux-kernel-4.4.55.git] / scripts / checkpatch.pl
index 1eb5d2fa8d20989f56195f58eb92f56ab0d3d075..61090e0ff613aefeb5429c26d4efc7775ad97739 100755 (executable)
@@ -4019,6 +4019,23 @@ sub process {
                        }
                }
 
+# check for naked sscanf
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /\bsscanf\b/ &&
+                   ($stat !~ /$Ident\s*=\s*sscanf\s*$balanced_parens/ &&
+                    $stat !~ /\bsscanf\s*$balanced_parens\s*(?:$Compare)/ &&
+                    $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) {
+                       my $lc = $stat =~ tr@\n@@;
+                       $lc = $lc + $linenr;
+                       my $stat_real = raw_line($linenr, 0);
+                       for (my $count = $linenr + 1; $count <= $lc; $count++) {
+                               $stat_real = $stat_real . "\n" . raw_line($count, 0);
+                       }
+                       WARN("NAKED_SSCANF",
+                            "unchecked sscanf return value\n" . "$here\n$stat_real\n");
+               }
+
 # check for new externs in .h files.
                if ($realfile =~ /\.h$/ &&
                    $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {