From ead8f16d7f9c050a5bff8d2edc980b290f54e7f9 Mon Sep 17 00:00:00 2001 From: Jeremie Courreges-Anglas Date: Fri, 18 Apr 2014 10:48:31 +0000 Subject: Invert the signature logic of in{,6}_selectsrc, make them return the error code and pass the resulting source address back to the caller through a pointer, as suggested by chrisz. This gives us more readable code, and eases the deletion of useless checks in the callers' error path. Add a bunch of "0 -> NULL" conversions, while here. ok chrisz@ mpi@ --- sys/netinet6/nd6_nbr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sys/netinet6/nd6_nbr.c') diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 52da768dcf2..729c959ea27 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_nbr.c,v 1.77 2014/04/14 09:06:42 mpi Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.78 2014/04/18 10:48:30 jca Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -456,9 +456,9 @@ nd6_ns_output(struct ifnet *ifp, struct in6_addr *daddr6, int error; bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa)); - src0 = in6_selectsrc(&dst_sa, NULL, NULL, &ro, NULL, - &error, m->m_pkthdr.ph_rtableid); - if (src0 == NULL) { + error = in6_selectsrc(&src0, &dst_sa, NULL, NULL, &ro, + NULL, m->m_pkthdr.ph_rtableid); + if (error) { char addr[INET6_ADDRSTRLEN]; nd6log((LOG_DEBUG, @@ -968,9 +968,9 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6, * Select a source whose scope is the same as that of the dest. */ bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa)); - src0 = in6_selectsrc(&dst_sa, NULL, NULL, &ro, NULL, &error, + error = in6_selectsrc(&src0, &dst_sa, NULL, NULL, &ro, NULL, m->m_pkthdr.ph_rtableid); - if (src0 == NULL) { + if (error) { char addr[INET6_ADDRSTRLEN]; nd6log((LOG_DEBUG, "nd6_na_output: source can't be " -- cgit v1.2.3