linux/arch/mips
Nathan Chancellor 059f47b3a4 MIPS: tlbex: Explicitly compare _PAGE_NO_EXEC against 0
[ Upstream commit 74de14fe05 ]

When CONFIG_XPA is enabled, Clang warns:

  arch/mips/mm/tlbex.c:629:24: error: converting the result of '<<' to a boolean; did you mean '(1 << _PAGE_NO_EXEC_SHIFT) != 0'? [-Werror,-Wint-in-bool-context]
          if (cpu_has_rixi && !!_PAGE_NO_EXEC) {
                              ^
  arch/mips/include/asm/pgtable-bits.h:174:28: note: expanded from macro '_PAGE_NO_EXEC'
  # define _PAGE_NO_EXEC          (1 << _PAGE_NO_EXEC_SHIFT)
                                     ^
  arch/mips/mm/tlbex.c:2568:24: error: converting the result of '<<' to a boolean; did you mean '(1 << _PAGE_NO_EXEC_SHIFT) != 0'? [-Werror,-Wint-in-bool-context]
          if (!cpu_has_rixi || !_PAGE_NO_EXEC) {
                                ^
  arch/mips/include/asm/pgtable-bits.h:174:28: note: expanded from macro '_PAGE_NO_EXEC'
  # define _PAGE_NO_EXEC          (1 << _PAGE_NO_EXEC_SHIFT)
                                     ^
  2 errors generated.

_PAGE_NO_EXEC can be '0' or '1 << _PAGE_NO_EXEC_SHIFT' depending on the
build and runtime configuration, which is what the negation operators
are trying to convey. To silence the warning, explicitly compare against
0 so the result of the '<<' operator is not implicitly converted to a
boolean.

According to its documentation, GCC enables -Wint-in-bool-context with
-Wall but this warning is not visible when building the same
configuration with GCC. It appears GCC only warns when compiling C++,
not C, although the documentation makes no note of this:
https://godbolt.org/z/x39q3brxf

Reported-by: Sudip Mukherjee (Codethink) <sudipm.mukherjee@gmail.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-25 11:38:22 +02:00
..
alchemy
ar7
ath25
ath79
bcm47xx
bcm63xx mips: bcm63xx: add support for clk_set_parent() 2022-01-27 10:54:09 +01:00
bmips MIPS: Use address-of operator on section symbols 2022-05-15 20:00:08 +02:00
boot MIPS: ingenic: correct unit node address 2022-04-13 21:01:00 +02:00
cavium-octeon mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start 2022-08-25 11:38:19 +02:00
cobalt
configs
crypto
dec mips: DEC: honor CONFIG_MIPS_FP_SUPPORT=n 2022-04-08 14:40:20 +02:00
fw
generic
include MIPS: IP30: Remove incorrect `cpu_has_fpu' override 2022-06-09 10:21:31 +02:00
ingenic
jazz
kernel MIPS: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2022-08-21 15:15:26 +02:00
kvm
lantiq MIPS: lantiq: check the return value of kzalloc() 2022-05-25 09:17:54 +02:00
lib
loongson2ef
loongson32
loongson64
math-emu
mm MIPS: tlbex: Explicitly compare _PAGE_NO_EXEC against 0 2022-08-25 11:38:22 +02:00
mti-malta
net
netlogic
oprofile
pci
pic32 MIPS: Use address-of operator on section symbols 2022-05-15 20:00:08 +02:00
pistachio
power
ralink MIPS: Use address-of operator on section symbols 2022-05-15 20:00:08 +02:00
rb532 MIPS: RB532: fix return value of __setup handler 2022-04-08 14:40:21 +02:00
sgi-ip22
sgi-ip27
sgi-ip30
sgi-ip32
sibyte
sni
tools
txx9
vdso
vr41xx MIPS: Remove repetitive increase irq_err_count 2022-06-29 08:59:48 +02:00
Kbuild
Kbuild.platforms
Kconfig
Kconfig.debug
Makefile
Makefile.postlink