[U-Boot] [PATCH] crc32: Correct endianness of crc32 result

Wolfgang Denk wd at denx.de
Sat Apr 6 09:04:29 CEST 2013


Dear Simon Glass,

In message <1365203470-9099-1-git-send-email-sjg at chromium.org> you wrote:
> When crc32 is handled by the hash library, it requires the data to be in
> big-endian format, since it reads it byte-wise. Thus at present the 'crc32'
> command reports incorrect data. For example, previously we might see:


> +#ifdef USE_HOSTCC
> +	crc = htobe32(crc);
>  	memcpy(output, &crc, sizeof(crc));
> +#else
> +	put_unaligned_be32(crc, output);
> +#endif

Why is this depending on USE_HOSTCC, and not on the endianess?

And why do we need the #ifdef?  Can we not always use htobe32() and
put_unaligned_be32() ?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"UNIX was not designed to stop you from doing stupid things,  because
that would also stop you from doing clever things."       - Doug Gwyn


More information about the U-Boot mailing list