On Wed, Jul 31, 2013 at 09:31:55AM +0900, Joe Stringer wrote:
> +ovs_be32
> +crc32c(const uint8_t *data, size_t size)
> +{
> + uint32_t crc = 0xffffffffL;
> +
> + while (size--) {
> + crc = crc32Table[(crc ^ *data++) & 0xff] ^ (crc >> 8);
> + }
> +
> + /* The result of this CRC calculation provides us a value in the reverse
> + * byte-order as compared with our architecture. On big-endian systems,
> + * this is opposite to our return type. So, to return a big-endian
> + * value, we must swap the byte-order. */
> +#if defined(WORDS_BIGENDIAN)
> + crc = get_unaligned_u32(&crc);
> +#endif
I don't see how this does any kind of byteswapping (as the comment
claims). Just treating 'crc' as unaligned (&crc should in fact be
properly aligned) has no effect. As far as I can tell it is
equivalent to "crc = crc;"
> + /* Our value is in network byte-order. OVS_FORCE keeps sparse happy. */
> + return (OVS_FORCE ovs_be32) ~crc;
> +}
Thanks,
Ben.
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev