Skip to content

Commit

Permalink
Merge pull request #392 from Tarsnap/misc
Browse files Browse the repository at this point in the history
Misc
  • Loading branch information
cperciva authored Sep 20, 2023
2 parents af988fd + dea12d2 commit 50c24cd
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 29 deletions.
File renamed without changes.
15 changes: 4 additions & 11 deletions perftests/recv-zeros/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 2 additions & 12 deletions perftests/send-zeros/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include "monoclock.h"
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion perftests/standalone-enc/freebsd_flamegraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/nc-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions tests/nc-server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions tests/nc-server/simple_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/pthread_create_blocking_np/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/pushbits/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 50c24cd

Please sign in to comment.