Message ID | 1425349251-15663-1-git-send-email-michael.qiu@intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 72269595A; Tue, 3 Mar 2015 03:21:05 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 30FB6106B for <dev@dpdk.org>; Tue, 3 Mar 2015 03:21:04 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 02 Mar 2015 18:21:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,679,1418112000"; d="scan'208";a="693041183" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 02 Mar 2015 18:20:59 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t232Kuoe017950; Tue, 3 Mar 2015 10:20:56 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t232Kq7k015697; Tue, 3 Mar 2015 10:20:54 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t232Kq8h015693; Tue, 3 Mar 2015 10:20:52 +0800 From: Michael Qiu <michael.qiu@intel.com> To: dev@dpdk.org Date: Tue, 3 Mar 2015 10:20:51 +0800 Message-Id: <1425349251-15663-1-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1425281223-14043-1-git-send-email-michael.qiu@intel.com> References: <1425281223-14043-1-git-send-email-michael.qiu@intel.com> Subject: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Michael Qiu
March 3, 2015, 2:20 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>
---
v2 --> v1:
Remove unnecessary casting (void *)
lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
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.
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 >
> -----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 > >
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 >
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 >> > >
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 >> >
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