linux/arch
Andy Shevchenko 6c2625e9c2 x86/percpu: fix clang warning when dealing with unsigned types
Patch series "percpu: Add a test case and fix for clang", v2.

Add a test case to percpu to check a corner case with the specific 64-bit
unsigned value.  This test case shows why the first patch is done in the
way it's done.

The before and after has been tested with binary comparison of the
percpu_test module and runnig it on the real Intel system.


This patch (of 2):

When percpu_add_op() is used with an unsigned argument, it prevents kernel
builds with clang, `make W=1` and CONFIG_WERROR=y:

net/ipv4/tcp_output.c:187:3: error: result of comparison of constant -1 with expression of type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
  187 |                 NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPACKCOMPRESSED,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  188 |                               tp->compressed_ack);
      |                               ~~~~~~~~~~~~~~~~~~~
...
arch/x86/include/asm/percpu.h:238:31: note: expanded from macro 'percpu_add_op'
  238 |                               ((val) == 1 || (val) == -1)) ?            \
      |                                              ~~~~~ ^  ~~

Fix this by casting -1 to the type of the parameter and then compare.

Link: https://lkml.kernel.org/r/20241016182635.1156168-1-andriy.shevchenko@linux.intel.com
Link: https://lkml.kernel.org/r/20241016182635.1156168-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Christoph Lameter <cl@linux.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dennis Zhou <dennis@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-11-06 20:11:14 -08:00
..
alpha mm: remove unused hugepage for vma_alloc_folio() 2024-11-06 20:11:12 -08:00
arc move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
arm arm: adjust_pte() use pte_offset_map_rw_nolock() 2024-11-05 16:56:27 -08:00
arm64 mm: remove unused hugepage for vma_alloc_folio() 2024-11-06 20:11:12 -08:00
csky mm: make arch_get_unmapped_area() take vm_flags by default 2024-09-09 16:39:13 -07:00
hexagon hexagon: vdso: Fix build failure 2024-09-23 08:17:50 -07:00
loongarch mm: consolidate common checks in hugetlb_get_unmapped_area 2024-11-06 20:11:10 -08:00
m68k mm: remove unused hugepage for vma_alloc_folio() 2024-11-06 20:11:12 -08:00
microblaze move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
mips mm: consolidate common checks in hugetlb_get_unmapped_area 2024-11-06 20:11:10 -08:00
nios2 move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
openrisc openrisc: convert to generic syscall table 2024-07-10 14:23:38 +02:00
parisc mm: consolidate common checks in hugetlb_get_unmapped_area 2024-11-06 20:11:10 -08:00
powerpc mm: drop hugetlb_get_unmapped_area{_*} functions 2024-11-06 20:11:10 -08:00
riscv mm: move set_pxd_safe() helpers from generic to platform 2024-11-06 20:11:09 -08:00
s390 mm: remove unused hugepage for vma_alloc_folio() 2024-11-06 20:11:12 -08:00
sh mm: consolidate common checks in hugetlb_get_unmapped_area 2024-11-06 20:11:10 -08:00
sparc mm: drop hugetlb_get_unmapped_area{_*} functions 2024-11-06 20:11:10 -08:00
um move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
x86 x86/percpu: fix clang warning when dealing with unsigned types 2024-11-06 20:11:14 -08:00
xtensa move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
.gitignore
Kconfig cfi: tweak llvm version for HAVE_CFI_ICALL_NORMALIZE_INTEGERS 2024-10-31 00:41:37 +01:00