From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 420705A83 for ; Tue, 3 Mar 2015 14:37:54 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 03 Mar 2015 05:37:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,681,1418112000"; d="scan'208";a="659741611" Received: from unknown (HELO [10.217.248.207]) ([10.217.248.207]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2015 05:37:52 -0800 Message-ID: <54F5B92E.5090202@intel.com> Date: Tue, 03 Mar 2015 14:37:50 +0100 From: Pawel Wodkowski User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "Qiu, Michael" , "dev@dpdk.org" 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> In-Reply-To: <533710CFB86FA344BFBF2D6802E60286CED932@SHSMSX101.ccr.corp.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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: Tue, 03 Mar 2015 13:37:54 -0000 > -----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 > >> --- > >> 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