Module Name:    src
Committed By:   christos
Date:           Wed Nov 13 21:41:23 UTC 2013

Modified Files:
        src/tests/net/net: t_unix.c

Log Message:
CID 1107543, 230676, 1107543, 976795, 230676, 976795, 1125885, etc.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/net/net/t_unix.c

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

Modified files:

Index: src/tests/net/net/t_unix.c
diff -u src/tests/net/net/t_unix.c:1.10 src/tests/net/net/t_unix.c:1.11
--- src/tests/net/net/t_unix.c:1.10	Sun Oct 20 13:36:36 2013
+++ src/tests/net/net/t_unix.c	Wed Nov 13 16:41:23 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_unix.c,v 1.10 2013/10/20 17:36:36 christos Exp $	*/
+/*	$NetBSD: t_unix.c,v 1.11 2013/11/13 21:41:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$Id: t_unix.c,v 1.10 2013/10/20 17:36:36 christos Exp $");
+__RCSID("$Id: t_unix.c,v 1.11 2013/11/13 21:41:23 christos Exp $");
 #else
 #define getprogname() argv[0]
 #endif
@@ -169,8 +169,10 @@ test(bool closeit, size_t len)
 	sun->sun_family = AF_UNIX;
 
 	if (bind(srvr, (struct sockaddr *)sun, sl) == -1) {
-		if (errno == EINVAL && sl >= 256)
+		if (errno == EINVAL && sl >= 256) {
+			close(srvr);
 			return -1;
+		}
 		FAIL("bind");
 	}
 
@@ -187,6 +189,7 @@ test(bool closeit, size_t len)
 	if (closeit) {
 		if (close(clnt) == -1)
 			FAIL("close");
+		clnt = -1;
 	}
 
 	acpt = acc(srvr);
@@ -233,18 +236,23 @@ test(bool closeit, size_t len)
 			    "sun->sun_path[%zu] %d\n", i, 
 			    sock_addr->sun_path[i], i, sun->sun_path[i]);
 
-	(void)close(acpt);
-	(void)close(srvr);
-	if (!closeit)
+	if (acpt != -1)
+		(void)close(acpt);
+	if (srvr != -1)
+		(void)close(srvr);
+	if (clnt != -1 && !closeit)
 		(void)close(clnt);
 
 	free(sock_addr);
 	free(sun);
 	return 0;
 fail:
-	(void)close(acpt);
-	(void)close(srvr);
-	(void)close(clnt);
+	if (acpt != -1)
+		(void)close(acpt);
+	if (srvr != -1)
+		(void)close(srvr);
+	if (clnt != -1 && !closeit)
+		(void)close(clnt);
 	free(sock_addr);
 	free(sun);
 	return -1;

Reply via email to