Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jan 2016 05:57:32 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r294485 - stable/10/tools/regression/sockets/zerosend
Message-ID:  <201601210557.u0L5vWEL088865@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Thu Jan 21 05:57:32 2016
New Revision: 294485
URL: https://svnweb.freebsd.org/changeset/base/294485

Log:
  MFC r294127:
  
  Fix warnings with clang/gcc
  
  - Get rid of unused argc/argv variables in main
  - Exit on failure with a return code of 1 instead of -1 with err/errx as a
    return code of -1 is implementation dependent
  - Bump WARNS to 6

Modified:
  stable/10/tools/regression/sockets/zerosend/Makefile
  stable/10/tools/regression/sockets/zerosend/zerosend.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tools/regression/sockets/zerosend/Makefile
==============================================================================
--- stable/10/tools/regression/sockets/zerosend/Makefile	Thu Jan 21 04:37:16 2016	(r294484)
+++ stable/10/tools/regression/sockets/zerosend/Makefile	Thu Jan 21 05:57:32 2016	(r294485)
@@ -2,6 +2,6 @@
 
 PROG=	zerosend
 MAN=
-WARNS?=	2
+WARNS?=	6
 
 .include <bsd.prog.mk>

Modified: stable/10/tools/regression/sockets/zerosend/zerosend.c
==============================================================================
--- stable/10/tools/regression/sockets/zerosend/zerosend.c	Thu Jan 21 04:37:16 2016	(r294484)
+++ stable/10/tools/regression/sockets/zerosend/zerosend.c	Thu Jan 21 05:57:32 2016	(r294485)
@@ -54,9 +54,9 @@ try_0send(const char *test, int fd)
 	ch = 0;
 	len = send(fd, &ch, 0, 0);
 	if (len < 0)
-		err(-1, "%s: try_0send", test);
+		err(1, "%s: try_0send", test);
 	if (len != 0)
-		errx(-1, "%s: try_0send: returned %zd", test, len);
+		errx(1, "%s: try_0send: returned %zd", test, len);
 }
 
 static void
@@ -68,9 +68,9 @@ try_0write(const char *test, int fd)
 	ch = 0;
 	len = write(fd, &ch, 0);
 	if (len < 0)
-		err(-1, "%s: try_0write", test);
+		err(1, "%s: try_0write", test);
 	if (len != 0)
-		errx(-1, "%s: try_0write: returned %zd", test, len);
+		errx(1, "%s: try_0write: returned %zd", test, len);
 }
 
 static void
@@ -87,24 +87,24 @@ setup_udp(const char *test, int *fdp)
 	sin.sin_port = htons(PORT1);
 	sock1 = socket(PF_INET, SOCK_DGRAM, 0);
 	if (sock1 < 0)
-		err(-1, "%s: setup_udp: socket", test);
+		err(1, "%s: setup_udp: socket", test);
 	if (bind(sock1, (struct sockaddr *)&sin, sizeof(sin)) < 0)
