From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ravi Kerur Subject: [PATCH 1/7] Fix rte_is_power_of_2 Date: Thu, 25 Dec 2014 10:33:11 -0500 Message-ID: <1419521597-31978-2-git-send-email-rkerur@gmail.com> References: <1419521597-31978-1-git-send-email-rkerur@gmail.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <1419521597-31978-1-git-send-email-rkerur-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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