From: Andy Whitcroft <apw@canonical.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>,
Rabin Vincent <rabin.vincent@stericsson.com>
Subject: [PATCH 10/16] checkpatch: check for incorrect permissions
Date: Wed, 18 Aug 2010 16:46:43 +0100 [thread overview]
Message-ID: <1282146409-30544-11-git-send-email-apw@canonical.com> (raw)
In-Reply-To: <1282146409-30544-1-git-send-email-apw@canonical.com>
From: Rabin Vincent <rabin.vincent@stericsson.com>
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>
---
scripts/checkpatch.pl | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e44ff91..93fa145 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1315,7 +1315,11 @@ sub process {
$here = "#$realline: " if ($file);
# extract the filename as it passes
- if ($line=~/^\+\+\+\s+(\S+)/) {
+ if ($line =~ /^diff --git.*?(\S+)$/) {
+ $realfile = $1;
+ $realfile =~ s@^([^/]*)/@@;
+
+ } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
$realfile = $1;
$realfile =~ s@^([^/]*)/@@;
@@ -1339,6 +1343,14 @@ sub process {
$cnt_lines++ if ($realcnt != 0);
+# Check for incorrect file permissions
+ if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
+ my $permhere = $here . "FILE: $realfile\n";
+ if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) {
+ ERROR("do not set execute permissions for source files\n" . $permhere);
+ }
+ }
+
#check the patch for a signoff:
if ($line =~ /^\s*signed-off-by:/i) {
# This is a signoff, if ugly, so do not double report.
--
1.7.0.4
next prev parent reply other threads:[~2010-08-18 15:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 15:46 [PATCH 00/16] update checkpatch to v0.31 Andy Whitcroft
2010-08-18 15:46 ` [PATCH 01/16] checkpatch: fix regressions in "fix handling of leading spaces" Andy Whitcroft
2010-08-18 15:46 ` [PATCH 02/16] checkpatch: types may sit on a line on their own Andy Whitcroft
2010-08-18 15:46 ` [PATCH 03/16] checkpatch: suggest cleanpatch and cleanfile when appropriate Andy Whitcroft
2010-08-18 15:46 ` [PATCH 04/16] checkpatch: ensure we do not collapse bracketed sections into constants Andy Whitcroft
2010-08-18 15:46 ` [PATCH 05/16] checkpatch: handle casts better fixing false categorisation of : as binary Andy Whitcroft
2010-08-18 15:46 ` [PATCH 06/16] checkpatch: returning errno typically should be negative Andy Whitcroft
2010-08-18 15:46 ` [PATCH 07/16] checkpatch: add check for space after struct, union, and enum Andy Whitcroft
2010-08-18 15:46 ` [PATCH 08/16] checkpatch: simplify and consolidate "missing space after" checks Andy Whitcroft
2010-08-18 15:46 ` [PATCH 09/16] checkpatch: ensure kconfig help checks only apply when we are adding help Andy Whitcroft
2010-08-18 15:46 ` Andy Whitcroft [this message]
2010-08-18 15:46 ` [PATCH 11/16] checkpatch: Add additional attribute #defines Andy Whitcroft
2010-08-18 15:46 ` [PATCH 12/16] checkpatch: update copyright dates Andy Whitcroft
2010-08-18 15:46 ` [PATCH 13/16] checkpatch: clean up structure definition macro handline Andy Whitcroft
2010-08-18 15:46 ` [PATCH 14/16] checkpatch: handle EXPORT_SYMBOL for DEVICE_ATTR and similar Andy Whitcroft
2010-08-18 15:46 ` [PATCH 15/16] checkpatch: statement/block context analyser should look at sanitised lines Andy Whitcroft
2010-08-18 15:46 ` [PATCH 16/16] checkpatch: version 0.31 Andy Whitcroft
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282146409-30544-11-git-send-email-apw@canonical.com \
--to=apw@canonical.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rabin.vincent@stericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®