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 47AF1CF9 for ; Sun, 18 Jan 2015 20:26:29 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 18 Jan 2015 11:26:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,422,1418112000"; d="scan'208";a="663752170" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by fmsmga002.fm.intel.com with ESMTP; 18 Jan 2015 11:26:27 -0800 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.245]) by IRSMSX103.ger.corp.intel.com ([169.254.3.242]) with mapi id 14.03.0195.001; Sun, 18 Jan 2015 19:26:26 +0000 From: "Doherty, Declan" To: Thomas Monjalon Thread-Topic: [dpdk-dev] [PATCH] eal / malloc : alignment parameter check failing due to changes in rte_is_power_of_2 Thread-Index: AQHQMZ6bHNSK3VPXfky0IgCFitALEZzC+OoAgANM2nA= Date: Sun, 18 Jan 2015 19:26:26 +0000 Message-ID: <345C63BAECC1AD42A2EC8C63AFFC3ADC2747EE3D@IRSMSX101.ger.corp.intel.com> References: <1421421030-22261-1-git-send-email-declan.doherty@intel.com> <1555477.4KJeR5JQaW@xps13> In-Reply-To: <1555477.4KJeR5JQaW@xps13> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] eal / malloc : alignment parameter check failing due to changes in rte_is_power_of_2 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: Sun, 18 Jan 2015 19:26:29 -0000 > -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > Sent: Friday, January 16, 2015 5:02 PM > To: Doherty, Declan > Cc: dev@dpdk.org; De Lara Guarch, Pablo > Subject: Re: [dpdk-dev] [PATCH] eal / malloc : alignment parameter check = failing > due to changes in rte_is_power_of_2 >=20 > 2015-01-16 15:10, Declan Doherty: > > In commit 2fc8d6d the behaviour of function rte_is_power_of_2 was > > changed to not return true for 0. memzone_reserve_aligned_thread_unsafe > > and rte_malloc_socket both make the assumption that for align =3D 0 > > !rte_is_power_of_2(align) will return false. This patch adds a check > > that align parameter is non-zero before doing the power of 2 check > > > > Signed-off-by: Declan Doherty > [...] > > - if (!rte_is_power_of_2(align)) { > > + if (align ? !rte_is_power_of_2(align) : 0) { > [...] > > - if (size =3D=3D 0 || !rte_is_power_of_2(align)) > > + if (size =3D=3D 0 || align ? !rte_is_power_of_2(align) : 0) >=20 > I don't understand why you write "align ? !rte_is_power_of_2(align) : 0" > instead of the more readable "align && !rte_is_power_of_2(align)" ? >=20 > Pablo acked it so I guess there is something obvious I'm missing. >=20 > -- > Thomas No there's nothing you're missing, this is just the way I saw the logic, if= align is none zero, then test the power of 2 condition otherwise return 0. I have no prob= lem with your suggestion in you prefer that, at the end of the day the logic test wo= rks out equivalent.