From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 3E0575683 for ; Wed, 4 Mar 2015 02:58:27 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 03 Mar 2015 17:58:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,685,1418112000"; d="scan'208";a="660078538" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2015 17:58:25 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 4 Mar 2015 09:58:23 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.197]) with mapi id 14.03.0195.001; Wed, 4 Mar 2015 09:58:21 +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 01:58:21 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CEDC0D@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> 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 01:58:30 -0000 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 poin= ter 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 this= =0A= >> Yes, but 'long' is enough, does it limit anything, or has any issue with= =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= =0A= OK, I will send out the v3 patch.=0A= =0A= > Also why make offset variables signed and different type? This introduce = =0A= > a lot of unnecessary explicit and implicit casts or type promotions.=0A= =0A= But Is it suitable to make offset (u)ptrdiff_t or (u)intptr_t?=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=