From owner-svn-src-head@FreeBSD.ORG Fri Mar 7 19:30:04 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9A8F8F9; Fri, 7 Mar 2014 19:30:04 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8773F5FF; Fri, 7 Mar 2014 19:30:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s27JU4s0006898; Fri, 7 Mar 2014 19:30:04 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s27JU4u1006894; Fri, 7 Mar 2014 19:30:04 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201403071930.s27JU4u1006894@svn.freebsd.org> From: Alan Somers Date: Fri, 7 Mar 2014 19:30:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262894 - head/tests/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Mar 2014 19:30:04 -0000 Author: asomers Date: Fri Mar 7 19:30:03 2014 New Revision: 262894 URL: http://svnweb.freebsd.org/changeset/base/262894 Log: kern/Makefile Set WARNS=5 for all files in this directory kern/unix_seqpacket_test.c Fix compiler warnings. Most were benign, but rcvbuf_oversized wasn't working as intended because I forgot to set the buffer sizes. MFC after: 2 weeks Reported by: pho Sponsored by: Spectra Logic Corporation Modified: head/tests/sys/kern/Makefile head/tests/sys/kern/unix_seqpacket_test.c Modified: head/tests/sys/kern/Makefile ============================================================================== --- head/tests/sys/kern/Makefile Fri Mar 7 17:47:53 2014 (r262893) +++ head/tests/sys/kern/Makefile Fri Mar 7 19:30:03 2014 (r262894) @@ -8,4 +8,6 @@ TEST_METADATA.unix_seqpacket_test+= time LDADD.unix_seqpacket_test+= -lpthread +WARNS?= 5 + .include Modified: head/tests/sys/kern/unix_seqpacket_test.c ============================================================================== --- head/tests/sys/kern/unix_seqpacket_test.c Fri Mar 7 17:47:53 2014 (r262893) +++ head/tests/sys/kern/unix_seqpacket_test.c Fri Mar 7 19:30:03 2014 (r262894) @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$"); #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) -void +static void do_socketpair(int *sv) { int s; @@ -55,7 +55,7 @@ do_socketpair(int *sv) ATF_REQUIRE(sv[0] != sv[1]); } -void +static void do_socketpair_nonblocking(int *sv) { int s; @@ -73,7 +73,7 @@ do_socketpair_nonblocking(int *sv) * Returns a pair of sockets made the hard way: bind, listen, connect & accept * @return const char* The path to the socket */ -const char* +static const char* mk_pair_of_sockets(int *sv) { struct sockaddr_un sun; @@ -116,7 +116,7 @@ mk_pair_of_sockets(int *sv) static volatile sig_atomic_t got_sigpipe = 0; static void -shutdown_send_sigpipe_handler(int x) +shutdown_send_sigpipe_handler(int __unused x) { got_sigpipe = 1; } @@ -124,16 +124,16 @@ shutdown_send_sigpipe_handler(int x) /* * Parameterized test function bodies */ -void +static void test_eagain(size_t sndbufsize, size_t rcvbufsize) { int i; int sv[2]; const size_t totalsize = (sndbufsize + rcvbufsize) * 2; const size_t pktsize = MIN(sndbufsize, rcvbufsize) / 4; + const int numpkts = totalsize / pktsize; char sndbuf[pktsize]; - char recv_buf[pktsize]; - ssize_t ssize, rsize; + ssize_t ssize; /* setup the socket pair */ do_socketpair_nonblocking(sv); @@ -145,7 +145,7 @@ test_eagain(size_t sndbufsize, size_t rc bzero(sndbuf, pktsize); /* Send data until we get EAGAIN */ - for(i=0; i < totalsize / pktsize; i++) { + for(i=0; i < numpkts; i++) { ssize = send(sv[0], sndbuf, pktsize, MSG_EOR); if (ssize == -1) { if (errno == EAGAIN) @@ -159,11 +159,11 @@ test_eagain(size_t sndbufsize, size_t rc atf_tc_fail("Never got EAGAIN"); } -void +static void test_sendrecv_symmetric_buffers(size_t bufsize, int blocking) { int s; int sv[2]; - const size_t pktsize = bufsize / 2; + const ssize_t pktsize = bufsize / 2; char sndbuf[pktsize]; char recv_buf[pktsize]; ssize_t ssize, rsize; @@ -201,12 +201,12 @@ test_sendrecv_symmetric_buffers(size_t b pktsize, rsize); } -void +static void test_pipe_simulator(size_t sndbufsize, size_t rcvbufsize) { - int s, num_sent, num_received; + int num_sent, num_received; int sv[2]; - const size_t pktsize = MIN(sndbufsize, rcvbufsize) / 4; + const ssize_t pktsize = MIN(sndbufsize, rcvbufsize) / 4; int numpkts; char sndbuf[pktsize]; char rcvbuf[pktsize]; @@ -331,12 +331,11 @@ test_pipe_reader(void* args) } -void +static void test_pipe(size_t sndbufsize, size_t rcvbufsize) { test_pipe_thread_data_t writer_data, reader_data; pthread_t writer, reader; - int num_sent, num_received; int sv[2]; const size_t pktsize = MIN(sndbufsize, rcvbufsize) / 4; int numpkts; @@ -611,12 +610,11 @@ ATF_TC_BODY(resize_connected_buffers, tc ATF_TC_WITHOUT_HEAD(send_recv); ATF_TC_BODY(send_recv, tc) { - int s; int sv[2]; const int bufsize = 64; const char *data = "data"; char recv_buf[bufsize]; - size_t datalen; + ssize_t datalen; ssize_t ssize, rsize; /* setup the socket pair */ @@ -648,12 +646,11 @@ ATF_TC_BODY(sendto_recvfrom, tc) { const char* path; struct sockaddr_storage from; - int s; int sv[2]; const int bufsize = 64; const char *data = "data"; char recv_buf[bufsize]; - size_t datalen; + ssize_t datalen; ssize_t ssize, rsize; socklen_t fromlen; @@ -696,12 +693,11 @@ ATF_TC_BODY(sendto_recvfrom, tc) ATF_TC_WITHOUT_HEAD(send_recv_with_connect); ATF_TC_BODY(send_recv_with_connect, tc) { - const char* path; int sv[2]; const int bufsize = 64; const char *data = "data"; char recv_buf[bufsize]; - size_t datalen; + ssize_t datalen; ssize_t ssize, rsize; mk_pair_of_sockets(sv); @@ -757,12 +753,11 @@ ATF_TC_BODY(shutdown_send_sigpipe, tc) ATF_TC_WITHOUT_HEAD(send_recv_nonblocking); ATF_TC_BODY(send_recv_nonblocking, tc) { - int s; int sv[2]; const int bufsize = 64; const char *data = "data"; char recv_buf[bufsize]; - size_t datalen; + ssize_t datalen; ssize_t ssize, rsize; /* setup the socket pair */ @@ -794,14 +789,12 @@ ATF_TC_BODY(send_recv_nonblocking, tc) ATF_TC_WITHOUT_HEAD(emsgsize); ATF_TC_BODY(emsgsize, tc) { - int s; int sv[2]; const size_t sndbufsize = 8192; const size_t rcvbufsize = 8192; const size_t pktsize = (sndbufsize + rcvbufsize) * 2; char sndbuf[pktsize]; - char recv_buf[pktsize]; - ssize_t ssize, rsize; + ssize_t ssize; /* setup the socket pair */ do_socketpair(sv); @@ -823,14 +816,12 @@ ATF_TC_BODY(emsgsize, tc) ATF_TC_WITHOUT_HEAD(emsgsize_nonblocking); ATF_TC_BODY(emsgsize_nonblocking, tc) { - int s; int sv[2]; const size_t sndbufsize = 8192; const size_t rcvbufsize = 8192; const size_t pktsize = (sndbufsize + rcvbufsize) * 2; char sndbuf[pktsize]; - char recv_buf[pktsize]; - ssize_t ssize, rsize; + ssize_t ssize; /* setup the socket pair */ do_socketpair_nonblocking(sv); @@ -883,25 +874,29 @@ ATF_TC_BODY(eagain_128k_128k, tc) ATF_TC_WITHOUT_HEAD(rcvbuf_oversized); ATF_TC_BODY(rcvbuf_oversized, tc) { - int s, i, j; + int i; int sv[2]; + const int pktsize = 1024; const size_t sndbufsize = 8192; const size_t rcvbufsize = 131072; - const size_t geom_mean_bufsize = 32768; - const int pktsize = 1024; + const size_t geometric_mean_bufsize = 32768; + const int numpkts = geometric_mean_bufsize / pktsize; char sndbuf[pktsize]; char recv_buf[pktsize]; - size_t datalen; ssize_t ssize, rsize; /* setup the socket pair */ do_socketpair_nonblocking(sv); + ATF_REQUIRE_EQ(0, setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &sndbufsize, + sizeof(sndbufsize))); + ATF_REQUIRE_EQ(0, setsockopt(sv[1], SOL_SOCKET, SO_RCVBUF, &rcvbufsize, + sizeof(rcvbufsize))); /* * Send and receive packets that are collectively greater than the send * buffer, but less than the receive buffer */ - for (i=0; i < geom_mean_bufsize / pktsize; i++) { + for (i=0; i < numpkts; i++) { /* Fill the buffer */ memset(sndbuf, i, pktsize);