Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers

commit b344d6a83d01 ("parisc: add support for cmpxchg on u8 pointers")
can generate a sparse warning ("cast truncates bits from constant
value"), which has been reported several times [1] [2] [3].

The original code worked as expected, but anyway, let silence such
sparse warning as what others did [4].

[1] https://lore.kernel.org/r/202104061220.nRMBwCXw-lkp@intel.com
[2] https://lore.kernel.org/r/202012291914.T5Agcn99-lkp@intel.com
[3] https://lore.kernel.org/r/202008210829.KVwn7Xeh%25lkp@intel.com
[4] https://lore.kernel.org/r/20210315131512.133720-2-jacopo+renesas@jmondi.org
Cc: Liam Beguin <liambeguin@gmail.com>
Cc: Helge Deller <deller@gmx.de>
Cc: stable@vger.kernel.org # v5.8+
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Gao Xiang and committed by
Helge Deller
4d752e5a 9054284e

+1 -1
+1 -1
arch/parisc/include/asm/cmpxchg.h
··· 72 72 #endif 73 73 case 4: return __cmpxchg_u32((unsigned int *)ptr, 74 74 (unsigned int)old, (unsigned int)new_); 75 - case 1: return __cmpxchg_u8((u8 *)ptr, (u8)old, (u8)new_); 75 + case 1: return __cmpxchg_u8((u8 *)ptr, old & 0xff, new_ & 0xff); 76 76 } 77 77 __cmpxchg_called_with_bad_pointer(); 78 78 return old;