parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers
PATCH 1/1 parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers
From: Gao Xiang <[email protected]>
commit b344d6a83d01 ("parisc: add support for cmpxchg on u8 pointers") can generate a sparse warningi ("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/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/202008210829.KVwn7Xeh%[email protected]
[4] https://lore.kernel.org/r/[email protected]
--- arch/parisc/include/asm/cmpxchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/include/asm/cmpxchg.h +1 -1
@@ -72,7 +72,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)#endif case 4 :return __cmpxchg_u32 ((unsigned int *)ptr, (unsigned int )old, (unsigned int )new_); -case 1 :return __cmpxchg_u8 ((u8 *)ptr, (u8 )old, (u8 )new_); +case 1 :return __cmpxchg_u8 ((u8 *)ptr, old &0xff , new_ &0xff ); }__cmpxchg_called_with_bad_pointer ();return old;
Signature · 1 line
2.20.1
Am Dienstag, 6. April 2021, 06:59:29 CEST schrieb Gao Xiang:
Quoted 4 lines
From: Gao Xiang <[email protected]>
commit
b344d6a83d01("parisc: add support for cmpxchg on u8 pointers") can generate a sparse warningi ("cast truncates bits from constant
^
Quoted 1 line
value"), which has been reported several times [1] [2] [3].
Quoted 9 lines · Gao Xiang
From: Gao Xiang <[email protected]>
commit
b344d6a83d01("parisc: add support for cmpxchg on u8 pointers") can generate a sparse warningi ("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].
Quoted 7 lines
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/202008210829.KVwn7Xeh%[email protected]
[4] https://lore.kernel.org/r/[email protected]Cc Liam Beguin <[email protected]>Cc Helge Deller <[email protected]>Signed-off-by Gao Xiang <[email protected]>
applied to the parisc for-next git tree.
(I fixed up the typo above too)
Thanks!
Helge
Quoted 18 lines
--- arch/parisc/include/asm/cmpxchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/parisc/include/asm/cmpxchg.h +1
-1@@ -72,7 +72,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)#endif case 4 :return __cmpxchg_u32 ((unsigned int *)ptr, (unsigned int )old, (unsigned int )new_); -case 1 :return __cmpxchg_u8 ((u8 *)ptr, (u8 )old, (u8 )new_); +case 1 :return __cmpxchg_u8 ((u8 *)ptr, old &0xff , new_ &0xff ); }__cmpxchg_called_with_bad_pointer ();return old;
Quoted 18 lines · Helge Deller
Quoted 9 lines · Gao Xiang
From: Gao Xiang <[email protected]>
commit
b344d6a83d01("parisc: add support for cmpxchg on u8 pointers") can generate a sparse warningi ("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].
Quoted 7 lines
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/202008210829.KVwn7Xeh%[email protected]
[4] https://lore.kernel.org/r/[email protected]Cc Liam Beguin <[email protected]>Cc Helge Deller <[email protected]>Signed-off-by Gao Xiang <[email protected]>
Quoted 2 lines
applied to the parisc for-next git tree.
(I fixed up the typo above too)
Thanks all! :)
Thanks,
Gao Xiang
Quoted 23 lines
Thanks!
HelgeQuoted 18 lines
--- arch/parisc/include/asm/cmpxchg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/parisc/include/asm/cmpxchg.h +1
-1@@ -72,7 +72,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)#endif case 4 :return __cmpxchg_u32 ((unsigned int *)ptr, (unsigned int )old, (unsigned int )new_); -case 1 :return __cmpxchg_u8 ((u8 *)ptr, (u8 )old, (u8 )new_); +case 1 :return __cmpxchg_u8 ((u8 *)ptr, old &0xff , new_ &0xff ); }__cmpxchg_called_with_bad_pointer ();return old;