svn commit: r319059 - head/tests/sys/file

Ngie Cooper ngie at FreeBSD.org
Sun May 28 08:55:33 UTC 2017


Author: ngie
Date: Sun May 28 08:55:32 2017
New Revision: 319059
URL: https://svnweb.freebsd.org/changeset/base/319059

Log:
  Use an exit code of 1 instead of -1 for reasons noted in r319056
  
  MFC after:	3 days
  Sponsored by:	Dell EMC Isilon

Modified:
  head/tests/sys/file/newfileops_on_fork_test.c

Modified: head/tests/sys/file/newfileops_on_fork_test.c
==============================================================================
--- head/tests/sys/file/newfileops_on_fork_test.c	Sun May 28 08:52:12 2017	(r319058)
+++ head/tests/sys/file/newfileops_on_fork_test.c	Sun May 28 08:55:32 2017	(r319059)
@@ -61,7 +61,7 @@ do_accept(__unused void *arg)
 
 	accept_fd = accept(listen_fd, NULL, NULL);
 	if (accept_fd < 0)
-		err(-1, "accept");
+		err(1, "accept");
 
 	return (NULL);
 }
@@ -73,7 +73,7 @@ do_fork(void)
 
 	pid = fork();
 	if (pid < 0)
-		err(-1, "fork");
+		err(1, "fork");
 	if (pid > 0) {
 		waitpid(pid, NULL, 0);
 		exit(0);
@@ -84,15 +84,15 @@ do_fork(void)
 	 * listen_fd+1, and get back EBADF if it's not a valid descriptor,
 	 * and EINVAL if it is.  This (currently) works fine in practice.
 	 */
-	if (ftruncate(listen_fd + 1, 0 < 0)) {
+	if (ftruncate(listen_fd + 1, 0) < 0) {
 		if (errno == EBADF)
 			exit(0);
 		else if (errno == EINVAL)
-			errx(-1, "file descriptor still open in child");
+			errx(1, "file descriptor still open in child");
 		else
-			err(-1, "unexpected error");
+			err(1, "unexpected error");
 	} else
-		errx(-1, "ftruncate succeeded");
+		errx(1, "ftruncate succeeded");
 }
 
 int
@@ -103,18 +103,18 @@ main(__unused int argc, __unused char *a
 
 	listen_fd = socket(PF_INET, SOCK_STREAM, 0);
 	if (listen_fd < 0)
-		err(-1, "socket");
+		err(1, "socket");
 	bzero(&sin, sizeof(sin));
 	sin.sin_family = AF_INET;
 	sin.sin_len = sizeof(sin);
 	sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 	sin.sin_port = htons(PORT);
 	if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0)
-		err(-1, "bind");
+		err(1, "bind");
 	if (listen(listen_fd, -1) <0)
-		err(-1, "listen");
+		err(1, "listen");
 	if (pthread_create(&accept_thread, NULL, do_accept, NULL) != 0)
-		err(-1, "pthread_create");
+		err(1, "pthread_create");
 	sleep(1);	/* Easier than using a CV. */
 	do_fork();
 	exit(0);


More information about the svn-src-head mailing list