-		err(-1, "%s: setup_udp: bind(%s, %d)", test,
+		err(1, "%s: setup_udp: bind(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT1);
 	sin.sin_port = htons(PORT2);
 	if (connect(sock1, (struct sockaddr *)&sin, sizeof(sin)) < 0)
-		err(-1, "%s: setup_udp: connect(%s, %d)", test,
+		err(1, "%s: setup_udp: connect(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT2);
 
 	sock2 = socket(PF_INET, SOCK_DGRAM, 0);
 	if (sock2 < 0)
-		err(-1, "%s: setup_udp: socket", test);
+		err(1, "%s: setup_udp: socket", test);
 	if (bind(sock2, (struct sockaddr *)&sin, sizeof(sin)) < 0)
-		err(-1, "%s: setup_udp: bind(%s, %d)", test,
+		err(1, "%s: setup_udp: bind(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT2);
 	sin.sin_port = htons(PORT1);
 	if (connect(sock2, (struct sockaddr *)&sin, sizeof(sin)) < 0)
-		err(-1, "%s: setup_udp: connect(%s, %d)", test,
+		err(1, "%s: setup_udp: connect(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT1);
 
 	fdp[0] = sock1;
@@ -130,12 +130,12 @@ setup_tcp(const char *test, int *fdp)
 	sin.sin_port = htons(PORT1);
 	sock1 = socket(PF_INET, SOCK_STREAM, 0);
 	if (sock1 < 0)
-		err(-1, "%s: setup_tcp: socket", test);
+		err(1, "%s: setup_tcp: socket", test);
 	if (bind(sock1, (struct sockaddr *)&sin, sizeof(sin)) < 0)
-		err(-1, "%s: bind(%s, %d)", test, inet_ntoa(sin.sin_addr),
+		err(1, "%s: bind(%s, %d)", test, inet_ntoa(sin.sin_addr),
 		    PORT1);
 	if (listen(sock1, -1) < 0)
-		err(-1, "%s: listen", test);
+		err(1, "%s: listen", test);
 
 	/*
 	 * Now connect to it, non-blocking so that we don't deadlock against
@@ -143,25 +143,25 @@ setup_tcp(const char *test, int *fdp)
 	 */
 	sock2 = socket(PF_INET, SOCK_STREAM, 0);
 	if (sock2 < 0)
-		err(-1, "%s: setup_tcp: socket", test);
+		err(1, "%s: setup_tcp: socket", test);
 	if (fcntl(sock2, F_SETFL, O_NONBLOCK) < 0)
-		err(-1, "%s: setup_tcp: fcntl(O_NONBLOCK)", test);
+		err(1, "%s: setup_tcp: fcntl(O_NONBLOCK)", test);
 	if (connect(sock2, (struct sockaddr *)&sin, sizeof(sin)) < 0 &&
 	    errno != EINPROGRESS)
-		err(-1, "%s: setup_tcp: connect(%s, %d)", test,
+		err(1, "%s: setup_tcp: connect(%s, %d)", test,
 		    inet_ntoa(sin.sin_addr), PORT1);
 
 	/*
 	 * Now pick up the connection after sleeping a moment to make sure
 	 * there's been time for some packets to go back and forth.
 	 */
-	if (sleep(1) < 0)
-		err(-1, "%s: sleep(1)", test);
+	if (sleep(1) != 0)
+		err(1, "%s: sleep(1)", test);
 	sock3 = accept(sock1, NULL, NULL);
 	if (sock3 < 0)
-		err(-1, "%s: accept", test);
-	if (sleep(1) < 0)
-		err(-1, "%s: sleep(1)", test);
+		err(1, "%s: accept", test);
+	if (sleep(1) != 0)
+		err(1, "%s: sleep(1)", test);
 
 	FD_ZERO(&writefds);
 	FD_SET(sock2, &writefds);
@@ -171,11 +171,11 @@ setup_tcp(const char *test, int *fdp)
 	tv.tv_usec = 0;
 	ret = select(sock2 + 1, NULL, &writefds, &exceptfds, &tv);
 	if (ret < 0)
-		err(-1, "%s: setup_tcp: select", test);
+		err(1, "%s: setup_tcp: select", test);
 	if (FD_ISSET(sock2, &exceptfds))
-		errx(-1, "%s: setup_tcp: select: exception", test);
+		errx(1, "%s: setup_tcp: select: exception", test);
 	if (!FD_ISSET(sock2, &writefds))
-		errx(-1, "%s: setup_tcp: select: not writable", test);
+		errx(1, "%s: setup_tcp: select: not writable", test);
 
 	close(sock1);
 	fdp[0] = sock2;
@@ -187,7 +187,7 @@ setup_udsstream(const char *test, int *f
 {
 
 	if (socketpair(PF_LOCAL, SOCK_STREAM, 0, fdp) < 0)
-		err(-1, "%s: setup_udsstream: socketpair", test);
+		err(1, "%s: setup_udsstream: socketpair", test);
 }
 
 static void
@@ -195,7 +195,7 @@ setup_udsdgram(const char *test, int *fd
 {
 
 	if (socketpair(PF_LOCAL, SOCK_DGRAM, 0, fdp) < 0)
-		err(-1, "%s: setup_udsdgram: socketpair", test);
+		err(1, "%s: setup_udsdgram: socketpair", test);
 }
 
 static void
@@ -203,7 +203,7 @@ setup_pipe(const char *test, int *fdp)
 {
 
 	if (pipe(fdp) < 0)
-		err(-1, "%s: setup_pipe: pipe", test);
+		err(1, "%s: setup_pipe: pipe", test);
 }
 
 static void
@@ -213,19 +213,19 @@ setup_fifo(const char *test, int *fdp)
 	int fd1, fd2;
 
 	if (mkstemp(path) == -1)
-		err(-1, "%s: setup_fifo: mktemp", test);
+		err(1, "%s: setup_fifo: mktemp", test);
 	unlink(path);
 
 	if (mkfifo(path, 0600) < 0)
-		err(-1, "%s: setup_fifo: mkfifo(%s)", test, path);
+		err(1, "%s: setup_fifo: mkfifo(%s)", test, path);
 
 	fd1 = open(path, O_RDONLY | O_NONBLOCK);
 	if (fd1 < 0)
-		err(-1, "%s: setup_fifo: open(%s, O_RDONLY)", test, path);
+		err(1, "%s: setup_fifo: open(%s, O_RDONLY)", test, path);
 
 	fd2 = open(path, O_WRONLY | O_NONBLOCK);
 	if (fd2 < 0)
-		err(-1, "%s: setup_fifo: open(%s, O_WRONLY)", test, path);
+		err(1, "%s: setup_fifo: open(%s, O_WRONLY)", test, path);
 
 	fdp[0] = fd2;
 	fdp[1] = fd1;
@@ -242,7 +242,7 @@ close_both(int *fdp)
 }
 
 int
-main(int argc, char *argv[])
+main(void)
 {
 	int fd[2];
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601210557.u0L5vWEL088865>