From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 06FA55A81 for ; Mon, 19 Jan 2015 10:01:10 +0100 (CET) Received: by mail-wg0-f41.google.com with SMTP id a1so8449610wgh.0 for ; Mon, 19 Jan 2015 01:01:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=G/etu12DQ8SdWxpiq+qwFNWSVfn0m/z/mDYdQsWUJl4=; b=Zn8v1JkGqkLg5yxlFn4cMpC3YTO1WhHCdVU0FcSINrsV9fiyWo7BBeUl1VbRHSjn0k +Iy1w2wWyd0Y8ys7lCPKJTh1tTvQbAEmhee2QDco+kl7Gf/O8Ufl963nQR6VAIbVRvtn efZJQbmVklSmJY2ZaptCqlvKY0CH9brU6C7iuIK/qt6urhtOJxnqWxUKl5fIRQlP3+Zg mgTz15SFy4oyhRpzRl+IT1BsxEQndZNcWzV12cADh78/bycfT32fdtUXqIPItJHA8VJV YbcsR74wweg1TSA31IuDuDkD0tDbEdMVL2CHtrTpKYJyDcv4HYAFnyWEegJQIAUXPYvJ bWWQ== X-Gm-Message-State: ALoCoQkZ8wnLmnHviUyXACtUfXxulUdR4UWs7qn5KXTtCHkaSz5NZxUiUKDnppjPUHWmwoWMMVeN X-Received: by 10.180.20.177 with SMTP id o17mr33301388wie.64.1421658069654; Mon, 19 Jan 2015 01:01:09 -0800 (PST) Received: from xps13.localnet ([109.190.92.136]) by mx.google.com with ESMTPSA id o16sm16452583wjw.7.2015.01.19.01.01.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jan 2015 01:01:08 -0800 (PST) From: Thomas Monjalon To: "Doherty, Declan" Date: Mon, 19 Jan 2015 10:00:43 +0100 Message-ID: <3882238.XjXCyuyOGj@xps13> Organization: 6WIND User-Agent: KMail/4.14.3 (Linux/3.17.6-1-ARCH; KDE/4.14.3; x86_64; ; ) In-Reply-To: <345C63BAECC1AD42A2EC8C63AFFC3ADC2747EE3D@IRSMSX101.ger.corp.intel.com> References: <1421421030-22261-1-git-send-email-declan.doherty@intel.com> <1555477.4KJeR5JQaW@xps13> <345C63BAECC1AD42A2EC8C63AFFC3ADC2747EE3D@IRSMSX101.ger.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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: Mon, 19 Jan 2015 09:01:10 -0000 2015-01-18 19:26, Doherty, Declan: > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > > 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 = 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 == 0 || !rte_is_power_of_2(align)) > > > + if (size == 0 || align ? !rte_is_power_of_2(align) : 0) There is an operator precedence bug here. Parens are needed after ||. > > 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)" ? > > > > Pablo acked it so I guess there is something obvious I'm missing. > > 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 problem with > your suggestion in you prefer that, at the end of the day the logic test works out equivalent. So I change to the simpler && form and I add parentheses after || to correctly check size==0. Applied with above changes. Thanks -- Thomas