librte_eal/common: Fix cast from pointer to integer of different size
PATCH 1/1 librte_eal/common: Fix cast from pointer to integer of different size
/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.
--- lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
@@ -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
Signature · 1 line
1.9.3
A message that is not in the archive (sent off-list or not yet received): 1425281223-14043-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Quoted 19 lines · Michael Qiu
/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 <[email protected]>--- lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-0
lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 592
Quoted 5 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +1
-1@@ -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.
lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 597
Quoted 6 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +1
-1n -= 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
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-0/** * For aligned copy
Quoted 15 lines · Sergio
Quoted 14 lines · Michael Qiu
/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 <[email protected]>--- lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 11 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 592
Quoted 10 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +1
-1@@ -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
Quoted 13 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 597
Quoted 6 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +1
-1n -= 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
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-0/** * For aligned copy
PATCH v2 1/1 librte_eal/common: Fix cast from pointer to integer of different size
In reply to a message not in the archive/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.
---
v2 --> v1:
Remove unnecessary casting (void *)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
@@ -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
Signature · 1 line
1.9.3
A message that is not in the archive (sent off-list or not yet received): 1425349251-15663-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Quoted 27 lines · Michael Qiu
/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 <[email protected]>---
v2 --> v1:
Remove unnecessary casting (void *)lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-1@@ -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 ;
lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 600
Quoted 10 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2
-1+ 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.
Signature · 1 line
Pawel
Quoted 35 lines · PawelX
Quoted 34 lines · Michael Qiu
/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 <[email protected]>---
v2 --> v1:
Remove unnecessary casting (void *)lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2
-2@@ -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 );
Quoted 4 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 600
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-0/** * For aligned copy I think you should use here
size_t, (u)ptrdiff_t or (u)intptr_t as this
Yes, but 'long' is enough, does it limit anything, or has any issue with multiple platforms?
Quoted 2 lines
will be more portable.
Also type of dstofss and srcofs should be changed accordingly.
No, I think, it should be offset.
Thanks,
Michael
Quoted 1 line
A message that is not in the archive (sent off-list or not yet received): 533710CFB86FA344BFBF2D6802E60286CED932-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Quoted 44 lines
-----Original Message-----
From: Qiu, Michael
Sent: Tuesday, March 03, 2015 11:00 AM
To: Wodkowski, PawelX; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different sizeQuoted 15 lines · PawelX
Quoted 14 lines · Michael Qiu
/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 <[email protected]>---
v2 --> v1:
Remove unnecessary casting (void *)Quoted 4 lines
Review
Quoted 4 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.hQuoted 16 lines
Quoted 16 lines
index 7b2d382..85a5f4d 100644
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2
-2@@ -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 );
Quoted 8 lines
Quoted 4 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 600
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-0/** * For aligned copy I think you should use here
size_t, (u)ptrdiff_t or (u)intptr_t as thisYes, but 'long' is enough, does it limit anything, or has any issue with multiple platforms?
Those types ((u)ptrdiff_t, (u)intptr_t) exists specially for pointer-to-int and int-to-pointer casts. Using integer primitives might produce further warnings/error in the future and need further patches fixing the same place.
Also why make offset variables signed and different type? This introduce a lot of unnecessary explicit and implicit casts or type promotions.
Quoted 8 lines
Quoted 2 lines
will be more portable.
Also type of dstofss and srcofs should be changed accordingly.No, I think, it should be offset.
Thanks,
MichaelQuoted 1 line
Signature · 1 line
Pawel
Quoted 48 lines · PawelX
Quoted 48 lines
-----Original Message-----
From: Qiu, Michael
Sent: Tuesday, March 03, 2015 11:00 AM
To: Wodkowski, PawelX; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different sizeQuoted 15 lines · PawelX
Quoted 14 lines · Michael Qiu
/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 <[email protected]>---
v2 --> v1:
Remove unnecessary casting (void *)Quoted 4 lines
Review
Quoted 4 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.hQuoted 20 lines
Quoted 9 lines
index 7b2d382..85a5f4d 100644
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-1@@ -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 ;lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 600
Quoted 10 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2
-1+ 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
Quoted 7 lines
Quoted 3 lines
Yes, but 'long' is enough, does it limit anything, or has any issue with multiple platforms?
Those types ((u)ptrdiff_t, (u)intptr_t) exists specially for pointer-to-int and int-to-pointer casts. Using integer primitives might produce further warnings/error in the future and need further patches fixing the same place.
OK, I will send out the v3 patch.
Quoted 2 lines
Also why make offset variables signed and different type? This introduce a lot of unnecessary explicit and implicit casts or type promotions.
But Is it suitable to make offset (u)ptrdiff_t or (u)intptr_t?
Thanks,
Michael
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
will be more portable.
Also type of dstofss and srcofs should be changed accordingly.No, I think, it should be offset.
Thanks,
Michael
A message that is not in the archive (sent off-list or not yet received): 533710CFB86FA344BFBF2D6802E60286CEDC0D-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Quoted 57 lines · Michael
Quoted 48 lines · PawelX
Quoted 48 lines
-----Original Message-----
From: Qiu, Michael
Sent: Tuesday, March 03, 2015 11:00 AM
To: Wodkowski, PawelX; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different sizeQuoted 15 lines · PawelX
Quoted 14 lines · Michael Qiu
/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 <[email protected]>---
v2 --> v1:
Remove unnecessary casting (void *)Quoted 4 lines
Review
Quoted 4 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.hQuoted 20 lines
Quoted 9 lines
index 7b2d382..85a5f4d 100644
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-1@@ -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 ;lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 600
Quoted 10 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2
-1+ 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 thisQuoted 7 lines
Quoted 3 lines
Yes, but 'long' is enough, does it limit anything, or has any issue with multiple platforms?
Those types ((u)ptrdiff_t, (u)intptr_t) exists specially for pointer-to-int and int-to-pointer casts. Using integer primitives might produce further warnings/error in the future and need further patches fixing the same place.
Quoted 7 lines
OK, I will send out the v3 patch.
Quoted 2 lines
Also why make offset variables signed and different type? This introduce a lot of unnecessary explicit and implicit casts or type promotions.
But Is it suitable to make offset (u)ptrdiff_t or (u)intptr_t?
I think, as final result is offset, its type should be size_t (the same type as type of offsetof() macro). This way you can use uptrdiff_t/uintptr_t and does not need of any signed-unsigned casting.
Quoted 12 lines
Thanks,
MichaelQuoted 7 lines
Quoted 6 lines
Quoted 2 lines
will be more portable.
Also type of dstofss and srcofs should be changed accordingly.No, I think, it should be offset.
Thanks,
Michael
Signature · 1 line
Pawel
Quoted 59 lines · PawelX
Quoted 58 lines · Michael
Quoted 48 lines · PawelX
Quoted 48 lines
-----Original Message-----
From: Qiu, Michael
Sent: Tuesday, March 03, 2015 11:00 AM
To: Wodkowski, PawelX; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different sizeQuoted 15 lines · PawelX
Quoted 14 lines · Michael Qiu
/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 <[email protected]>---
v2 --> v1:
Remove unnecessary casting (void *)Quoted 4 lines
Review
Quoted 4 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/common/include/arch/x86/rte_memcpy.hQuoted 20 lines
Quoted 9 lines
index 7b2d382..85a5f4d 100644
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0
-1@@ -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 ;lib/librte_eal/common/include/arch/x86/rte_memcpy.h COPY_BLOCK_64_BACK15: · line 600
Quoted 10 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2
-1+ 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 thisQuoted 7 lines
Quoted 3 lines
Yes, but 'long' is enough, does it limit anything, or has any issue with multiple platforms?
Those types ((u)ptrdiff_t, (u)intptr_t) exists specially for pointer-to-int and int-to-pointer casts. Using integer primitives might produce further warnings/error in the future and need further patches fixing the same place.
OK, I will send out the v3 patch.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Also why make offset variables signed and different type? This introduce a lot of unnecessary explicit and implicit casts or type promotions.
But Is it suitable to make offset (u)ptrdiff_t or (u)intptr_t?
I think, as final result is offset, its type should be
size_t(the same type as type ofoffsetof()macro). This way you can use uptrdiff_t/uintptr_t and does not need of any signed-unsigned casting.
size_t should be acceptable
Thanks,
Michael
Quoted 12 lines
Quoted 11 lines
Thanks,
MichaelQuoted 6 lines
Quoted 6 lines
Quoted 2 lines
will be more portable.
Also type of dstofss and srcofs should be changed accordingly.No, I think, it should be offset.
Thanks,
Michael
PATCH v3 1/1 librte_eal/common: Fix cast from pointer to integer of different size
In reply to a message not in the archive./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.
---
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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +4 -4
@@ -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
Signature · 1 line
1.9.3
A message that is not in the archive (sent off-list or not yet received): 1425541598-8669-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Tang, HaifengX
Tested-byPatch name: [dpdk-dev] [PATCH v3] librte_eal/common: Fix cast from pointer to integer of different size
Test Env :
Fedora 18 , 3.6.10-4 ,4.7.2 ,14.0.0
Fedora20 ,3.11.0,4.8.2,14.0.0
Fedora21,3.17.4-302,4.9.2,15.0.0
Ubuntu 14.04, 3.13.0-30, 4.8.2, 14.0.0
Test Result:
error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] problem fixed now
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Michael Qiu
Sent: Thursday, March 05, 2015 3:47 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v3] librte_eal/common: Fix cast from pointer to integer of different size
./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.
---
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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +4 -4
@@ -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
PATCH 1/1 librte_eal/common: Fix cast from pointer to integer of different size
In reply to a message not in the archive./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.
---
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(-)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +7 -7
@@ -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
Signature · 1 line
1.9.3
A message that is not in the archive (sent off-list or not yet received): 1425611587-769-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Wang, Zhihong
Acked-byQuoted 84 lines
-----Original Message-----
From: Qiu, Michael
Sent: Friday, March 06, 2015 11:13 AM
To: [email protected]
Cc: Qiu, Michael; Wang, Zhihong
Subject: [PATCH] librte_eal/common: Fix cast from pointer to integer of different size
./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 <[email protected]>Signed-off-by Zhihong Wang <[email protected]>---
v4 --> v3:
fix dstofss/bits tosize_tinrte_memcpy()
v3 --> v2:
make dstofss and srcofs to be typesize_tcasting type useuintptr_tv2 --> v1:
Remove unnecessary casting (void *)lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)lib/librte_eal/common/include/arch/x86/rte_memcpy.h +7
-8@@ -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 --
Quoted 1 line
1.9.3
A message that is not in the archive (sent off-list or not yet received): F60F360A2500CD45ACDB1D700268892D0E792B73-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Thomas Monjalon
AppliedQuoted 17 lines
Quoted 17 lines
./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 <[email protected]>Signed-off-by Zhihong Wang <[email protected]>---
v4 --> v3:
fix dstofss/bits tosize_tinrte_memcpy()
v3 --> v2:
make dstofss and srcofs to be typesize_tcasting type useuintptr_t
Quoted 4 lines
Quoted 2 lines
v2 --> v1:
Remove unnecessary casting (void *)Acked-by Wang, Zhihong <[email protected]>
Applied, thanks