linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: kmemleak: Use address-of operator on section symbols
@ 2020-02-20  5:15 Nathan Chancellor
  2020-02-20 11:05 ` Catalin Marinas
  2020-02-21  1:35 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Nathan Chancellor @ 2020-02-20  5:15 UTC (permalink / raw)
  To: Catalin Marinas, Andrew Morton
  Cc: linux-mm, linux-kernel, clang-built-linux, Nathan Chancellor,
	Nick Desaulniers

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).

Link: https://github.com/ClangBuiltLinux/linux/issues/895
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

v1 -> v2: https://lore.kernel.org/lkml/20200219045423.54190-6-natechancellor@gmail.com/

* 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(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index aa6832432d6a..788dc5509539 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm: kmemleak: Use address-of operator on section symbols
  2020-02-20  5:15 [PATCH v2] mm: kmemleak: Use address-of operator on section symbols Nathan Chancellor
@ 2020-02-20 11:05 ` Catalin Marinas
  2020-02-21  1:35 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2020-02-20 11:05 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Andrew Morton, linux-mm, linux-kernel, clang-built-linux,
	Nick Desaulniers

On Wed, Feb 19, 2020 at 10:15:51PM -0700, Nathan Chancellor wrote:
> 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).
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/895
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm: kmemleak: Use address-of operator on section symbols
  2020-02-20  5:15 [PATCH v2] mm: kmemleak: Use address-of operator on section symbols Nathan Chancellor
  2020-02-20 11:05 ` Catalin Marinas
@ 2020-02-21  1:35 ` Andrew Morton
  2020-02-21  1:37   ` Nathan Chancellor
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2020-02-21  1:35 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Catalin Marinas, linux-mm, linux-kernel, clang-built-linux,
	Nick Desaulniers

On Wed, 19 Feb 2020 22:15:51 -0700 Nathan Chancellor <natechancellor@gmail.com> wrote:

> 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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm: kmemleak: Use address-of operator on section symbols
  2020-02-21  1:35 ` Andrew Morton
@ 2020-02-21  1:37   ` Nathan Chancellor
  0 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2020-02-21  1:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Catalin Marinas, linux-mm, linux-kernel, clang-built-linux,
	Nick Desaulniers

On Thu, Feb 20, 2020 at 05:35:01PM -0800, Andrew Morton wrote:
> On Wed, 19 Feb 2020 22:15:51 -0700 Nathan Chancellor <natechancellor@gmail.com> wrote:
> 
> > 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-21  1:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20  5:15 [PATCH v2] mm: kmemleak: Use address-of operator on section symbols Nathan Chancellor
2020-02-20 11:05 ` Catalin Marinas
2020-02-21  1:35 ` Andrew Morton
2020-02-21  1:37   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).