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 223B95A99 for ; Wed, 21 Jan 2015 21:58:03 +0100 (CET) Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1YE2Le-00078w-Nb; Wed, 21 Jan 2015 15:58:00 -0500 From: Neil Horman To: dev@dpdk.org Date: Wed, 21 Jan 2015 15:57:27 -0500 Message-Id: <1421873870-21754-3-git-send-email-nhorman@tuxdriver.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1421873870-21754-1-git-send-email-nhorman@tuxdriver.com> References: <1419109299-9603-1-git-send-email-nhorman@tuxdriver.com> <1421873870-21754-1-git-send-email-nhorman@tuxdriver.com> X-Spam-Score: -2.9 (--) X-Spam-Status: No Subject: [dpdk-dev] [PATCH v7 03/26] eal: fix check for power of 2 in 0 case 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: Wed, 21 Jan 2015 20:58:04 -0000 From: Ravi Kerur 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 Acked-by: Neil Horman --- 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)); } /** -- 2.1.0