Re: Possible false positive from checkpatch.pl?

From: Joe Perches
Date: Mon Aug 09 2021 - 16:25:12 EST


On Mon, 2021-08-09 at 15:15 -0500, Madhavan T. Venkataraman wrote:
> Hi,
>
> I have defined the SYM_CODE_END() macro for ARM64 in arch/arm64/include/asm/linkage.h like this:
>
> #define SYM_CODE_END(name) \
>         SYM_END(name, SYM_T_NONE) ;\
>         99: ;\
>         .pushsection "sym_code_functions", "aw" ;\
>         .quad name ;\
>         .quad 99b ;\
>         .popsection
>
> SYM_CODE_START() and SYM_CODE_END() macros are only used while defining assembly functions.
> They are never used in C code.
>
> But checkpatch.pl is emitting the following messages (enclosed within ========). Looks like
> it is treating them like macros used in C code.
>
>
> =================
> ERROR: Macros with multiple statements should be enclosed in a do - while loop
> #21: FILE: arch/arm64/include/asm/linkage.h:68:
> +#define SYM_CODE_END(name) \
> + SYM_END(name, SYM_T_NONE) ;\
> + 99: ;\
> + .pushsection "sym_code_functions", "aw" ;\
> + .quad name ;\
> + .quad 99b ;\
> + .popsection
>
> ERROR: spaces required around that ':' (ctx:VxW)
> #23: FILE: arch/arm64/include/asm/linkage.h:70:
> + 99: ;\
>   ^
>
> WARNING: labels should not be indented
> #23: FILE: arch/arm64/include/asm/linkage.h:70:
> + 99: ;\
>
> total: 2 errors, 1 warnings, 124 lines checked
>
> Wrote EXPERIMENTAL --fix correction(s) to '/tmp/x.EXPERIMENTAL-checkpatch-fixes'
>
> Do _NOT_ trust the results written to this file.
> Do _NOT_ submit these changes without inspecting them for correctness.
>
> This EXPERIMENTAL file is simply a convenience to help rewrite patches.
> No warranties, expressed or implied...
>
> /tmp/x has style problems, please review.
>
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.
> ==================
>
> How do I fix this? Can you please help?

Fix checkpatch? If you _really_ want, you could change checkpatch
to skip .h file tests when $realfile =~ m@/asm/@;

Otherwise, just be sensible and ignore checkpatch output that doesn't
make sense. It's a stupid brainless script. You are not.
>
> Thanks in advance.
>
> Madhavan T. Venkataraman