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 implementing local
per_byte_htole32(__u8 *) and use it for the 2 present occurences of
htole32(). Let's also change sect_done type to __u32 for consistency.

Suggested-by: Avri Altman <>
Fixes: a1b594ca735e ("mmc-utils: ffu: Simplify ext_csd bytes parsing")
Signed-off-by: Giulio Benetti <>
Reviewed-by: Avri Altman <>
Signed-off-by: Ulf Hansson <>
1 file changed