MIPS: Use address-of operator on section symbols
authorNathan Chancellor <natechancellor@gmail.com>
Tue, 5 Jan 2021 20:18:27 +0000 (13:18 -0700)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Thu, 7 Jan 2021 16:10:36 +0000 (17:10 +0100)
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>
arch/mips/bmips/setup.c
arch/mips/lantiq/prom.c
arch/mips/pic32/pic32mzda/init.c
arch/mips/ralink/of.c

index 19308df5f577914dc05708893dc36503ebd3b921..1b06b25aea87dd1b4b67d4764bff878952aed794 100644 (file)
@@ -167,7 +167,7 @@ void __init plat_mem_setup(void)
                dtb = phys_to_virt(fw_arg2);
        else if (fw_passed_dtb) /* UHI interface or appended dtb */
                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 51a218f04fe0dd073ef65408c9137330a6a43fa9..3f568f5aae2d1121ee684b1b53fe257b17ba511f 100644 (file)
@@ -79,7 +79,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 50f376f058f438630fc81e39f876c22a7c8148ce..f232c77ff5265381908eef747eacca2f4316b4be 100644 (file)
@@ -28,7 +28,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;
index cbae9d23ab7ffef0e3482cbeaf2ca53c69eca766..2c9af61efc205c63b69c3ce982218604bb8750c5 100644 (file)
@@ -75,7 +75,7 @@ void __init plat_mem_setup(void)
         */
        if (fw_passed_dtb)
                dtb = (void *)fw_passed_dtb;
-       else if (__dtb_start != __dtb_end)
+       else if (&__dtb_start != &__dtb_end)
                dtb = (void *)__dtb_start;
 
        __dt_setup_arch(dtb);