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 419F158C6 for ; Thu, 17 May 2018 13:03:17 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 May 2018 04:03:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,410,1520924400"; d="scan'208";a="55178421" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by fmsmga004.fm.intel.com with ESMTP; 17 May 2018 04:03:15 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.214]) by irsmsx110.ger.corp.intel.com ([169.254.15.125]) with mapi id 14.03.0319.002; Thu, 17 May 2018 12:03:14 +0100 From: "Ananyev, Konstantin" To: "Richardson, Bruce" , Andy Green CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4 11/23] rte_mbuf.h: explicit cast restricting ptrdiff to uint16 Thread-Index: AQHT60IKVTOrtSOZMEqKTFiW2tkRYqQzsoUAgAAShrA= Date: Thu, 17 May 2018 11:03:14 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258AEDC8830@irsmsx105.ger.corp.intel.com> References: <152627436523.53156.4398253089110011263.stgit@localhost.localdomain> <152627462287.53156.1972221889368883834.stgit@localhost.localdomain> <20180517105042.GC22048@bricha3-MOBL.ger.corp.intel.com> In-Reply-To: <20180517105042.GC22048@bricha3-MOBL.ger.corp.intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzA3MDE1NTgtM2Y1MC00ZDczLWFiZTctOTU4NWU4ODZmZmEyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Im1cL2J1blRUXC9vTm1YRGJ5ZWdyZnhDVXZJYjZ6dmVMZjJucG5VNWpTK3gybz0ifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4 11/23] rte_mbuf.h: explicit cast restricting ptrdiff to uint16 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 May 2018 11:03:17 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson > Sent: Thursday, May 17, 2018 11:51 AM > To: Andy Green > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v4 11/23] rte_mbuf.h: explicit cast restri= cting ptrdiff to uint16 >=20 > On Mon, May 14, 2018 at 01:10:22PM +0800, Andy Green wrote: > > /projects/lagopus/src/dpdk/build/include/rte_common.h:141:34: > > warning: conversion from 'long unsigned int' to 'uint16_t' > > {aka 'short unsigned int'} may change value [-Wconversion] > > #define RTE_PTR_DIFF(ptr1, ptr2) ((uintptr_t)(ptr1) - > > (uintptr_t)(ptr2)) > > ^ > > /projects/lagopus/src/dpdk/build/include/rte_mbuf.h:1360:13: > > note: in expansion of macro 'RTE_PTR_DIFF' > > *buf_len =3D RTE_PTR_DIFF(shinfo, buf_addr); > > > > Signed-off-by: Andy Green > > --- > > lib/librte_mbuf/rte_mbuf.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > index a27dbb878..0580ec8a0 100644 > > --- a/lib/librte_mbuf/rte_mbuf.h > > +++ b/lib/librte_mbuf/rte_mbuf.h > > @@ -1358,7 +1358,7 @@ rte_pktmbuf_ext_shinfo_init_helper(void *buf_addr= , uint16_t *buf_len, > > shinfo->fcb_opaque =3D fcb_opaque; > > rte_mbuf_ext_refcnt_set(shinfo, 1); > > > > - *buf_len =3D RTE_PTR_DIFF(shinfo, buf_addr); > > + *buf_len =3D (uint16_t)RTE_PTR_DIFF(shinfo, buf_addr); > > return shinfo; > > } > Acked-by: Bruce Richardson Just as a nit: if all such conversions are unavoidable - might be introduce= : RTE_PTR_DIFF_TYPE(.., type) ((type)(RTE_PTR_DIFF(...)) Might look a bit nicer. Konstantin