diff mbox

[RFC/PATCH] arm64: Rename macro arguments to silence sparse

Message ID 20170207010143.22371-1-sboyd@codeaurora.org (mailing list archive)
State New, archived
Headers show

Commit Message

Stephen Boyd Feb. 7, 2017, 1:01 a.m. UTC
When I compile files with sparse, I get these sorts of warnings:

arch/arm64/include/asm/lse.h:14:28: warning: Unknown escape 'l'
arch/arm64/include/asm/lse.h:14:37: warning: Unknown escape 'l'
arch/arm64/include/asm/alternative.h:172:28: warning: Unknown escape 'o'

This is because sparse is trying to tokenize these files and sees
a line like this:

 alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS

It gets past alternative_insn part and then sees the start of a
string with the double quote character. So sparse starts to parse
the string (eat_string() in the sparse code) but the string has
an escape character '\' in it. Sparse sees the escape character,
so it checks to see if it's an escape sequence, but '\l' isn't.
This causes sparse to spit out this warning of an unknown escape
sequence 'l'.

In reality, sparse isn't going to use these macros anyway because
this whole thing is inside an __ASSEMBLER__ ifdef. One hacky
solution is to make sparse think it actually is an escape
sequence by starting the macro arguments with the 'n' character.
Then sparse will see a \n inside a string, which keeps it silent
and the assembler doesn't seem to mind either.

Cc: <sparse@vger.kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 arch/arm64/include/asm/alternative.h | 4 ++--
 arch/arm64/include/asm/lse.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Stephen Boyd Feb. 7, 2017, 1:08 a.m. UTC | #1
On 02/06/2017 05:01 PM, Stephen Boyd wrote:
> When I compile files with sparse, I get these sorts of warnings:
>
> arch/arm64/include/asm/lse.h:14:28: warning: Unknown escape 'l'
> arch/arm64/include/asm/lse.h:14:37: warning: Unknown escape 'l'
> arch/arm64/include/asm/alternative.h:172:28: warning: Unknown escape 'o'
>
> This is because sparse is trying to tokenize these files and sees
> a line like this:
>
>  alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
>
> It gets past alternative_insn part and then sees the start of a
> string with the double quote character. So sparse starts to parse
> the string (eat_string() in the sparse code) but the string has
> an escape character '\' in it. Sparse sees the escape character,
> so it checks to see if it's an escape sequence, but '\l' isn't.
> This causes sparse to spit out this warning of an unknown escape
> sequence 'l'.
>
> In reality, sparse isn't going to use these macros anyway because
> this whole thing is inside an __ASSEMBLER__ ifdef. One hacky
> solution is to make sparse think it actually is an escape
> sequence by starting the macro arguments with the 'n' character.
> Then sparse will see a \n inside a string, which keeps it silent
> and the assembler doesn't seem to mind either.
>
> Cc: <sparse@vger.kernel.org>

Sorry, supposed to be <linux-sparse@vger.kernel.org>

> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> ---
>  arch/arm64/include/asm/alternative.h | 4 ++--
>  arch/arm64/include/asm/lse.h         | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> index 6e1cb8c5af4d..dd393db554c8 100644
> --- a/arch/arm64/include/asm/alternative.h
> +++ b/arch/arm64/include/asm/alternative.h
> @@ -168,8 +168,8 @@ alternative_endif
>  #define _ALTERNATIVE_CFG(insn1, insn2, cap, cfg, ...)	\
>  	alternative_insn insn1, insn2, cap, IS_ENABLED(cfg)
>  
> -.macro user_alt, label, oldinstr, newinstr, cond
> -9999:	alternative_insn "\oldinstr", "\newinstr", \cond
> +.macro user_alt, label, noldinstr, newinstr, cond
> +9999:	alternative_insn "\noldinstr", "\newinstr", \cond
>  	_ASM_EXTABLE 9999b, \label
>  .endm
>  
> diff --git a/arch/arm64/include/asm/lse.h b/arch/arm64/include/asm/lse.h
> index fc756e22c84c..36206d75943d 100644
> --- a/arch/arm64/include/asm/lse.h
> +++ b/arch/arm64/include/asm/lse.h
> @@ -10,8 +10,8 @@
>  
>  .arch_extension	lse
>  
> -.macro alt_lse, llsc, lse
> -	alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
> +.macro alt_lse, nllsc, nlse
> +	alternative_insn "\nllsc", "\nlse", ARM64_HAS_LSE_ATOMICS
>  .endm
>  
>  #else	/* __ASSEMBLER__ */
diff mbox

Patch

diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
index 6e1cb8c5af4d..dd393db554c8 100644
--- a/arch/arm64/include/asm/alternative.h
+++ b/arch/arm64/include/asm/alternative.h
@@ -168,8 +168,8 @@  alternative_endif
 #define _ALTERNATIVE_CFG(insn1, insn2, cap, cfg, ...)	\
 	alternative_insn insn1, insn2, cap, IS_ENABLED(cfg)
 
-.macro user_alt, label, oldinstr, newinstr, cond
-9999:	alternative_insn "\oldinstr", "\newinstr", \cond
+.macro user_alt, label, noldinstr, newinstr, cond
+9999:	alternative_insn "\noldinstr", "\newinstr", \cond
 	_ASM_EXTABLE 9999b, \label
 .endm
 
diff --git a/arch/arm64/include/asm/lse.h b/arch/arm64/include/asm/lse.h
index fc756e22c84c..36206d75943d 100644
--- a/arch/arm64/include/asm/lse.h
+++ b/arch/arm64/include/asm/lse.h
@@ -10,8 +10,8 @@ 
 
 .arch_extension	lse
 
-.macro alt_lse, llsc, lse
-	alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
+.macro alt_lse, nllsc, nlse
+	alternative_insn "\nllsc", "\nlse", ARM64_HAS_LSE_ATOMICS
 .endm
 
 #else	/* __ASSEMBLER__ */