checkpatch: avoid sscanf test duplicated messages
[firefly-linux-kernel-4.4.55.git] / scripts / checkpatch.pl
index 1054283c6e70e705f6310dea6fef6daa263779e8..e7c50977fe3d54d0cf4b1fd3515cba2a9b47acc9 100755 (executable)
@@ -4188,7 +4188,7 @@ sub process {
 # check for naked sscanf
                if ($^V && $^V ge 5.10.0 &&
                    defined $stat &&
-                   $stat =~ /\bsscanf\b/ &&
+                   $line =~ /\bsscanf\b/ &&
                    ($stat !~ /$Ident\s*=\s*sscanf\s*$balanced_parens/ &&
                     $stat !~ /\bsscanf\s*$balanced_parens\s*(?:$Compare)/ &&
                     $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) {
@@ -4512,9 +4512,11 @@ sub process {
                                my $val = $1;
                                $val = $6 if ($skip_args ne "");
 
-                               if ($val =~ /^$Int$/ && $val !~ /^$Octal$/) {
+                               if ($val !~ /^0$/ &&
+                                   (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
+                                    length($val) ne 4)) {
                                        ERROR("NON_OCTAL_PERMISSIONS",
-                                             "Use octal not decimal permissions\n" . $herecurr);
+                                             "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);
                                }
                        }
                }