All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] kernel/extable: Use address-of operator on section symbols
@ 2020-02-19 20:20 Nathan Chancellor
  2020-02-19 20:24 ` Nathan Chancellor
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2020-02-19 20:20 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, clang-built-linux, Nathan Chancellor

Clang warns:

../kernel/extable.c:37:52: warning: array comparison always evaluates to
a constant [-Wtautological-compare]
        if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) {
                                                          ^
1 warning generated.

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/892
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

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

* No longer a series because there is no prerequisite patch.
* Use address-of operator instead of casting to unsigned long.

 kernel/extable.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/extable.c b/kernel/extable.c
index a0024f27d3a1..88f3251b05e3 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -34,7 +34,8 @@ u32 __initdata __visible main_extable_sort_needed = 1;
 /* Sort the kernel's built-in exception table */
 void __init sort_main_extable(void)
 {
-	if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) {
+	if (main_extable_sort_needed &&
+	    &__stop___ex_table > &__start___ex_table) {
 		pr_notice("Sorting __ex_table...\n");
 		sort_extable(__start___ex_table, __stop___ex_table);
 	}
-- 
2.25.1


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

* Re: [PATCH v2] kernel/extable: Use address-of operator on section symbols
  2020-02-19 20:20 [PATCH v2] kernel/extable: Use address-of operator on section symbols Nathan Chancellor
@ 2020-02-19 20:24 ` Nathan Chancellor
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2020-02-19 20:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, clang-built-linux

On Wed, Feb 19, 2020 at 01:20:37PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
> ../kernel/extable.c:37:52: warning: array comparison always evaluates to
> a constant [-Wtautological-compare]
>         if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) {
>                                                           ^
> 1 warning generated.
> 
> 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/892
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Gah this should have:

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>

I can send a v3 if necessary.

> ---
> 
> v1 -> v2: https://lore.kernel.org/lkml/20200219045423.54190-3-natechancellor@gmail.com/
> 
> * No longer a series because there is no prerequisite patch.
> * Use address-of operator instead of casting to unsigned long.
> 
>  kernel/extable.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/extable.c b/kernel/extable.c
> index a0024f27d3a1..88f3251b05e3 100644
> --- a/kernel/extable.c
> +++ b/kernel/extable.c
> @@ -34,7 +34,8 @@ u32 __initdata __visible main_extable_sort_needed = 1;
>  /* Sort the kernel's built-in exception table */
>  void __init sort_main_extable(void)
>  {
> -	if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) {
> +	if (main_extable_sort_needed &&
> +	    &__stop___ex_table > &__start___ex_table) {
>  		pr_notice("Sorting __ex_table...\n");
>  		sort_extable(__start___ex_table, __stop___ex_table);
>  	}
> -- 
> 2.25.1
> 

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

end of thread, other threads:[~2020-02-19 20:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 20:20 [PATCH v2] kernel/extable: Use address-of operator on section symbols Nathan Chancellor
2020-02-19 20:24 ` Nathan Chancellor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.