mm: kmemleak: Use address-of operator on section symbols
Subsystems (2)
PATCH v2 1/1 mm: kmemleak: Use address-of operator on section symbols
Clang warns:
These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
---
v1 -> v2: https://lore.kernel.org/lkml/[email protected]/
* No longer a series because there is no prerequisite patch.
* Use address-of operator instead of casting to unsigned long.
mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c +1 -1
@@ -1952,7 +1952,7 @@ void __init kmemleak_init(void)create_object ((unsigned long )__bss_start, __bss_stop - __bss_start,KMEMLEAK_GREY ,GFP_ATOMIC );/* only register .data..ro_after_init if not within .data */ -if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata) +if (&__start_ro_after_init < &_sdata || &__end_ro_after_init > &_edata)create_object ((unsigned long )__start_ro_after_init, __end_ro_after_init - __start_ro_after_init,KMEMLEAK_GREY ,GFP_ATOMIC );
Signature · 1 line
2.25.1
Quoted 10 lines · Nathan Chancellor
Clang warns:
These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
Suggested-by Nick Desaulniers <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Andrew Morton
maintainerQuoted 6 lines · On Wed, 19 Feb 2020 22:15:51 -0700 Nathan Chancellor…
Clang warns:
These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
I guess you forgot to quote the clang output?
Quoted 10 lines · Andrew Morton
Quoted 6 lines · On Wed, 19 Feb 2020 22:15:51 -0700 Nathan Chancellor…
Clang warns:
These are not true arrays, they are linker defined symbols, which are just addresses. Using the address of operator silences the warning and does not change the resulting assembly with either clang/ld.lld or gcc/ld (tested with diff + objdump -Dr).
I guess you forgot to quote the clang output?
Ugh yes, sorry. I can send a v3 later or here it is if you want to stitch it in:
../mm/kmemleak.c:1955:28: warning: array comparison always evaluates to a constant [-Wtautological-compare]
if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)
^
../mm/kmemleak.c:1955:60: warning: array comparison always evaluates to a constant [-Wtautological-compare]
if (__start_ro_after_init < _sdata || __end_ro_after_init > _edata)
^2 warnings generated.
Cheers,
Nathan