diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-03-31 16:43:36 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-03-31 16:47:00 -0400 |
| commit | ff3745c26abdfbebeebf14ffe55361666771e1a7 (patch) | |
| tree | ff24d60ebc1aaca943a3110ef9908e4b4c5863ee | |
| parent | 8cb129e9868eb5edb7bfe98917fad9931de6144b (diff) | |
pimd: Remove impossible conditions from test
It is impossible for the list->cmp function to
ever be handed NULL values as the arguments.
Clean up this in the code.
Additionally consolidate the exact same two functions
into 1 function.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
| -rw-r--r-- | pimd/pim_nht.c | 36 | ||||
| -rw-r--r-- | pimd/pim_rp.c | 16 | ||||
| -rw-r--r-- | pimd/pim_rp.h | 2 |
3 files changed, 4 insertions, 50 deletions
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 5395c08392..fe96d01a06 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -111,42 +111,6 @@ pim_nexthop_cache_find (struct pim_rpf *rpf) } -static int -pim_rp_list_cmp (void *v1, void *v2) -{ - struct rp_info *rp1 = (struct rp_info *) v1; - struct rp_info *rp2 = (struct rp_info *) v2; - - if (rp1 == rp2) - return 0; - - if (!rp1 && rp2) - return -1; - - if (rp1 && !rp2) - return 1; - - /* - * Sort by RP IP address - */ - if (rp1->rp.rpf_addr.u.prefix4.s_addr < rp2->rp.rpf_addr.u.prefix4.s_addr) - return -1; - - if (rp1->rp.rpf_addr.u.prefix4.s_addr > rp2->rp.rpf_addr.u.prefix4.s_addr) - return 1; - - /* - * Sort by group IP address - */ - if (rp1->group.u.prefix4.s_addr < rp2->group.u.prefix4.s_addr) - return -1; - - if (rp1->group.u.prefix4.s_addr > rp2->group.u.prefix4.s_addr) - return 1; - - return -1; -} - struct pim_nexthop_cache * pim_nexthop_cache_add (struct pim_rpf *rpf_addr) { diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 6c83811d9a..78bbd14405 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -54,21 +54,12 @@ pim_rp_info_free (struct rp_info *rp_info) XFREE (MTYPE_PIM_RP, rp_info); } -static int +int pim_rp_list_cmp (void *v1, void *v2) { struct rp_info *rp1 = (struct rp_info *)v1; struct rp_info *rp2 = (struct rp_info *)v2; - if (rp1 == rp2) - return 0; - - if (!rp1 && rp2) - return -1; - - if (rp1 && !rp2) - return 1; - /* * Sort by RP IP address */ @@ -87,10 +78,7 @@ pim_rp_list_cmp (void *v1, void *v2) if (rp1->group.u.prefix4.s_addr > rp2->group.u.prefix4.s_addr) return 1; - if (rp1 == tail) - return 1; - - return -1; + return 0; } void diff --git a/pimd/pim_rp.h b/pimd/pim_rp.h index e5580cfa63..84ab9be482 100644 --- a/pimd/pim_rp.h +++ b/pimd/pim_rp.h @@ -61,4 +61,6 @@ struct pim_rpf *pim_rp_g (struct in_addr group); #define RP(G) pim_rp_g ((G)) void pim_rp_show_information (struct vty *vty, u_char uj); + +int pim_rp_list_cmp (void *v1, void *v2); #endif |
