package/mmc-utils: fix build failure due to type-punned error
PATCH 1/1 package/mmc-utils: fix build failure due to type-punned error
Add local patch pending upstream to fix:
mmc_cmds.c: In function 'do_ffu':
mmc_cmds.c:2971: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]));
^
Fixes:
http://autobuild.buildroot.net/results/06f972f95f4f2e0e7504b1fa069b89695b7377ef
Signed-off-by Giulio Benetti <[email protected]>
--- ...ds-fix-type-punned-warning-on-ext_cs.patch | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 package/mmc-utils/0001-mmc-utils-mmc_cmds-fix-type-punned-warning-on-ext_cs.patch
package/mmc-utils/0001-mmc-utils-mmc_cmds-fix-type-punned-warning-on-ext_cs.patch new file +40 -0
@@ -0,0 +1,40 @@ +From 18b2b6e2049cf650a2fb27992047cd439ee0d501 Mon Sep 17 00:00:00 2001 +From: Giulio Benetti <[email protected]> +Date: Tue, 5 Mar 2024 11:52:54 +0100 +Subject: [PATCH] mmc-utils: mmc_cmds: fix type-punned warning on &ext_csd[] + casting + +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. + +Upstream: https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/ + +Signed-off-by: Giulio Benetti <[email protected]> +--- + 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 +
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot