From: Alexey Dobriyan <adobriyan@gmail.com>
To: dennis@kernel.org, tj@kernel.org, cl@linux.com
Cc: linux-mm@kvack.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
hpa@zytor.com
Subject: [PATCH] x86/percpu: fix cast in __pcpu_cast_* macros
Date: Mon, 27 May 2024 08:51:17 +0300 [thread overview]
Message-ID: <c818d685-6609-450b-a695-44b5c57518a7@p183> (raw)
Fix compile failure
this_cpu_add(*p, x = 1);
kernel/test.c:7:29: error: lvalue required as left operand of assignment
7 | this_cpu_add(*p, x = 1);
| ^
arch/x86/include/asm/percpu.h:134:51: note: in definition of macro '__pcpu_cast_1'
134 | #define __pcpu_cast_1(val) ((u8)(((unsigned long) val) & 0xff))
This pattern is almost always wrong:
#define M(x) ((T)x)
also because it can't be used with assignment expressions: cast makes
left part of it non-lvalue and assignment to non-lvalue has to break
compilation.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
arch/x86/include/asm/percpu.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -119,9 +119,9 @@
#define __pcpu_type_4 u32
#define __pcpu_type_8 u64
-#define __pcpu_cast_1(val) ((u8)(((unsigned long) val) & 0xff))
-#define __pcpu_cast_2(val) ((u16)(((unsigned long) val) & 0xffff))
-#define __pcpu_cast_4(val) ((u32)(((unsigned long) val) & 0xffffffff))
+#define __pcpu_cast_1(val) ((u8)((unsigned long)(val) & 0xff))
+#define __pcpu_cast_2(val) ((u16)((unsigned long)(val) & 0xffff))
+#define __pcpu_cast_4(val) ((u32)((unsigned long)(val) & 0xffffffff))
#define __pcpu_cast_8(val) ((u64)(val))
#define __pcpu_op1_1(op, dst) op "b " dst
next reply other threads:[~2024-05-27 5:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 5:51 Alexey Dobriyan [this message]
[not found] ` <81264b6c-fd23-2ee5-52cd-249047e317a7@linux.com>
2024-05-28 20:49 ` Dennis Zhou
2024-05-29 7:54 ` Thomas Gleixner
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=c818d685-6609-450b-a695-44b5c57518a7@p183 \
--to=adobriyan@gmail.com \
--cc=bp@alien8.de \
--cc=cl@linux.com \
--cc=dave.hansen@linux.intel.com \
--cc=dennis@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=x86@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