kernel/extable: Use address-of operator on section symbols
PATCH v2 1/1 kernel/extable: Use address-of operator on section symbols
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).
---
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.
kernel/extable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/extable.c +2 -1
@@ -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); }
Signature · 1 line
2.25.1
Quoted 8 lines · 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.
Quoted 7 lines
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).
Gah this should have:
I can send a v3 if necessary.
Quoted 27 lines
---
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.kernel/extable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/extable.c +2
-1@@ -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); }Signature · 1 line
2.25.1