lkml.org 
[lkml]   [2020]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] checkpatch: improve EXECUTE_PERMISSIONS tests
Date
1. Use group capture regexp for file mode test to improve code
readability.

2. The 'scripts/' directory test on filenames can be excluded
as it has become obsolete because there are many source
files that are not scripts in this directory and its
subdirectories.

3. Replace unnecessary group capture regexp with non-capturing
group.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Ujjwal Kumar <ujjwalkumar0501@gmail.com>
---
scripts/checkpatch.pl | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fab38b493cef..aa84999917b5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2678,10 +2678,11 @@ sub process {
}

# Check for incorrect file permissions
- if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
+ if ($line =~ /^new (?:file )?mode (\d+)$/) {
+ my $mode = substr($1, -3);
my $permhere = $here . "FILE: $realfile\n";
- if ($realfile !~ m@scripts/@ &&
- $realfile !~ /\.(py|pl|awk|sh)$/) {
+ if ($mode =~ /[1357]/ &&
+ $realfile !~ /\.(?:py|pl|awk|sh)$/) {
ERROR("EXECUTE_PERMISSIONS",
"do not set execute permissions for source files\n" . $permhere);
}
base-commit: d67bc7812221606e1886620a357b13f906814af7
--
2.26.2

\
 
 \ /
  Last update: 2020-10-12 17:21    [W:0.029 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site