According to GCC documentation for __builtin_clz:
Returns the number of leading 0-bits in x,
starting at the most significant bit position.
If x is 0, the result is undefined.
__builtin_clz will be called with 0 if the existing
prefix address matches the one we want to insert.
Fixes:
5a5793a5ffa2 ("rib: add RIB library")
Cc: stable@dpdk.org
Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
/* closest node found, new_node should be inserted in the middle */
common_depth = RTE_MIN(depth, (*tmp)->depth);
common_prefix = ip ^ (*tmp)->ip;
- d = __builtin_clz(common_prefix);
+ d = (common_prefix == 0) ? 32 : __builtin_clz(common_prefix);
common_depth = RTE_MIN(d, common_depth);
common_prefix = ip & rte_rib_depth_to_mask(common_depth);