aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl51
1 files changed, 31 insertions, 20 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3d3ef2ff62b2..9f03345a1c5c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -388,6 +388,13 @@ our @mode_permission_funcs = (
388 ["(?:CLASS|DEVICE|SENSOR)_ATTR", 2], 388 ["(?:CLASS|DEVICE|SENSOR)_ATTR", 2],
389); 389);
390 390
391#Create a search pattern for all these functions to speed up a loop below
392our $mode_perms_search = "";
393foreach my $entry (@mode_permission_funcs) {
394 $mode_perms_search .= '|' if ($mode_perms_search ne "");
395 $mode_perms_search .= $entry->[0];
396}
397
391our $allowed_asm_includes = qr{(?x: 398our $allowed_asm_includes = qr{(?x:
392 irq| 399 irq|
393 memory 400 memory
@@ -4524,26 +4531,30 @@ sub process {
4524 "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); 4531 "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
4525 } 4532 }
4526 4533
4527 foreach my $entry (@mode_permission_funcs) { 4534# Mode permission misuses where it seems decimal should be octal
4528 my $func = $entry->[0]; 4535# This uses a shortcut match to avoid unnecessary uses of a slow foreach loop
4529 my $arg_pos = $entry->[1]; 4536 if ($^V && $^V ge 5.10.0 &&
4530 4537 $line =~ /$mode_perms_search/) {
4531 my $skip_args = ""; 4538 foreach my $entry (@mode_permission_funcs) {
4532 if ($arg_pos > 1) { 4539 my $func = $entry->[0];
4533 $arg_pos--; 4540 my $arg_pos = $entry->[1];
4534 $skip_args = "(?:\\s*$FuncArg\\s*,\\s*){$arg_pos,$arg_pos}"; 4541
4535 } 4542 my $skip_args = "";
4536 my $test = "\\b$func\\s*\\(${skip_args}([\\d]+)\\s*[,\\)]"; 4543 if ($arg_pos > 1) {
4537 if ($^V && $^V ge 5.10.0 && 4544 $arg_pos--;
4538 $line =~ /$test/) { 4545 $skip_args = "(?:\\s*$FuncArg\\s*,\\s*){$arg_pos,$arg_pos}";
4539 my $val = $1; 4546 }
4540 $val = $6 if ($skip_args ne ""); 4547 my $test = "\\b$func\\s*\\(${skip_args}([\\d]+)\\s*[,\\)]";
4541 4548 if ($line =~ /$test/) {
4542 if ($val !~ /^0$/ && 4549 my $val = $1;
4543 (($val =~ /^$Int$/ && $val !~ /^$Octal$/) || 4550 $val = $6 if ($skip_args ne "");
4544 length($val) ne 4)) { 4551
4545 ERROR("NON_OCTAL_PERMISSIONS", 4552 if ($val !~ /^0$/ &&
4546 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr); 4553 (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
4554 length($val) ne 4)) {
4555 ERROR("NON_OCTAL_PERMISSIONS",
4556 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);
4557 }
4547 } 4558 }
4548 } 4559 }
4549 } 4560 }