From: Alexey Dobriyan <adobriyan@gmail.com>
To: Brian Gerst <brgerst@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>,
x86@kernel.org
Subject: cast inside __pcpu_cast_1 macro
Date: Tue, 12 Dec 2023 14:49:10 +0300 [thread overview]
Message-ID: <c107538b-4e4a-4698-aca2-327eacdc15b2@p183> (raw)
Hi, Brian.
You've added the following macros in
commit 6865dc3ae93b9acb336ca48bd7b2db3446d89370
x86/percpu: Introduce size abstraction macros
+#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))
They break complation if "val" is something complex like
this_cpu_write(pcp, *x = 1);
Only __pcpu_cast_8() is correct in this regard.
"val" should be in parenthesis at least.
Is there a reason for casts to "unsigned long"?
Why not just
#define __pcpu_cast_1(val) ((u8)(val))
reply other threads:[~2023-12-12 11:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=c107538b-4e4a-4698-aca2-327eacdc15b2@p183 \
--to=adobriyan@gmail.com \
--cc=brgerst@gmail.com \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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