mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts: checkpatch: Check spaces in Makefiles.
@ 2024-09-19 10:42 Tóth János via B4 Relay
  0 siblings, 0 replies; only message in thread
From: Tóth János via B4 Relay @ 2024-09-19 10:42 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn
  Cc: linux-kernel, Tóth János

From: Tóth János <gomba007@gmail.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@gmail.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@uk.ibm.com> (new conditions, test suite)
 # (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
 # (c) 2010-2018 Joe Perches <joe@perches.com>
+# (c) 2024 Tóth János <gomba007@gmail.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@gmail.com>



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

only message in thread, other threads:[~2024-09-19 10:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-19 10:42 [PATCH] scripts: checkpatch: Check spaces in Makefiles Tóth János via B4 Relay

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®