Skip to contentSkip to conversation

checkpatch: Don't warn about colon termination in linker scripts

PATCH Superseded Chris Down 2 participants 4 messages Feb 4, 2021 – Feb 6, 2021

Subsystems (2)
lore
Share & tools
lore

Chris Down

author
#0 lore raw

PATCH 1/1 checkpatch: Don't warn about colon termination in linker scripts

This check erroneously flags cases like the one in my recent printk enumeration patch[0], where the spaces are syntactic, and section:' vs. section :' is syntactically important:

ERROR: space prohibited before that ':' (ctx:WxW) #258: FILE: include/asm-generic/vmlinux.lds.h:314:
+ .printk_fmts : AT(ADDR(.printk_fmts) - LOAD_OFFSET) {

0: https://lore.kernel.org/patchwork/patch/1375749/

Cc Andrew Morton <[email protected]>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index 4f8494527139..3bcffc5574ae 100755
@@ -5046,7 +5046,7 @@ sub process {
 				# A colon needs no spaces before when it is
 				# terminating a case value or a label.
 				} elsif ($opv eq ':C' || $opv eq ':L') {
-					if ($ctx =~ /Wx./) {
+					if ($ctx =~ /Wx./ and $realfile !~ m@.*\.lds\.h$@) {
 						if (ERROR("SPACING",
 							  "space prohibited before that '$op' $at\n" . $hereptr)) {
 							$good = rtrim($fix_elements[$n]) . trim($fix_elements[$n + 1]);
Signature · 1 line
2.30.0
maintainer
#1 lore raw
Quoted 9 lines · Chris Down

This check erroneously flags cases like the one in my recent printk enumeration patch[0], where the spaces are syntactic, and section:' vs. section :' is syntactically important:

    ERROR: space prohibited before that ':' (ctx:WxW) #258: FILE: include/asm-generic/vmlinux.lds.h:314:
    + .printk_fmts : AT(ADDR(.printk_fmts) - LOAD_OFFSET) {

0: https://lore.kernel.org/patchwork/patch/1375749/

Remember to cc the checkpatch maintainers.

Quoted 19 lines
Cc Andrew Morton <[email protected]>

---
 scripts/checkpatch.pl | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index 4f8494527139..3bcffc5574ae 100755
@@ -5046,7 +5046,7 @@ sub process {
  				# A colon needs no spaces before when it is
  				# terminating a case value or a label.
  				} elsif ($opv eq ':C' || $opv eq ':L') {
-					if ($ctx =~ /Wx./) {
+					if ($ctx =~ /Wx./ and $realfile !~ m@.*\.lds\.h$@) {
  						if (ERROR("SPACING",
  							  "space prohibited before that '$op' $at\n" . $hereptr)) {
  							$good = rtrim($fix_elements[$n]) . trim($fix_elements[$n + 1]);
author
#2 lore raw

Oh, apologies -- I was somehow operating under the mistaken memory that this was under Andrew's purview and neglected to run get_maintainer.

I'll resend. :-)

maintainer
#3 lore raw
Quoted 4 lines · Chris Down

Oh, apologies -- I was somehow operating under the mistaken memory that this was under Andrew's purview and neglected to run get_maintainer.

I'll resend. :-)

No need really. The patch is fine.