From: Ravi Kerur Date: Sat, 27 Dec 2014 15:30:44 +0000 (-0500) Subject: eal: fix check for power of 2 in 0 case X-Git-Tag: spdx-start~9856 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2fc8d6daa4c7a8b247e3bc2b791b1229e8bcd617;p=dpdk.git eal: fix check for power of 2 in 0 case 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 --- diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 921b91f37b..8ac940cbc5 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)); } /**