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 <rkerur@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
This commit is contained in:
Ravi Kerur 2014-12-27 10:30:44 -05:00 committed by Thomas Monjalon
parent 9b0895e864
commit 2fc8d6daa4

View File

@ -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));
}
/**