diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2010-10-26 17:23:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:20 -0400 |
commit | 3bf9a009fccea422bc355414a3bdf5f35fff9f36 (patch) | |
tree | 18a47ff24bae81950fae0e8b550835723da17cd1 /scripts | |
parent | 9fe287d79b0af983050d24e7916cf3d1f019f553 (diff) |
checkpatch: check for incorrect permissions
Throw an error when a source file has been given execute permissions using
the mode change line present in git diffs. Also alow the filename
matching to use the "diff" line in addition to the "+++" line, since the
mode change lines appear before any "+++" lines.
[apw@canonical.com: simplified filename logic slightly, added tests]
Cc: Andy Whitcroft <apw@canonical.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e44ff91e811d..93fa145671a0 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -1315,7 +1315,11 @@ sub process { | |||
1315 | $here = "#$realline: " if ($file); | 1315 | $here = "#$realline: " if ($file); |
1316 | 1316 | ||
1317 | # extract the filename as it passes | 1317 | # extract the filename as it passes |
1318 | if ($line=~/^\+\+\+\s+(\S+)/) { | 1318 | if ($line =~ /^diff --git.*?(\S+)$/) { |
1319 | $realfile = $1; | ||
1320 | $realfile =~ s@^([^/]*)/@@; | ||
1321 | |||
1322 | } elsif ($line =~ /^\+\+\+\s+(\S+)/) { | ||
1319 | $realfile = $1; | 1323 | $realfile = $1; |
1320 | $realfile =~ s@^([^/]*)/@@; | 1324 | $realfile =~ s@^([^/]*)/@@; |
1321 | 1325 | ||
@@ -1339,6 +1343,14 @@ sub process { | |||
1339 | 1343 | ||
1340 | $cnt_lines++ if ($realcnt != 0); | 1344 | $cnt_lines++ if ($realcnt != 0); |
1341 | 1345 | ||
1346 | # Check for incorrect file permissions | ||
1347 | if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) { | ||
1348 | my $permhere = $here . "FILE: $realfile\n"; | ||
1349 | if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) { | ||
1350 | ERROR("do not set execute permissions for source files\n" . $permhere); | ||
1351 | } | ||
1352 | } | ||
1353 | |||
1342 | #check the patch for a signoff: | 1354 | #check the patch for a signoff: |
1343 | if ($line =~ /^\s*signed-off-by:/i) { | 1355 | if ($line =~ /^\s*signed-off-by:/i) { |
1344 | # This is a signoff, if ugly, so do not double report. | 1356 | # This is a signoff, if ugly, so do not double report. |