diff --git a/lib/util/millisleep.h b/libcperciva/util/millisleep.h similarity index 100% rename from lib/util/millisleep.h rename to libcperciva/util/millisleep.h diff --git a/perftests/recv-zeros/main.c b/perftests/recv-zeros/main.c index e953ac1e..c6ef9bab 100644 --- a/perftests/recv-zeros/main.c +++ b/perftests/recv-zeros/main.c @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -15,7 +14,7 @@ main(int argc, char ** argv) { /* Command-line parameters. */ const char * addr = NULL; - ssize_t buflen; + size_t buflen; /* Working variables. */ struct sock_addr * sa; @@ -37,14 +36,8 @@ main(int argc, char ** argv) goto err0; } - /* Sanity check. */ - if (buflen <= 0) { - warnp("Can't have a buffer length <= 0!"); - goto err0; - } - /* Allocate buffer. */ - if ((buffer = malloc((size_t)buflen)) == NULL) { + if ((buffer = malloc(buflen)) == NULL) { warnp("malloc"); goto err0; } @@ -76,8 +69,8 @@ main(int argc, char ** argv) /* Receive data, but do nothing with it. */ do { - r = recv(socket_recv, buffer, (size_t)buflen, MSG_WAITALL); - } while (r == buflen); + r = recv(socket_recv, buffer, buflen, MSG_WAITALL); + } while (r == (ssize_t)buflen); if (r != 0) { warnp("recv"); goto err4; diff --git a/perftests/send-zeros/main.c b/perftests/send-zeros/main.c index 765ef96b..1d43882a 100644 --- a/perftests/send-zeros/main.c +++ b/perftests/send-zeros/main.c @@ -3,10 +3,10 @@ #include #include +#include #include #include #include -#include #include #include "monoclock.h" @@ -42,21 +42,11 @@ main(int argc, char ** argv) warnp("parsenum"); goto err0; } - if (PARSENUM(&count, argv[3])) { + if (PARSENUM(&count, argv[3], 1, SIZE_MAX)) { warnp("parsenum"); goto err0; } - /* Sanity check. */ - if (buflen <= 0) { - warnp("Can't have a buffer length <= 0!"); - goto err0; - } - if (count == 0) { - warnp("Can't send 0 blocks!"); - goto err0; - } - /* Allocate and fill buffer to send. */ if ((buffer = malloc(buflen)) == NULL) { warnp("Out of memory"); diff --git a/perftests/standalone-enc/freebsd_flamegraph.sh b/perftests/standalone-enc/freebsd_flamegraph.sh index 8e9e4138..9aaf9a3b 100755 --- a/perftests/standalone-enc/freebsd_flamegraph.sh +++ b/perftests/standalone-enc/freebsd_flamegraph.sh @@ -58,7 +58,7 @@ if grep -q pipe_enc_thread "${outfilename}.folded" ; then else has_pipe_enc=0 fi -if [ "${KEEP_ALL}" -eq "0" -a "${has_pipe_enc}" -gt "0" ]; then +if [ "${KEEP_ALL}" -eq "0" ] && [ "${has_pipe_enc}" -gt "0" ]; then grep pipe_enc_thread "${outfilename}.folded" > "${outfilename}.tmp" mv "${outfilename}.tmp" "${outfilename}.folded" fi diff --git a/tests/nc-server/Makefile b/tests/nc-server/Makefile index 3da6a240..e2ffb166 100644 --- a/tests/nc-server/Makefile +++ b/tests/nc-server/Makefile @@ -22,7 +22,7 @@ clean: ${PROG}:${SRCS:.c=.o} ${LIBALL} ${CC} -o ${PROG} ${SRCS:.c=.o} ${LIBALL} ${LDFLAGS} ${LDADD_EXTRA} ${LDADD_REQ} ${LDADD_POSIX} -main.o: main.c ../../lib/util/millisleep.h ../../libcperciva/util/monoclock.h ../../libcperciva/util/parsenum.h ../../libcperciva/util/warnp.h simple_server.h +main.o: main.c ../../libcperciva/util/millisleep.h ../../libcperciva/util/monoclock.h ../../libcperciva/util/parsenum.h ../../libcperciva/util/warnp.h simple_server.h ${CC} ${CFLAGS_POSIX} -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DCPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\" -DAPISUPPORT_CONFIG_FILE=\"apisupport-config.h\" -I../.. ${IDIRS} ${CPPFLAGS} ${CFLAGS} -c main.c -o main.o simple_server.o: simple_server.c ../../libcperciva/events/events.h ../../libcperciva/network/network.h ../../libcperciva/external/queue/queue.h ../../libcperciva/util/sock.h ../../libcperciva/util/warnp.h simple_server.h ${CC} ${CFLAGS_POSIX} -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DCPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\" -DAPISUPPORT_CONFIG_FILE=\"apisupport-config.h\" -I../.. ${IDIRS} ${CPPFLAGS} ${CFLAGS} -c simple_server.c -o simple_server.o diff --git a/tests/nc-server/main.c b/tests/nc-server/main.c index e2416fd7..fb6ea648 100644 --- a/tests/nc-server/main.c +++ b/tests/nc-server/main.c @@ -68,6 +68,9 @@ write_bps(int sock, uint8_t * buf, size_t buflen, size_t bps) actual_sent += to_send; } while (remaining > 0); + /* Success! */ + return (0); + err0: /* Failure! */ return (-1); diff --git a/tests/nc-server/simple_server.c b/tests/nc-server/simple_server.c index 0d84b3c3..c2ab5a3d 100644 --- a/tests/nc-server/simple_server.c +++ b/tests/nc-server/simple_server.c @@ -170,8 +170,9 @@ callback_read(void * cookie, ssize_t lenread) /* If we have a message. */ if (lenread > 0) { /* Handle it with the parent code. */ - A->callback_nc_message(A->caller_cookie, R->buf, - (size_t)lenread, sock); + if (A->callback_nc_message(A->caller_cookie, R->buf, + (size_t)lenread, sock)) + goto err0; /* Try to read some more data. */ if ((R->network_read_cookie = network_read(R->sock_read, diff --git a/tests/pthread_create_blocking_np/Makefile b/tests/pthread_create_blocking_np/Makefile index f327fa0b..4ed06f76 100644 --- a/tests/pthread_create_blocking_np/Makefile +++ b/tests/pthread_create_blocking_np/Makefile @@ -25,5 +25,5 @@ ${PROG}:${SRCS:.c=.o} ${LIBALL} main.o: main.c ../../lib/util/pthread_create_blocking_np.h timing.h ../../libcperciva/util/warnp.h ${CC} ${CFLAGS_POSIX} -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DCPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\" -DAPISUPPORT_CONFIG_FILE=\"apisupport-config.h\" -I../.. ${IDIRS} ${CPPFLAGS} ${CFLAGS} -c main.c -o main.o -timing.o: timing.c ../../lib/util/millisleep.h ../../libcperciva/util/monoclock.h ../../lib/util/pthread_create_blocking_np.h ../../libcperciva/util/warnp.h timing.h +timing.o: timing.c ../../libcperciva/util/millisleep.h ../../libcperciva/util/monoclock.h ../../lib/util/pthread_create_blocking_np.h ../../libcperciva/util/warnp.h timing.h ${CC} ${CFLAGS_POSIX} -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DCPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\" -DAPISUPPORT_CONFIG_FILE=\"apisupport-config.h\" -I../.. ${IDIRS} ${CPPFLAGS} ${CFLAGS} -c timing.c -o timing.o diff --git a/tests/pushbits/Makefile b/tests/pushbits/Makefile index 0cbe2de8..f201f20c 100644 --- a/tests/pushbits/Makefile +++ b/tests/pushbits/Makefile @@ -23,7 +23,7 @@ clean: ${PROG}:${SRCS:.c=.o} ${LIBALL} ${CC} -o ${PROG} ${SRCS:.c=.o} ${LIBALL} ${LDFLAGS} ${LDADD_EXTRA} ${LDADD_REQ} ${LDADD_POSIX} -main.o: main.c ../../libcperciva/util/getopt.h ../../lib/util/millisleep.h ../../libcperciva/util/noeintr.h ../../libcperciva/util/parsenum.h ../../libcperciva/util/warnp.h ../../spipe/pushbits.h +main.o: main.c ../../libcperciva/util/getopt.h ../../libcperciva/util/millisleep.h ../../libcperciva/util/noeintr.h ../../libcperciva/util/parsenum.h ../../libcperciva/util/warnp.h ../../spipe/pushbits.h ${CC} ${CFLAGS_POSIX} -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DCPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\" -DAPISUPPORT_CONFIG_FILE=\"apisupport-config.h\" -I../.. ${IDIRS} ${CPPFLAGS} ${CFLAGS} -c main.c -o main.o pushbits.o: ../../spipe/pushbits.c ../../libcperciva/util/noeintr.h ../../lib/util/pthread_create_blocking_np.h ../../libcperciva/util/warnp.h ../../spipe/pushbits.h ${CC} ${CFLAGS_POSIX} -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -DCPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\" -DAPISUPPORT_CONFIG_FILE=\"apisupport-config.h\" -I../.. ${IDIRS} ${CPPFLAGS} ${CFLAGS} -c ../../spipe/pushbits.c -o pushbits.o