History

checkpatch: improve octal permissions tests

Add world writable permissions tests for the various functions like debugfs etc... Add $String type for $FuncArg so that string constants are matched.

Joe Perches committed 11 years ago

Commit c0a5c891 parent 62ec8181 file · +5 −1Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+5−1
@@ -298,6 +298,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?}; · 297 unmodified lines
298our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};298our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
299our $Int = qr{[0-9]+$Int_type?};299our $Int = qr{[0-9]+$Int_type?};
300our $Octal = qr{0[0-7]+$Int_type?};300our $Octal = qr{0[0-7]+$Int_type?};
301our $String = qr{"[X\t]*"};
301our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};302our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
302our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};303our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
303our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};304our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
@@ -517,7 +518,7 @@ our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; · 213 unmodified lines
517 518
518our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;519our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
519our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};520our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
520our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};521our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
521 522
522our $declaration_macros = qr{(?x:523our $declaration_macros = qr{(?x:
523 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|524 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|
@@ -5261,6 +5262,9 @@ sub process { · 4737 unmodified lines
5261 length($val) ne 4)) {5262 length($val) ne 4)) {
5262 ERROR("NON_OCTAL_PERMISSIONS",5263 ERROR("NON_OCTAL_PERMISSIONS",
5263 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);5264 "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);
5265 } elsif ($val =~ /^$Octal$/ && (oct($val) & 02)) {
5266 ERROR("EXPORTED_WORLD_WRITABLE",
5267 "Exporting writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
5264 }5268 }
5265 }5269 }
5266 }5270 }