lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240919-checkpatch-makefile-spaces-v1-1-f247fd2ba4cf@gmail.com>
Date: Thu, 19 Sep 2024 12:42:00 +0200
From: Tóth János via B4 Relay <devnull+gomba007.gmail.com@...nel.org>
To: Andy Whitcroft <apw@...onical.com>, Joe Perches <joe@...ches.com>, 
 Dwaipayan Ray <dwaipayanray1@...il.com>, 
 Lukas Bulwahn <lukas.bulwahn@...il.com>
Cc: linux-kernel@...r.kernel.org, 
 Tóth János <gomba007@...il.com>
Subject: [PATCH] scripts: checkpatch: Check spaces in Makefiles.

From: Tóth János <gomba007@...il.com>

I've found a Makefile that looked like this:
    obj-$(X)<tab><tab>+=<space>X.o
    obj-$(Y)<space><space>+=<space>Y.o

This patch allows checkpatch to detect this type of style error
in Makefiles. The check is disabled for the comment-only lines.

Signed-off-by: Tóth János <gomba007@...il.com>
---
 scripts/checkpatch.pl | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4427572b2477..25b6f5b024c0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6,6 +6,7 @@
 # (c) 2007,2008, Andy Whitcroft <apw@...ibm.com> (new conditions, test suite)
 # (c) 2008-2010 Andy Whitcroft <apw@...onical.com>
 # (c) 2010-2018 Joe Perches <joe@...ches.com>
+# (c) 2024 Tóth János <gomba007@...il.com>
 
 use strict;
 use warnings;
@@ -3718,6 +3719,26 @@ sub process {
 			     "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
 		}
 
+		if ($realfile =~ /Makefile.*/ && $rawline !~ /^\+\#/) {
+			if ($rawline =~ /  /) {
+				my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+				WARN("MULTIPLE_SPACES",
+				     "please, use tabs\n" . $herevet)
+			}
+
+			if ($rawline =~ / \t/) {
+				my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+				WARN("SPACE_BEFORE_TAB",
+				     "please, no space before tabs, use tabs\n" . $herevet)
+			}
+
+			if ($rawline =~ /\t /) {
+				my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+				WARN("TAB_BEFORE_SPACE",
+				     "please, no tab before spaces, use tabs\n" . $herevet)
+			}
+		}
+
 # check for DT compatible documentation
 		if (defined $root &&
 			(($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||

---
base-commit: 98f7e32f20d28ec452afb208f9cffc08448a2652
change-id: 20240919-checkpatch-makefile-spaces-74c1bcd2829c

Best regards,
-- 
Tóth János <gomba007@...il.com>



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