MIPS: Use address-of operator on section symbols
authorNathan Chancellor <natechancellor@gmail.com>
Tue, 5 Jan 2021 20:18:27 +0000 (13:18 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 15 May 2022 17:39:17 +0000 (19:39 +0200)
commit d422c6c0644bccbb1ebeefffa51f35cec3019517 upstream.

When building xway_defconfig with clang:

arch/mips/lantiq/prom.c:82:23: error: array comparison always evaluates
to true [-Werror,-Wtautological-compare]
        else if (__dtb_start != __dtb_end)
                             ^
1 error 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). Do the same thing across
the entire MIPS subsystem to ensure there are no more warnings around
this type of comparison.

Link: https://github.com/ClangBuiltLinux/linux/issues/1232
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/mips/bmips/setup.c
arch/mips/lantiq/prom.c
arch/mips/pic32/pic32mzda/init.c

index 3b6f687f177cdf5b3826e10978a1bd465ed2a96e..32f8c501f6cb19b06eec35ae0649712de6db56ba 100644 (file)
@@ -174,7 +174,7 @@ void __init plat_mem_setup(void)
                dtb = phys_to_virt(fw_arg2);
        else if (fw_passed_dtb) /* UHI interface */
                dtb = (void *)fw_passed_dtb;
-       else if (__dtb_start != __dtb_end)
+       else if (&__dtb_start != &__dtb_end)
                dtb = (void *)__dtb_start;
        else
                panic("no dtb found");
index 4cbb000e778e3f0fcfcc57942a325d8e318ab343..9b30e46e91a75146becb1721841c83f99e2133cd 100644 (file)
@@ -76,7 +76,7 @@ void __init plat_mem_setup(void)
 
        if (fw_passed_dtb) /* UHI interface */
                dtb = (void *)fw_passed_dtb;
-       else if (__dtb_start != __dtb_end)
+       else if (&__dtb_start != &__dtb_end)
                dtb = (void *)__dtb_start;
        else
                panic("no dtb found");
index 51599710472bcb4abf89293827345cffb7953a7f..406c6c5cec29bb5dd3b319c6c785f45dce388537 100644 (file)
@@ -36,7 +36,7 @@ static ulong get_fdtaddr(void)
        if (fw_passed_dtb && !fw_arg2 && !fw_arg3)
                return (ulong)fw_passed_dtb;
 
-       if (__dtb_start < __dtb_end)
+       if (&__dtb_start < &__dtb_end)
                ftaddr = (ulong)__dtb_start;
 
        return ftaddr;