diff options
author | asomers <asomers@FreeBSD.org> | 2014-03-07 19:30:03 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2014-03-07 19:30:03 +0000 |
commit | 10361d66d0d438166a585c00112aa5d9fcf658cf (patch) | |
tree | 353394a61cf3bcefd5e229c520fbd5b06ce1bb63 /tests | |
parent | 1f687e831829570f1c05aee3dd795715ef53f48b (diff) | |
download | FreeBSD-src-10361d66d0d438166a585c00112aa5d9fcf658cf.zip FreeBSD-src-10361d66d0d438166a585c00112aa5d9fcf658cf.tar.gz |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/sys/kern/Makefile | 2 | ||||
-rw-r--r-- | tests/sys/kern/unix_seqpacket_test.c | 63 |
2 files changed, 31 insertions, 34 deletions
diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index 6b44eea..bf6ad55 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -8,4 +8,6 @@ TEST_METADATA.unix_seqpacket_test+= timeout="15" LDADD.unix_seqpacket_test+= -lpthread +WARNS?= 5 + .include <atf.test.mk> diff --git a/tests/sys/kern/unix_seqpacket_test.c b/tests/sys/kern/unix_seqpacket_test.c index 51769c4..102535b7 100644 --- a/tests/sys/kern/unix_seqpacket_test.c +++ b/tests/sys/kern/unix_seqpacket_test.c @@ -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 rcvbufsize) 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 rcvbufsize) 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 bufsize, int blocking) { 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); |