From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 776102EDA for ; Sat, 27 Dec 2014 21:49:19 +0100 (CET) Received: from [2001:470:8:a08:215:ff:fecc:4872] (helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1Y4yIL-0002rF-GR; Sat, 27 Dec 2014 15:49:18 -0500 Date: Sat, 27 Dec 2014 15:49:03 -0500 From: Neil Horman To: Ravi Kerur Message-ID: <20141227204903.GB16138@localhost.localdomain> References: <1419694115-1892-1-git-send-email-rkerur@gmail.com> <1419694244-2018-1-git-send-email-rkerur@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1419694244-2018-1-git-send-email-rkerur@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Score: -2.9 (--) X-Spam-Status: No Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] Fix 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: Sat, 27 Dec 2014 20:49:19 -0000 On Sat, Dec 27, 2014 at 10:30:44AM -0500, Ravi Kerur wrote: > rte_is_power_of_2 returns true for 0 and 0 is not power_of_2. Fix > by checking for n. > > Signed-off-by: Ravi Kerur > --- > lib/librte_eal/common/include/rte_common.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h > index 921b91f..8ac940c 100644 > --- a/lib/librte_eal/common/include/rte_common.h > +++ b/lib/librte_eal/common/include/rte_common.h > @@ -203,7 +203,7 @@ extern int RTE_BUILD_BUG_ON_detected_error; > static inline int > rte_is_power_of_2(uint32_t n) > { > - return ((n-1) & n) == 0; > + return n && !(n & (n - 1)); > } > > /** > -- > 1.9.1 > > Acked-by: Neil Horman