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

Message ID 1425281223-14043-1-git-send-email-michael.qiu@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Michael Qiu March 2, 2015, 7:27 a.m. UTC
  /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@intel.com>
---
 lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Sergio Gonzalez Monroy March 2, 2015, 11:39 a.m. UTC | #1
On 02/03/2015 07:27, 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@intel.com>
> ---
>   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..6565c00 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)(void *)dst & 0x0F) + 16;
You may as well remove the (void *) casting, I don't think it is necessary.
>   	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)(const void *)src & 0x0F);
Same here for (const void *)

Sergio
>   
>   	/**
>   	 * For aligned copy
  
Michael Qiu March 3, 2015, 2:02 a.m. UTC | #2
On 3/2/2015 7:39 PM, Gonzalez Monroy, Sergio wrote:
> On 02/03/2015 07:27, 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@intel.com>
>> ---
>>   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..6565c00 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)(void *)dst & 0x0F) + 16;
> You may as well remove the (void *) casting, I don't think it is necessary.

Yes, you are right. The original type is (void *).

Thanks,
Michael
>>   	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)(const void *)src & 0x0F);
> Same here for (const void *)
>
> Sergio
>>   
>>   	/**
>>   	 * For aligned copy
>
  

Patch

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..6565c00 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)(void *)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)(const void *)src & 0x0F);
 
 	/**
 	 * For aligned copy