From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F07A9568F for ; Wed, 4 Mar 2015 12:24:07 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 04 Mar 2015 03:24:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,687,1418112000"; d="scan'208";a="660255494" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by orsmga001.jf.intel.com with ESMTP; 04 Mar 2015 03:24:06 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 4 Mar 2015 19:24:03 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.46]) with mapi id 14.03.0195.001; Wed, 4 Mar 2015 19:24:02 +0800 From: "Qiu, Michael" To: "Wodkowski, PawelX" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from pointer to integer of different size Thread-Index: AQHQVVixjCQ23eswG0KNXZTQD6fASA== Date: Wed, 4 Mar 2015 11:24:02 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CEE839@SHSMSX101.ccr.corp.intel.com> References: <1425281223-14043-1-git-send-email-michael.qiu@intel.com> <1425349251-15663-1-git-send-email-michael.qiu@intel.com> <54F56FEB.5050803@intel.com> <533710CFB86FA344BFBF2D6802E60286CED932@SHSMSX101.ccr.corp.intel.com> <54F5B92E.5090202@intel.com> <533710CFB86FA344BFBF2D6802E60286CEDC0D@SHSMSX101.ccr.corp.intel.com> <54F6BFC4.8080700@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2015 11:24:08 -0000 On 3/4/2015 4:19 PM, Wodkowski, PawelX wrote:=0A= > On 2015-03-04 02:58, Qiu, Michael wrote:=0A= >> On 3/3/2015 9:38 PM, Wodkowski, PawelX wrote:=0A= >>>> -----Original Message-----=0A= >>>> From: Qiu, Michael=0A= >>>> Sent: Tuesday, March 03, 2015 11:00 AM=0A= >>>> To: Wodkowski, PawelX; dev@dpdk.org=0A= >>>> Subject: Re: [dpdk-dev] [PATCH v2] librte_eal/common: Fix cast from po= inter to=0A= >>>> integer of different size=0A= >>>>=0A= >>>> On 3/3/2015 4:25 PM, Wodkowski, PawelX wrote:=0A= >>>>> On 2015-03-03 03:20, Michael Qiu wrote:=0A= >>>>>> /i686-native-linuxapp-gcc/include/rte_memcpy.h:592:23: error:=0A= >>>>>> cast from pointer to integer of different size=0A= >>>>>> [-Werror=3Dpointer-to-int-cast]=0A= >>>>>>=0A= >>>>>> dstofss =3D 16 - (int)((long long)(void *)dst & 0x0F) + 16;=0A= >>>>>>=0A= >>>>>> Type 'long long' is 64-bit in i686 platform while 'void *'=0A= >>>>>> is 32-bit.=0A= >>>>>>=0A= >>>>>> Signed-off-by: Michael Qiu =0A= >>>>>> ---=0A= >>>>>> v2 --> v1:=0A= >>>>>> Remove unnecessary casting (void *)=0A= >>>>>>=0A= >>>>>> lib/librte_eal/common/include/arch/x86/rte_memcpy.h | 4 ++--=0A= >>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)=0A= >>>>>>=0A= >>>>>> diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h=0A= >>>> b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h=0A= >>>>>> index 7b2d382..85a5f4d 100644=0A= >>>>>> --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h=0A= >>>>>> +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h=0A= >>>>>> @@ -589,12 +589,12 @@ COPY_BLOCK_64_BACK15:=0A= >>>>>> * unaligned copy functions require up to 15 bytes=0A= >>>>>> * backwards access.=0A= >>>>>> */=0A= >>>>>> - dstofss =3D 16 - (int)((long long)(void *)dst & 0x0F) + 16;=0A= >>>>>> + dstofss =3D 16 - (int)((long)dst & 0x0F) + 16;=0A= >>>>>> n -=3D dstofss;=0A= >>>>>> rte_mov32((uint8_t *)dst, (const uint8_t *)src);=0A= >>>>>> src =3D (const uint8_t *)src + dstofss;=0A= >>>>>> dst =3D (uint8_t *)dst + dstofss;=0A= >>>>>> - srcofs =3D (int)((long long)(const void *)src & 0x0F);=0A= >>>>>> + srcofs =3D (int)((long)src & 0x0F);=0A= >>>>>>=0A= >>>>>> /**=0A= >>>>>> * For aligned copy=0A= >>>>>>=0A= >>>>> I think you should use here size_t, (u)ptrdiff_t or (u)intptr_t as th= is=0A= >>>> Yes, but 'long' is enough, does it limit anything, or has any issue wi= th=0A= >>>> multiple platforms?=0A= >>>>=0A= >>> Those types ((u)ptrdiff_t, (u)intptr_t) exists specially for=0A= >>> pointer-to-int and int-to-pointer casts. Using integer primitives might= =0A= >>> produce further warnings/error in the future and need further patches= =0A= >>> fixing the same place.=0A= >> OK, I will send out the v3 patch.=0A= >>=0A= >>> Also why make offset variables signed and different type? This introduc= e=0A= >>> a lot of unnecessary explicit and implicit casts or type promotions.=0A= >> But Is it suitable to make offset (u)ptrdiff_t or (u)intptr_t?=0A= >>=0A= > I think, as final result is offset, its type should be size_t (the same = =0A= > type as type of offsetof() macro). This way you can use =0A= > uptrdiff_t/uintptr_t and does not need of any signed-unsigned casting.=0A= =0A= size_t should be acceptable=0A= =0A= Thanks,=0A= Michael=0A= =0A= >=0A= >> Thanks,=0A= >> Michael=0A= >>=0A= >>>>> will be more portable.=0A= >>>>> Also type of dstofss and srcofs should be changed accordingly.=0A= >>>> No, I think, it should be offset.=0A= >>>>=0A= >>>> Thanks,=0A= >>>> Michael=0A= >>=0A= >=0A= =0A=