From: Giulio Benetti <giulio.benetti@benettiengineering.com>
To: linux-mmc@vger.kernel.org
Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
Subject: [PATCH] mmc-utils: mmc_cmds: fix type-punned warning on &ext_csd[] casting
Date: Tue, 5 Mar 2024 11:59:49 +0100 [thread overview]
Message-ID: <20240305105949.392092-1-giulio.benetti@benettiengineering.com> (raw)
When building with -Werror=strict-aliasing error is thrown:
mmc_cmds.c: In function 'do_ffu':
mmc_cmds.c:2972:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
sect_done = htole32(*((__u32 *)&ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_0]));
^
cc1: all warnings being treated as errors
Let's fix type-punned breaking strict-aliasing by memcpy() the variable.
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
mmc_cmds.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mmc_cmds.c b/mmc_cmds.c
index ae7b876..dcd60aa 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -2968,7 +2968,8 @@ do_retry:
}
/* Test if we need to restart the download */
- sect_done = htole32(*((__u32 *)&ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_0]));
+ memcpy(§_done, &ext_csd[EXT_CSD_NUM_OF_FW_SEC_PROG_0], sizeof(__u32));
+ sect_done = htole32(sect_done);
/* By spec, host should re-start download from the first sector if sect_done is 0 */
if (sect_done == 0) {
if (retry--) {
--
2.34.1
next reply other threads:[~2024-03-05 11:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 10:59 Giulio Benetti [this message]
2024-03-05 14:52 ` [PATCH] mmc-utils: mmc_cmds: fix type-punned warning on &ext_csd[] casting Avri Altman
2024-03-05 15:01 ` Avri Altman
2024-03-05 18:45 ` [PATCH v2] " Giulio Benetti
2024-03-05 19:48 ` Avri Altman
2024-03-07 11:02 ` Ulf Hansson
2024-03-05 18:46 ` [PATCH] " Giulio Benetti
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=20240305105949.392092-1-giulio.benetti@benettiengineering.com \
--to=giulio.benetti@benettiengineering.com \
--cc=linux-mmc@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).