[dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size

Pawel Wodkowski pawelx.wodkowski at intel.com
Tue Mar 3 09:25:15 CET 2015


On 2015-03-03 03:20, Michael Qiu wrote:
> /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 <michael.qiu at intel.com>
> ---
> v2 --> v1:
> 	Remove unnecessary casting (void *)
>
>   lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 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..85a5f4d 100644
> --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> @@ -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 - (int)((long)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 = (int)((long)src & 0x0F);
>
>   	/**
>   	 * For aligned copy
>

I think you should use here size_t, (u)ptrdiff_t or (u)intptr_t as this 
will be more portable.
Also type of dstofss and srcofs should be changed accordingly.

-- 
Pawel


More information about the dev mailing list