]> git.droids-corp.org - dpdk.git/blobdiff - lib/librte_eal/common/include/rte_common.h
eal: fix check for power of 2 in 0 case
[dpdk.git] / lib / librte_eal / common / include / rte_common.h
index 921b91f37bac55b22259c9eb9350ae999b41fe15..8ac940cbc5f2823d09f98c6a273601f1eb2afc56 100644 (file)
@@ -203,7 +203,7 @@ extern int RTE_BUILD_BUG_ON_detected_error;
 static inline int
 rte_is_power_of_2(uint32_t n)
 {
 static inline int
 rte_is_power_of_2(uint32_t n)
 {
-       return ((n-1) & n) == 0;
+       return n && !(n & (n - 1));
 }
 
 /**
 }
 
 /**