From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Qiu Subject: [PATCH] librte_eal/common: Fix cast from pointer to integer of different size Date: Fri, 6 Mar 2015 11:13:07 +0800 Message-ID: <1425611587-769-1-git-send-email-michael.qiu@intel.com> References: <1425541598-8669-1-git-send-email-michael.qiu@intel.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1425541598-8669-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" ./i686-native-linuxapp-gcc/include/rte_memcpy.h:592:23: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16; Type 'long long' is 64-bit in i686 platform while 'void *' is 32-bit. Signed-off-by: Michael Qiu Signed-off-by: Zhihong Wang --- v4 --> v3: fix dstofss/bits to size_t in rte_memcpy() v3 --> v2: make dstofss and srcofs to be type size_t casting type use uintptr_t v2 --> v1: Remove unnecessary casting (void *) lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h index 7b2d382..6ec4434 100644 --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h @@ -196,8 +196,8 @@ static inline void * rte_memcpy(void *dst, const void *src, size_t n) { void *ret = dst; - int dstofss; - int bits; + size_t dstofss; + size_t bits; /** * Copy less than 16 bytes @@ -271,7 +271,7 @@ COPY_BLOCK_64_BACK31: /** * Make store aligned when copy size exceeds 512 bytes */ - dstofss = 32 - (int)((long long)(void *)dst & 0x1F); + dstofss = 32 - ((uintptr_t)dst & 0x1F); n -= dstofss; rte_mov32((uint8_t *)dst, (const uint8_t *)src); src = (const uint8_t *)src + dstofss; @@ -493,8 +493,8 @@ rte_memcpy(void *dst, const void *src, size_t n) { __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; void *ret = dst; - int dstofss; - int srcofs; + size_t dstofss; + size_t srcofs; /** * Copy less than 16 bytes @@ -589,12 +589,12 @@ COPY_BLOCK_64_BACK15: * unaligned copy functions require up to 15 bytes * backwards access. */ - dstofss = 16 - (int)((long long)(void *)dst & 0x0F) + 16; + dstofss = 16 - ((uintptr_t)dst & 0x0F) + 16; n -= dstofss; rte_mov32((uint8_t *)dst, (const uint8_t *)src); src = (const uint8_t *)src + dstofss; dst = (uint8_t *)dst + dstofss; - srcofs = (int)((long long)(const void *)src & 0x0F); + srcofs = ((uintptr_t)src & 0x0F); /** * For aligned copy -- 1.9.3