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

Message ID YBwhqsc2TIVeid3t@chrisdown.name
State Accepted
Commit 263afd39c06f5939ef943e0d535380d4b8e56484
Headers show
Series
  • checkpatch: Don't warn about colon termination in linker scripts
Related show

Commit Message

Chris Down Feb. 4, 2021, 4:32 p.m. UTC
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/

Signed-off-by: Chris Down <chris@chrisdown.name>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joe Perches Feb. 6, 2021, 3:25 a.m. UTC | #1
On Thu, 2021-02-04 at 16:32 +0000, Chris Down wrote:
> 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.

> Signed-off-by: Chris Down <chris@chrisdown.name>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 4f8494527139..3bcffc5574ae 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -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]);
Chris Down Feb. 6, 2021, 1:04 p.m. UTC | #2
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. :-)
Joe Perches Feb. 6, 2021, 1:11 p.m. UTC | #3
On Sat, 2021-02-06 at 13:04 +0000, Chris Down wrote:
> 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.

Patch
diff mbox series

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4f8494527139..3bcffc5574ae 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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]);