[dpdk-dev] [PATCH] hash: fix breaking strict-aliasing rules
Pawel Wodkowski
pawelx.wodkowski at intel.com
Fri Mar 20 13:47:55 CET 2015
On 2015-03-18 17:51, Yerden Zhumabekov wrote:
>
> - switch (7 - (data_len & 0x07)) {
> + i = 7 - (data_len & 0x07);
> + switch (i) {
> case 0:
> - temp |= (uint64_t) *((const uint8_t *)p64 + 6) << 48;
> - /* Fallthrough */
> case 1:
> - temp |= (uint64_t) *((const uint8_t *)p64 + 5) << 40;
> - /* Fallthrough */
> case 2:
> - temp |= (uint64_t) *((const uint8_t *)p64 + 4) << 32;
> - temp |= *((const uint32_t *)p64);
> + temp = odd_8byte_mask[i] & *p64;
> init_val = rte_hash_crc_8byte(temp, init_val);
> break;
> case 3:
> - init_val = rte_hash_crc_4byte(*(const uint32_t *)p64, init_val);
> - break;
> case 4:
> - temp |= *((const uint8_t *)p64 + 2) << 16;
> - /* Fallthrough */
> case 5:
> - temp |= *((const uint8_t *)p64 + 1) << 8;
> - /* Fallthrough */
> case 6:
> - temp |= *((const uint8_t *)p64);
> + temp = odd_8byte_mask[i] & *p64;
> init_val = rte_hash_crc_4byte(temp, init_val);
> - /* Fallthrough */
> default:
> break;
> }
>
Second thought: is this not an issue here reading 8 bytes by
dereferencing *p64 if there is less bytes in buffer?
--
Pawel
More information about the dev
mailing list