Clean up callers of nd6_prelist_add().

nd6_prelist_add() sets *newp if and only if it is successful, so there's no
need for code that handles the case where the return value is 0 and
*newp == NULL. Fix some style bugs in nd6_prelist_add() while here.

MFC after:	1 week
This commit is contained in:
Mark Johnston 2016-05-07 03:41:29 +00:00
parent 83631b16a7
commit 20b5f02214
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299213
2 changed files with 8 additions and 19 deletions

View File

@ -669,14 +669,6 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
(*carp_detach_p)(&ia->ia_ifa);
goto out;
}
if (pr == NULL) {
if (carp_attached)
(*carp_detach_p)(&ia->ia_ifa);
log(LOG_ERR, "nd6_prelist_add succeeded but "
"no prefix\n");
error = EINVAL;
goto out;
}
}
/* relate the address to the prefix */

View File

@ -993,11 +993,9 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr,
new->ndpr_flags = pr->ndpr_flags;
if ((error = in6_init_prefix_ltimes(new)) != 0) {
free(new, M_IP6NDP);
return(error);
return (error);
}
new->ndpr_lastupdate = time_uptime;
if (newp != NULL)
*newp = new;
/* initialization */
LIST_INIT(&new->ndpr_advrtrs);
@ -1021,10 +1019,11 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr,
}
}
if (dr)
if (dr != NULL)
pfxrtr_add(new, dr);
return 0;
if (newp != NULL)
*newp = new;
return (0);
}
void
@ -1144,13 +1143,11 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
goto end;
error = nd6_prelist_add(new, dr, &pr);
if (error != 0 || pr == NULL) {
if (error != 0) {
nd6log((LOG_NOTICE, "prelist_update: "
"nd6_prelist_add failed for %s/%d on %s "
"errno=%d, returnpr=%p\n",
"nd6_prelist_add failed for %s/%d on %s errno=%d\n",
ip6_sprintf(ip6buf, &new->ndpr_prefix.sin6_addr),
new->ndpr_plen, if_name(new->ndpr_ifp),
error, pr));
new->ndpr_plen, if_name(new->ndpr_ifp), error));
goto end; /* we should just give up in this case. */
}