From: Andrew Morton <akpm@linux-foundation.org>
To: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
Cc: linux-kselftest@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com>,
Wei Yang <richard.weiyang@gmail.com>,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] selftests/user_events: Avoid taking address of packed member in perf_test
Date: Tue, 28 Oct 2025 13:26:05 -0700 [thread overview]
Message-ID: <20251028132605.2926d3ef5eb6ea60d22ceffe@linux-foundation.org> (raw)
In-Reply-To: <aQD2Igc3svAF3klc@fedora>
On Tue, 28 Oct 2025 22:28:10 +0530 Ankit Khushwaha <ankitkhushwaha.linux@gmail.com> wrote:
> > > @@ -236,7 +237,8 @@ TEST_F(user, perf_empty_events) {
> > > ASSERT_EQ(1 << reg.enable_bit, self->check);
> > >
> > > /* Ensure write shows up at correct offset */
> > > - ASSERT_NE(-1, write(self->data_fd, ®.write_index,
> > > + memcpy(&write_index, ®.write_index, sizeof(reg.write_index));
> > > + ASSERT_NE(-1, write(self->data_fd, &write_index,
> > > sizeof(reg.write_index)));
> >
> > Simply casting &write_index to void* would fix this?
>
> yes, this hides the type mismatch from the compiler. But i think
> casting to void * will not fix the alignment mismatch for packed struct.
> It works on x86, but might break on other platform.
It's the second argument to write(2)! write(2) expects a const char *,
but void* will work.
next prev parent reply other threads:[~2025-10-28 20:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 11:34 [PATCH] selftests/user_events: Avoid taking address of packed member in perf_test Ankit Khushwaha
2025-10-27 23:25 ` Andrew Morton
2025-10-28 16:58 ` Ankit Khushwaha
2025-10-28 20:26 ` Andrew Morton [this message]
2025-10-29 15:20 ` Ankit Khushwaha
2025-11-01 3:19 ` Andrew Morton
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=20251028132605.2926d3ef5eb6ea60d22ceffe@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ankitkhushwaha.linux@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=reddybalavignesh9979@gmail.com \
--cc=richard.weiyang@gmail.com \
--cc=rostedt@goodmis.org \
--cc=shuah@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