* [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size @ 2015-03-02 7:27 Michael Qiu 2015-03-02 11:39 ` Gonzalez Monroy, Sergio ` (2 more replies) 0 siblings, 3 replies; 15+ messages in thread From: Michael Qiu @ 2015-03-02 7:27 UTC (permalink / raw) To: 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 <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; 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 -- 1.9.3 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-02 7:27 [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size Michael Qiu @ 2015-03-02 11:39 ` Gonzalez Monroy, Sergio 2015-03-03 2:02 ` Qiu, Michael 2015-03-03 2:20 ` [dpdk-dev] [PATCH v2] " Michael Qiu 2015-03-05 7:46 ` [dpdk-dev] [PATCH v3] " Michael Qiu 2 siblings, 1 reply; 15+ messages in thread From: Gonzalez Monroy, Sergio @ 2015-03-02 11:39 UTC (permalink / raw) To: Michael Qiu; +Cc: dev 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-02 11:39 ` Gonzalez Monroy, Sergio @ 2015-03-03 2:02 ` Qiu, Michael 0 siblings, 0 replies; 15+ messages in thread From: Qiu, Michael @ 2015-03-03 2:02 UTC (permalink / raw) To: Gonzalez Monroy, Sergio; +Cc: dev 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 > ^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-02 7:27 [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size Michael Qiu 2015-03-02 11:39 ` Gonzalez Monroy, Sergio @ 2015-03-03 2:20 ` Michael Qiu 2015-03-03 8:25 ` Pawel Wodkowski 2015-03-05 7:46 ` [dpdk-dev] [PATCH v3] " Michael Qiu 2 siblings, 1 reply; 15+ messages in thread From: Michael Qiu @ 2015-03-03 2:20 UTC (permalink / raw) To: 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 <michael.qiu@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 -- 1.9.3 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-03 2:20 ` [dpdk-dev] [PATCH v2] " Michael Qiu @ 2015-03-03 8:25 ` Pawel Wodkowski 2015-03-03 9:59 ` Qiu, Michael 0 siblings, 1 reply; 15+ messages in thread From: Pawel Wodkowski @ 2015-03-03 8:25 UTC (permalink / raw) To: Michael Qiu, dev 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@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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-03 8:25 ` Pawel Wodkowski @ 2015-03-03 9:59 ` Qiu, Michael 2015-03-03 13:37 ` Pawel Wodkowski 0 siblings, 1 reply; 15+ messages in thread From: Qiu, Michael @ 2015-03-03 9:59 UTC (permalink / raw) To: Wodkowski, PawelX, dev On 3/3/2015 4:25 PM, Wodkowski, PawelX wrote: > 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@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 Yes, but 'long' is enough, does it limit anything, or has any issue with multiple platforms? > will be more portable. > Also type of dstofss and srcofs should be changed accordingly. No, I think, it should be offset. Thanks, Michael > ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-03 9:59 ` Qiu, Michael @ 2015-03-03 13:37 ` Pawel Wodkowski 2015-03-04 1:58 ` Qiu, Michael 0 siblings, 1 reply; 15+ messages in thread From: Pawel Wodkowski @ 2015-03-03 13:37 UTC (permalink / raw) To: Qiu, Michael, dev > -----Original Message----- > From: Qiu, Michael > Sent: Tuesday, March 03, 2015 11:00 AM > To: Wodkowski, PawelX; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to > integer of different size > > On 3/3/2015 4:25 PM, Wodkowski, PawelX wrote: > > 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@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 > > 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. Also why make offset variables signed and different type? This introduce a lot of unnecessary explicit and implicit casts or type promotions. > > will be more portable. > > Also type of dstofss and srcofs should be changed accordingly. > > No, I think, it should be offset. > > Thanks, > Michael > > -- Pawel ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-03 13:37 ` Pawel Wodkowski @ 2015-03-04 1:58 ` Qiu, Michael 2015-03-04 8:18 ` Pawel Wodkowski 0 siblings, 1 reply; 15+ messages in thread From: Qiu, Michael @ 2015-03-04 1:58 UTC (permalink / raw) To: Wodkowski, PawelX, dev On 3/3/2015 9:38 PM, Wodkowski, PawelX wrote: >> -----Original Message----- >> From: Qiu, Michael >> Sent: Tuesday, March 03, 2015 11:00 AM >> To: Wodkowski, PawelX; dev@dpdk.org >> Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to >> integer of different size >> >> On 3/3/2015 4:25 PM, Wodkowski, PawelX wrote: >>> 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@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 >> 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. > 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 >>> will be more portable. >>> Also type of dstofss and srcofs should be changed accordingly. >> No, I think, it should be offset. >> >> Thanks, >> Michael > ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-04 1:58 ` Qiu, Michael @ 2015-03-04 8:18 ` Pawel Wodkowski 2015-03-04 11:24 ` Qiu, Michael 0 siblings, 1 reply; 15+ messages in thread From: Pawel Wodkowski @ 2015-03-04 8:18 UTC (permalink / raw) To: Qiu, Michael, dev On 2015-03-04 02:58, Qiu, Michael wrote: > On 3/3/2015 9:38 PM, Wodkowski, PawelX wrote: >>> -----Original Message----- >>> From: Qiu, Michael >>> Sent: Tuesday, March 03, 2015 11:00 AM >>> To: Wodkowski, PawelX; dev@dpdk.org >>> Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to >>> integer of different size >>> >>> On 3/3/2015 4:25 PM, Wodkowski, PawelX wrote: >>>> 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@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 >>> 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. > >> 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. > Thanks, > Michael > >>>> will be more portable. >>>> Also type of dstofss and srcofs should be changed accordingly. >>> No, I think, it should be offset. >>> >>> Thanks, >>> Michael >> > > -- Pawel ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-04 8:18 ` Pawel Wodkowski @ 2015-03-04 11:24 ` Qiu, Michael 0 siblings, 0 replies; 15+ messages in thread From: Qiu, Michael @ 2015-03-04 11:24 UTC (permalink / raw) To: Wodkowski, PawelX, dev On 3/4/2015 4:19 PM, Wodkowski, PawelX wrote: > On 2015-03-04 02:58, Qiu, Michael wrote: >> On 3/3/2015 9:38 PM, Wodkowski, PawelX wrote: >>>> -----Original Message----- >>>> From: Qiu, Michael >>>> Sent: Tuesday, March 03, 2015 11:00 AM >>>> To: Wodkowski, PawelX; dev@dpdk.org >>>> Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to >>>> integer of different size >>>> >>>> On 3/3/2015 4:25 PM, Wodkowski, PawelX wrote: >>>>> 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@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 >>>> 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. >> >>> 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. size_t should be acceptable Thanks, Michael > >> Thanks, >> Michael >> >>>>> will be more portable. >>>>> Also type of dstofss and srcofs should be changed accordingly. >>>> No, I think, it should be offset. >>>> >>>> Thanks, >>>> Michael >> > ^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v3] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-02 7:27 [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size Michael Qiu 2015-03-02 11:39 ` Gonzalez Monroy, Sergio 2015-03-03 2:20 ` [dpdk-dev] [PATCH v2] " Michael Qiu @ 2015-03-05 7:46 ` Michael Qiu 2015-03-05 8:25 ` Tang, HaifengX 2015-03-06 3:13 ` [dpdk-dev] [PATCH] " Michael Qiu 2 siblings, 2 replies; 15+ messages in thread From: Michael Qiu @ 2015-03-05 7:46 UTC (permalink / raw) To: 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 <michael.qiu@intel.com> --- 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(-) 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..aa433e4 100644 --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h @@ -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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v3] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-05 7:46 ` [dpdk-dev] [PATCH v3] " Michael Qiu @ 2015-03-05 8:25 ` Tang, HaifengX 2015-03-06 3:13 ` [dpdk-dev] [PATCH] " Michael Qiu 1 sibling, 0 replies; 15+ messages in thread From: Tang, HaifengX @ 2015-03-05 8:25 UTC (permalink / raw) To: Qiu, Michael, dev Tested-by: haifeng.tang <haifengx.tang@intel.com> Patch 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:dev-bounces@dpdk.org] On Behalf Of Michael Qiu Sent: Thursday, March 05, 2015 3:47 PM To: dev@dpdk.org 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. Signed-off-by: Michael Qiu <michael.qiu@intel.com> --- 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(-) 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..aa433e4 100644 --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h @@ -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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-05 7:46 ` [dpdk-dev] [PATCH v3] " Michael Qiu 2015-03-05 8:25 ` Tang, HaifengX @ 2015-03-06 3:13 ` Michael Qiu 2015-03-09 5:38 ` Wang, Zhihong 1 sibling, 1 reply; 15+ messages in thread From: Michael Qiu @ 2015-03-06 3:13 UTC (permalink / raw) To: 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 <michael.qiu@intel.com> Signed-off-by: Zhihong Wang <zhihong.wang@intel.com> --- 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-06 3:13 ` [dpdk-dev] [PATCH] " Michael Qiu @ 2015-03-09 5:38 ` Wang, Zhihong 2015-03-09 11:43 ` Thomas Monjalon 0 siblings, 1 reply; 15+ messages in thread From: Wang, Zhihong @ 2015-03-09 5:38 UTC (permalink / raw) To: dev, Qiu, Michael > -----Original Message----- > From: Qiu, Michael > Sent: Friday, March 06, 2015 11:13 AM > To: dev@dpdk.org > 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 <michael.qiu@intel.com> > Signed-off-by: Zhihong Wang <zhihong.wang@intel.com> > --- > 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 Acked-by: Wang, Zhihong <zhihong.wang@intel.com> ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size 2015-03-09 5:38 ` Wang, Zhihong @ 2015-03-09 11:43 ` Thomas Monjalon 0 siblings, 0 replies; 15+ messages in thread From: Thomas Monjalon @ 2015-03-09 11:43 UTC (permalink / raw) To: Qiu, Michael; +Cc: 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 <michael.qiu@intel.com> > > Signed-off-by: Zhihong Wang <zhihong.wang@intel.com> > > --- > > 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 *) > > Acked-by: Wang, Zhihong <zhihong.wang@intel.com> Applied, thanks ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2015-03-09 11:50 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-03-02 7:27 [dpdk-dev] [PATCH] librte_eal/common: Fix cast from pointer to integer of different size Michael Qiu 2015-03-02 11:39 ` Gonzalez Monroy, Sergio 2015-03-03 2:02 ` Qiu, Michael 2015-03-03 2:20 ` [dpdk-dev] [PATCH v2] " Michael Qiu 2015-03-03 8:25 ` Pawel Wodkowski 2015-03-03 9:59 ` Qiu, Michael 2015-03-03 13:37 ` Pawel Wodkowski 2015-03-04 1:58 ` Qiu, Michael 2015-03-04 8:18 ` Pawel Wodkowski 2015-03-04 11:24 ` Qiu, Michael 2015-03-05 7:46 ` [dpdk-dev] [PATCH v3] " Michael Qiu 2015-03-05 8:25 ` Tang, HaifengX 2015-03-06 3:13 ` [dpdk-dev] [PATCH] " Michael Qiu 2015-03-09 5:38 ` Wang, Zhihong 2015-03-09 11:43 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).