[PATCH 1/3] checkpatch: skip spacing tests on linker scripts

From: Jim Cromie
Date: Fri Jun 25 2021 - 23:40:30 EST


Before issuing a WARNING on spacing, exclude reports on linker
scripts, which don't comport to C style rules. skip_on_filename()
skips on *.lds.h files, I think covering all cases.

Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
scripts/checkpatch.pl | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 23697a6b1eaa..4fe9fab20009 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2546,6 +2546,11 @@ sub get_raw_comment {
return $comment;
}

+sub skip_on_filename {
+ my $fname = shift;
+ return $fname =~ m@\.lds\.h$@;
+}
+
sub exclude_global_initialisers {
my ($realfile) = @_;

@@ -5134,7 +5139,8 @@ sub process {
}
}
} elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
- if (ERROR("SPACING",
+ if (!skip_on_filename($realfile) &&
+ ERROR("SPACING",
"need consistent spacing around '$op' $at\n" . $hereptr)) {
$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
if (defined $fix_elements[$n + 2]) {
--
2.31.1