Module Name:    src
Committed By:   ozaki-r
Date:           Tue Apr  7 04:36:19 UTC 2015

Modified Files:
        src/sys/net: route.c

Log Message:
Clean up rtcache_setdst

We can assume sockaddr_copy never return NULL when we pass
non-NULL dst (1st argument).


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/net/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/route.c
diff -u src/sys/net/route.c:1.141 src/sys/net/route.c:1.142
--- src/sys/net/route.c:1.141	Mon Apr  6 08:39:06 2015
+++ src/sys/net/route.c	Tue Apr  7 04:36:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.141 2015/04/06 08:39:06 ozaki-r Exp $	*/
+/*	$NetBSD: route.c,v 1.142 2015/04/07 04:36:19 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@
 #include "opt_route.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.141 2015/04/06 08:39:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.142 2015/04/07 04:36:19 ozaki-r Exp $");
 
 #include <sys/param.h>
 #ifdef RTFLUSH_DEBUG
@@ -1468,15 +1468,16 @@ rtcache_setdst(struct route *ro, const s
 	KASSERT(sa != NULL);
 
 	rtcache_invariants(ro);
-	if (ro->ro_sa != NULL && ro->ro_sa->sa_family == sa->sa_family) {
-		rtcache_clear(ro);
-		if (sockaddr_copy(ro->ro_sa, ro->ro_sa->sa_len, sa) != NULL) {
-			rtcache_invariants(ro);
-			return 0;
+	if (ro->ro_sa != NULL) {
+		if (ro->ro_sa->sa_family == sa->sa_family) {
+			rtcache_clear(ro);
+			sockaddr_copy(ro->ro_sa, ro->ro_sa->sa_len, sa);
+			sockaddr_free(ro->ro_sa);
+		} else {
+			/* free ro_sa, wrong family */
+			rtcache_free(ro);
 		}
-		sockaddr_free(ro->ro_sa);
-	} else if (ro->ro_sa != NULL)
-		rtcache_free(ro);	/* free ro_sa, wrong family */
+	}
 
 	KASSERT(ro->_ro_rt == NULL);
 

Reply via email to