linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers
@ 2021-04-06  4:59 Gao Xiang
  2021-04-06  8:49 ` Rolf Eike Beer
  2021-04-06 10:08 ` Helge Deller
  0 siblings, 2 replies; 4+ messages in thread
From: Gao Xiang @ 2021-04-06  4:59 UTC (permalink / raw)
  To: linux-parisc, Helge Deller; +Cc: Liam Beguin, linux-kernel, Gao Xiang

From: Gao Xiang <hsiangkao@redhat.com>

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/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>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
 arch/parisc/include/asm/cmpxchg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/include/asm/cmpxchg.h b/arch/parisc/include/asm/cmpxchg.h
index cf5ee9b0b393..84ee232278a6 100644
--- a/arch/parisc/include/asm/cmpxchg.h
+++ b/arch/parisc/include/asm/cmpxchg.h
@@ -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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers
  2021-04-06  4:59 [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers Gao Xiang
@ 2021-04-06  8:49 ` Rolf Eike Beer
  2021-04-06 10:08 ` Helge Deller
  1 sibling, 0 replies; 4+ messages in thread
From: Rolf Eike Beer @ 2021-04-06  8:49 UTC (permalink / raw)
  To: linux-parisc, Helge Deller, Gao Xiang
  Cc: Liam Beguin, linux-kernel, Gao Xiang

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

Am Dienstag, 6. April 2021, 06:59:29 CEST schrieb Gao Xiang:
> From: Gao Xiang <hsiangkao@redhat.com>
> 
> 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].


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers
  2021-04-06  4:59 [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers Gao Xiang
  2021-04-06  8:49 ` Rolf Eike Beer
@ 2021-04-06 10:08 ` Helge Deller
  2021-04-06 10:57   ` Gao Xiang
  1 sibling, 1 reply; 4+ messages in thread
From: Helge Deller @ 2021-04-06 10:08 UTC (permalink / raw)
  To: Gao Xiang, linux-parisc; +Cc: Liam Beguin, linux-kernel, Gao Xiang

On 4/6/21 6:59 AM, Gao Xiang wrote:
> From: Gao Xiang <hsiangkao@redhat.com>
>
> 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/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>
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>

applied to the parisc for-next git tree.
(I fixed up the typo above too)

Thanks!
Helge

> ---
>   arch/parisc/include/asm/cmpxchg.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/parisc/include/asm/cmpxchg.h b/arch/parisc/include/asm/cmpxchg.h
> index cf5ee9b0b393..84ee232278a6 100644
> --- a/arch/parisc/include/asm/cmpxchg.h
> +++ b/arch/parisc/include/asm/cmpxchg.h
> @@ -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;
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers
  2021-04-06 10:08 ` Helge Deller
@ 2021-04-06 10:57   ` Gao Xiang
  0 siblings, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2021-04-06 10:57 UTC (permalink / raw)
  To: Helge Deller; +Cc: Gao Xiang, linux-parisc, Liam Beguin, linux-kernel

On Tue, Apr 06, 2021 at 12:08:55PM +0200, Helge Deller wrote:
> On 4/6/21 6:59 AM, Gao Xiang wrote:
> > From: Gao Xiang <hsiangkao@redhat.com>
> > 
> > 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/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>
> > Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
> 
> applied to the parisc for-next git tree.
> (I fixed up the typo above too)

Thanks all! :)

Thanks,
Gao Xiang

> 
> Thanks!
> Helge
> 
> > ---
> >   arch/parisc/include/asm/cmpxchg.h | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/parisc/include/asm/cmpxchg.h b/arch/parisc/include/asm/cmpxchg.h
> > index cf5ee9b0b393..84ee232278a6 100644
> > --- a/arch/parisc/include/asm/cmpxchg.h
> > +++ b/arch/parisc/include/asm/cmpxchg.h
> > @@ -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;
> > 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-06 10:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06  4:59 [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers Gao Xiang
2021-04-06  8:49 ` Rolf Eike Beer
2021-04-06 10:08 ` Helge Deller
2021-04-06 10:57   ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).