git.droids-corp.org
/
dpdk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9b0895e
)
eal: fix check for power of 2 in 0 case
author
Ravi Kerur
<rkerur@gmail.com>
Sat, 27 Dec 2014 15:30:44 +0000
(10:30 -0500)
committer
Thomas Monjalon
<thomas.monjalon@6wind.com>
Thu, 15 Jan 2015 12:41:39 +0000
(13:41 +0100)
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>
lib/librte_eal/common/include/rte_common.h
patch
|
blob
|
history
diff --git
a/lib/librte_eal/common/include/rte_common.h
b/lib/librte_eal/common/include/rte_common.h
index
921b91f
..
8ac940c
100644
(file)
--- 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))
;
}
/**