From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgw.gov.kz (mgw.gov.kz [89.218.88.242]) by dpdk.org (Postfix) with ESMTP id 285539AE3 for ; Tue, 24 Mar 2015 14:30:22 +0100 (CET) Received: from mgw.gov.kz (mx.ctsat.kz [178.89.4.95]) by mgw.gov.kz with ESMTP id t2ODUIhf008372-t2ODUIhg008372; Tue, 24 Mar 2015 19:30:18 +0600 Received: from EXCASHUB2.rgp.local (192.168.40.53) by EdgeForefront.rgp.local (192.168.40.59) with Microsoft SMTP Server (TLS) id 14.2.247.3; Tue, 24 Mar 2015 19:28:21 +0600 Received: from r220.rgp.local (192.168.59.10) by excashub2.rgp.local (192.168.40.48) with Microsoft SMTP Server (TLS) id 14.2.247.3; Tue, 24 Mar 2015 19:30:17 +0600 From: Yerden Zhumabekov To: Date: Tue, 24 Mar 2015 19:31:55 +0600 Message-ID: <3ba2a35fc1c2e9e3058d678908e2245d88bd7743.1427203852.git.e_zhumabekov@sts.kz> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.59.10] X-FEAS-SYSTEM-WL: e_zhumabekov@sts.kz Subject: [dpdk-dev] [PATCH v2] hash: fix breaking strict-aliasing rules X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Mar 2015 13:30:22 -0000 Fix rte_hash_crc() function by making use of uintptr_t variable to hold a pointer to data being hashed. In this way, casting uint64_t pointer to uint32_t avoided. Signed-off-by: Yerden Zhumabekov --- lib/librte_hash/rte_hash_crc.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h index 1cd626c..abdbd9a 100644 --- a/lib/librte_hash/rte_hash_crc.h +++ b/lib/librte_hash/rte_hash_crc.h @@ -513,35 +513,36 @@ rte_hash_crc(const void *data, uint32_t data_len, uint32_t init_val) { unsigned i; uint64_t temp = 0; - const uint64_t *p64 = (const uint64_t *)data; + uintptr_t pd = (uintptr_t) data; for (i = 0; i < data_len / 8; i++) { - init_val = rte_hash_crc_8byte(*p64++, init_val); + init_val = rte_hash_crc_8byte(*(const uint64_t *)pd, init_val); + pd += 8; } switch (7 - (data_len & 0x07)) { case 0: - temp |= (uint64_t) *((const uint8_t *)p64 + 6) << 48; + temp |= (uint64_t) *((const uint8_t *)pd + 6) << 48; /* Fallthrough */ case 1: - temp |= (uint64_t) *((const uint8_t *)p64 + 5) << 40; + temp |= (uint64_t) *((const uint8_t *)pd + 5) << 40; /* Fallthrough */ case 2: - temp |= (uint64_t) *((const uint8_t *)p64 + 4) << 32; - temp |= *((const uint32_t *)p64); + temp |= (uint64_t) *((const uint8_t *)pd + 4) << 32; + temp |= *(const uint32_t *)pd; init_val = rte_hash_crc_8byte(temp, init_val); break; case 3: - init_val = rte_hash_crc_4byte(*(const uint32_t *)p64, init_val); + init_val = rte_hash_crc_4byte(*(const uint32_t *)pd, init_val); break; case 4: - temp |= *((const uint8_t *)p64 + 2) << 16; + temp |= *((const uint8_t *)pd + 2) << 16; /* Fallthrough */ case 5: - temp |= *((const uint8_t *)p64 + 1) << 8; + temp |= *((const uint8_t *)pd + 1) << 8; /* Fallthrough */ case 6: - temp |= *((const uint8_t *)p64); + temp |= *(const uint8_t *)pd; init_val = rte_hash_crc_4byte(temp, init_val); /* Fallthrough */ default: -- 1.7.9.5