Linux: -Wtautological-pointer-compare in arch/x86/mm/mmio-mod.c

Created on 8 Apr 2020  路  6Comments  路  Source: ClangBuiltLinux/linux

Seeing this on Linux v5.6.3 with kbuild: Enable -Wtautological-compare applied (using clang-10/ld.lld-10 from Debian/unstable):

arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL &&
            ^~~~~~~~~~~    ~~~~
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]
        if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
            ^~~~~~~~~~~    ~~~~
2 warnings generated.
-Wtautological-compare -Wtautological-pointer-compare [BUG] linux [FIXED][LINUX] 5.7

Most helpful comment

All 6 comments

I have applied 3 upstream commits + patch from @nathanchance:

$ git log --no-merges --oneline 5.6.3-1-amd64-clang..5.6.3-2-amd64-clang
2a7a4c66bd66 (for-5.6/kbuild-Wtautological-compare) x86: mmiotrace: Use cpumask_available for cpumask_var_t variables
810eab320502 lib/dynamic_debug.c: use address-of operator on section symbols
b23086de122a tracing: Use address-of operator on section symbols
1966e2eccba4 kernel/extable.c: use address-of operator on section symbols

References:

$ grep warning: build-log_5.6.3-1-amd64-clang.txt | grep '\-Wtautological-compare'
kernel/trace/trace.c:9337:33: warning: array comparison always evaluates to true [-Wtautological-compare]
kernel/extable.c:37:52: warning: array comparison always evaluates to a constant [-Wtautological-compare]
lib/dynamic_debug.c:1016:24: warning: array comparison always evaluates to false [-Wtautological-compare]

$ grep warning: build-log_5.6.3-1-amd64-clang.txt | grep '\-Wtautological-pointer-compare'
arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]
arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus' equal to a null pointer is always false [-Wtautological-pointer-compare]

[ -Wtautological-compare in kernel/extable.c #892 ]

https://github.com/ClangBuiltLinux/linux/issues/892
https://git.kernel.org/linus/63174f61dfaef58dc0e813eaf6602636794f8942

[ -Wtautological-compare in kernel/trace/trace.c #893 ]

https://github.com/ClangBuiltLinux/linux/issues/893
https://git.kernel.org/linus/bf2cbe044da275021b2de5917240411a19e5c50d

[ -Wtautological-compare in lib/dynamic_debug.c #894 ]

https://github.com/ClangBuiltLinux/linux/issues/894
https://git.kernel.org/linus/8306b057a85ec07482da5d4b99d5c0b47af69be1

[ -Wtautological-pointer-compare in arch/x86/mm/mmio-mod.c #982 ]

https://github.com/ClangBuiltLinux/linux/issues/982
https://lore.kernel.org/lkml/[email protected]/

Looks good:

$ grep warning: build-log_5.6.3-2-amd64-clang.txt 
dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-pc-linux-gnu, try setting a correct CC environment variable

I have seen the warning also in Linux v5.7-rc1 and added @nathanchance patch to my local Linux Git - seen with both gcc-9.3 and clang-10.

Patch entered tip.git#x86/urgent.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/urgent&id=d7110a26e5905ec2fe3fc88bc6a538901accb72b

Was this page helpful?
0 / 5 - 0 ratings