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>
This commit is contained in:
Donald Sharp 2017-03-31 16:43:36 -04:00
parent 8cb129e986
commit ff3745c26a
3 changed files with 4 additions and 50 deletions

View file

@ -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)
{

View file

@ -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

View file

@ -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