svn commit: r294127 - head/tools/regression/sockets/zerosend
Steven Hartland
steven.hartland at multiplay.co.uk
Sat Jan 16 02:21:45 UTC 2016
The main params change seems a bit odd, wouldn't have expected that to
be valid, shouldn't they just be flagged __unused?
On 16/01/2016 02:18, Garrett Cooper wrote:
> Author: ngie
> Date: Sat Jan 16 02:18:36 2016
> New Revision: 294127
> URL: https://svnweb.freebsd.org/changeset/base/294127
>
> Log:
> 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
>
> MFC after: 5 days
> Sponsored by: EMC / Isilon Storage Division
>
> Modified:
> head/tools/regression/sockets/zerosend/Makefile
> head/tools/regression/sockets/zerosend/zerosend.c
> Directory Properties:
> head/ (props changed)
>
> Modified: head/tools/regression/sockets/zerosend/Makefile
> ==============================================================================
> --- head/tools/regression/sockets/zerosend/Makefile Sat Jan 16 02:15:13 2016 (r294126)
> +++ head/tools/regression/sockets/zerosend/Makefile Sat Jan 16 02:18:36 2016 (r294127)
> @@ -2,6 +2,6 @@
>
> PROG= zerosend
> MAN=
> -WARNS?= 2
> +WARNS?= 6
>
> .include <bsd.prog.mk>
>
> Modified: head/tools/regression/sockets/zerosend/zerosend.c
> ==============================================================================
> --- head/tools/regression/sockets/zerosend/zerosend.c Sat Jan 16 02:15:13 2016 (r294126)
> +++ head/tools/regression/sockets/zerosend/zerosend.c Sat Jan 16 02:18:36 2016 (r294127)
> @@ -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];
>
>
More information about the svn-src-all
mailing list