The flag parameter in rte_rib_get_nxt() and rte_rib6_get_nxt() is a plain int used as a typed enumeration. Give the anonymous enums proper names (rte_rib_nxt_mode, rte_rib6_nxt_mode) and rename the parameter from "flag" to "mode" to reflect its purpose.
Signed-off-by: Robin Jarry <[email protected]> --- lib/rib/rte_rib.c | 4 ++-- lib/rib/rte_rib.h | 12 ++++++------ lib/rib/rte_rib6.c | 4 ++-- lib/rib/rte_rib6.h | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/rib/rte_rib.c b/lib/rib/rte_rib.c index 046db131ca00..89061829a23c 100644 --- a/lib/rib/rte_rib.c +++ b/lib/rib/rte_rib.c @@ -175,7 +175,7 @@ rte_rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth) RTE_EXPORT_SYMBOL(rte_rib_get_nxt) struct rte_rib_node * rte_rib_get_nxt(struct rte_rib *rib, uint32_t ip, - uint8_t depth, struct rte_rib_node *last, int flag) + uint8_t depth, struct rte_rib_node *last, enum rte_rib_nxt_mode mode) { struct rte_rib_node *tmp, *prev = NULL; @@ -205,7 +205,7 @@ rte_rib_get_nxt(struct rte_rib *rib, uint32_t ip, (is_covered(tmp->ip, ip, depth) && (tmp->depth > depth))) { prev = tmp; - if (flag == RTE_RIB_GET_NXT_COVER) + if (mode == RTE_RIB_GET_NXT_COVER) return prev; } tmp = (tmp->left) ? tmp->left : tmp->right; diff --git a/lib/rib/rte_rib.h b/lib/rib/rte_rib.h index c325b3e3618c..0fabfb2a41a6 100644 --- a/lib/rib/rte_rib.h +++ b/lib/rib/rte_rib.h @@ -26,11 +26,11 @@ extern "C" { /** * rte_rib_get_nxt() flags */ -enum { - /** flag to get all subroutes in a RIB tree */ +enum rte_rib_nxt_mode { + /** get all subroutes in a RIB tree, excluding any exact match top-level route */ RTE_RIB_GET_NXT_ALL, - /** flag to get first matched subroutes in a RIB tree */ - RTE_RIB_GET_NXT_COVER + /** get first matched subroutes in a RIB tree, excluding any exact match top-level route */ + RTE_RIB_GET_NXT_COVER, }; struct rte_rib; @@ -120,7 +120,7 @@ rte_rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth); * pointer to the last returned prefix to get next prefix * or * NULL to get first more specific prefix - * @param flag + * @param mode * -RTE_RIB_GET_NXT_ALL * get all prefixes from subtrie * -RTE_RIB_GET_NXT_COVER @@ -131,7 +131,7 @@ rte_rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth); */ struct rte_rib_node * rte_rib_get_nxt(struct rte_rib *rib, uint32_t ip, uint8_t depth, - struct rte_rib_node *last, int flag); + struct rte_rib_node *last, enum rte_rib_nxt_mode mode); /** * Remove prefix from the RIB diff --git a/lib/rib/rte_rib6.c b/lib/rib/rte_rib6.c index ec8ff68e8700..c23881f6247e 100644 --- a/lib/rib/rte_rib6.c +++ b/lib/rib/rte_rib6.c @@ -195,7 +195,7 @@ RTE_EXPORT_SYMBOL(rte_rib6_get_nxt) struct rte_rib6_node * rte_rib6_get_nxt(struct rte_rib6 *rib, const struct rte_ipv6_addr *ip, - uint8_t depth, struct rte_rib6_node *last, int flag) + uint8_t depth, struct rte_rib6_node *last, enum rte_rib6_nxt_mode mode) { struct rte_rib6_node *tmp, *prev = NULL; struct rte_ipv6_addr tmp_ip; @@ -229,7 +229,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib, (rte_ipv6_addr_eq_prefix(&tmp->ip, &tmp_ip, depth) && (tmp->depth > depth))) { prev = tmp; - if (flag == RTE_RIB6_GET_NXT_COVER) + if (mode == RTE_RIB6_GET_NXT_COVER) return prev; } tmp = (tmp->left != NULL) ? tmp->left : tmp->right; diff --git a/lib/rib/rte_rib6.h b/lib/rib/rte_rib6.h index d66d9e7c07c6..ed2761492bc8 100644 --- a/lib/rib/rte_rib6.h +++ b/lib/rib/rte_rib6.h @@ -25,13 +25,13 @@ extern "C" { #define RTE_RIB6_IPV6_ADDR_SIZE (RTE_DEPRECATED(RTE_RIB6_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE) /** - * rte_rib6_get_nxt() flags + * rte_rib6_get_nxt() mode */ -enum { - /** flag to get all subroutes in a RIB tree */ +enum rte_rib6_nxt_mode { + /** get all subroutes in a RIB tree, excluding any exact match top-level route */ RTE_RIB6_GET_NXT_ALL, - /** flag to get first matched subroutes in a RIB tree */ - RTE_RIB6_GET_NXT_COVER + /** get first matched subroutes in a RIB tree, excluding any exact match top-level route */ + RTE_RIB6_GET_NXT_COVER, }; struct rte_rib6; @@ -179,7 +179,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib, * pointer to the last returned prefix to get next prefix * or * NULL to get first more specific prefix - * @param flag + * @param mode * -RTE_RIB6_GET_NXT_ALL * get all prefixes from subtrie * -RTE_RIB6_GET_NXT_COVER @@ -191,7 +191,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib, struct rte_rib6_node * rte_rib6_get_nxt(struct rte_rib6 *rib, const struct rte_ipv6_addr *ip, - uint8_t depth, struct rte_rib6_node *last, int flag); + uint8_t depth, struct rte_rib6_node *last, enum rte_rib6_nxt_mode mode); /** * Remove prefix from the RIB -- 2.54.0

