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

Tom Rini
2013-04-16T23:00:49Z

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/16/2013 05:57 PM, Simon Glass wrote:
> Hi Wolfgang,
>
> On Sat, Apr 6, 2013 at 12:04 AM, Wolfgang Denk <wd@denx.de> wrote:
>> Dear Simon Glass,
>>
>> In message <1365203470-9099-1-git-send-email-sjg@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?
>
> We always want big-endian in this case, since the bytes have to
> date been written that way by the crc32 command.

In other words, this code is executed on both the host and the target,
and there's not a uniform endian sanitizer function.

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRbdghAAoJENk4IS6UOR1WzzsP/j+JhIIkp9EK4YwDQ7H6F06V
i60/Y/EaVg32HAqMjo66y2GCcu7ak9fobZo3wHnAjrFkaSJWq4s+eDNOtJiHbr/O
ZwQbDJ/t5Yf7vuZ1OhBTII+pYHXYcDW+30QZpBP3+ydY8Zkg7tsAcQ5rH7KdHWuD
83k7DLjv9obn85eeVikNkfB7ONNFVRug07Obcd+jbXdQamc/VWxWZyvUwDiKGCYH
eqmss/hQ7o343FWKqsVNSxd3/tF7z3PNevWm83xJxlc5xbtyJ/8kad6qkkILtOGd
G5OOXnL7BpSqL2mxt5ruW+cwqOnp74SvoQXuM6lNZzeAmlirAginYbnDSvjQamIy
DK1BQAjodXGU7nZxffw4vKZzbGzkgRl2KkuGvQfpMJzoJRyWvrbDzIVOeF/bXXQS
UEvASOFAdqKpMPNJnIm16GUtH6/OyEWK+8HInFse7K19ycM4M/TpM2dhmVZrHG0S
Q+Xq7ZI6pEq0SjMIfhuCwYJS6lqbtlQ5eOk+KoTYXOWneOzOgDGKO+El53wDwKQ5
0icIUwNKn4ZKMg7HLE25Docx3Ez6OVBD2Aelz0wlc5FMWlmLrHe9oYaufDN36bBH
D5XrLeBDjj89mTOHl4V0U3tZ/1iLLFqxo9RyNG6lPkLOQD62vLPxjyPYqY8Q6q85
kPdToR/o/YfFk3EsiYpD
=0O7d
-----END PGP SIGNATURE-----