From: Gao Xiang <xiang@kernel.org>
To: linux-parisc@vger.kernel.org, Helge Deller <deller@gmx.de>
Cc: Liam Beguin <liambeguin@gmail.com>,
linux-kernel@vger.kernel.org, Gao Xiang <hsiangkao@redhat.com>
Subject: [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers
Date: Tue, 6 Apr 2021 12:59:29 +0800 [thread overview]
Message-ID: <20210406045929.30331-1-xiang@kernel.org> (raw)
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
next reply other threads:[~2021-04-06 4:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 4:59 Gao Xiang [this message]
2021-04-06 8:49 ` [PATCH] parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers Rolf Eike Beer
2021-04-06 10:08 ` Helge Deller
2021-04-06 10:57 ` Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210406045929.30331-1-xiang@kernel.org \
--to=xiang@kernel.org \
--cc=deller@gmx.de \
--cc=hsiangkao@redhat.com \
--cc=liambeguin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox