Linux Kernel Mentees Archive on lore.kernel.org
 help / color / Atom feed
* [Linux-kernel-mentees] [PATCH] checkpatch: improve EXECUTE_PERMISSIONS tests
@ 2020-10-12 15:16 Ujjwal Kumar
  0 siblings, 0 replies; only message in thread
From: Ujjwal Kumar @ 2020-10-12 15:16 UTC (permalink / raw)
  To: Joe Perches, Lukas Bulwahn
  Cc: linux-kernel-mentees, linux-kernel, Ujjwal Kumar

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

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 15:16 [Linux-kernel-mentees] [PATCH] checkpatch: improve EXECUTE_PERMISSIONS tests Ujjwal Kumar

Linux Kernel Mentees Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kernel-mentees/0 linux-kernel-mentees/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kernel-mentees linux-kernel-mentees/ https://lore.kernel.org/linux-kernel-mentees \
		linux-kernel-mentees@lists.linuxfoundation.org linux-kernel-mentees@lists.linux-foundation.org
	public-inbox-index linux-kernel-mentees

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxfoundation.lists.linux-kernel-mentees


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git