From: "Arnd Bergmann" <arnd@arndb.de>
To: "Takashi Iwai" <tiwai@suse.de>, "Arnd Bergmann" <arnd@kernel.org>
Cc: "Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH] ALSA: asihpi: avoid write overflow check warning
Date: Wed, 18 Mar 2026 13:16:14 +0100 [thread overview]
Message-ID: <74923a6e-fdce-4f15-b345-55fddcc4c7c2@app.fastmail.com> (raw)
In-Reply-To: <87eclhcpzo.wl-tiwai@suse.de>
On Wed, Mar 18, 2026, at 12:54, Takashi Iwai wrote:
> On Wed, 18 Mar 2026 11:50:08 +0100,
>> + memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].h, &hr,
>> + sizeof(rESP_HPI_ADAPTER_OPEN[adapter].h));
>> + memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].a, &hr.u.s,
>> + sizeof(rESP_HPI_ADAPTER_OPEN[adapter].a));
>
> I think the last one is still a bit confusing as if doing an overflow
> copy again: hr.u.s is struct hpi_subsys_res which is smaller than
> rESP_HPI_ADAPTER_OPEN[adapter].a which is struct hpi_adapter_res.
Right, I got confused by the various similarly named types
again.
> If any, the last one should be
>
> memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].a, &hr.u.ax.info,
> sizeof(rESP_HPI_ADAPTER_OPEN[adapter].a));
>
> Or it could be even
>
> rESP_HPI_ADAPTER_OPEN[adapter].a = hr.u.ax.info;
>
> (I'm not sure which one can be a better result, though.)
Code generation wise, I would expect them to be the same,
as gcc is good at transforming the memcpy() calls into
direct copies and vice versa.
I'll send a v2 with the first one after it passes build tests,
unless someone has another preference.
Arnd
prev parent reply other threads:[~2026-03-18 12:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 10:50 [PATCH] ALSA: asihpi: avoid write overflow check warning Arnd Bergmann
2026-03-18 11:54 ` Takashi Iwai
2026-03-18 12:16 ` Arnd Bergmann [this message]
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=74923a6e-fdce-4f15-b345-55fddcc4c7c2@app.fastmail.com \
--to=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=tiwai@suse.de \
/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