Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Mar 2014 19:30:04 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262894 - head/tests/sys/kern
Message-ID:  <201403071930.s27JU4u1006894@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <atf.test.mk>

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);
 



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