diff --git a/src/iperf.h b/src/iperf.h index 80581e5..9634f62 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -131,7 +131,7 @@ struct iperf_test int sender; /* client & !reverse or server & reverse */ int sender_has_retransmits; struct protocol *protocol; - char state; + signed char state; char *server_hostname; /* -c option */ char *bind_address; /* -B option */ int server_port; diff --git a/src/iperf_api.c b/src/iperf_api.c index c361dec..3f0b63f 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1206,7 +1206,7 @@ JSON_read(int fd) if (Nread(fd, (char*) &nsize, sizeof(nsize), Ptcp) >= 0) { hsize = ntohl(nsize); - str = (char *) malloc((hsize+1) * sizeof(char)); /* +1 for EOS */ + str = (char *) malloc(hsize+1); /* +1 for EOS */ if (str != NULL) { if (Nread(fd, str, hsize, Ptcp) >= 0) { str[hsize] = '\0'; /* add the EOS */ diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index fd76ae2..b7ec673 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -186,7 +186,7 @@ iperf_handle_message_client(struct iperf_test *test) { int rval, perr; - if ((rval = read(test->ctrl_sck, &test->state, sizeof(char))) <= 0) { + if ((rval = read(test->ctrl_sck, (char*) &test->state, sizeof(signed char))) <= 0) { if (rval == 0) { i_errno = IECTRLCLOSE; return -1; diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 9103937..b86f6a8 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -154,7 +154,7 @@ iperf_handle_message_server(struct iperf_test *test) struct iperf_stream *sp; // XXX: Need to rethink how this behaves to fit API - if ((rval = Nread(test->ctrl_sck, &test->state, sizeof(char), Ptcp)) <= 0) { + if ((rval = Nread(test->ctrl_sck, (char*) &test->state, sizeof(signed char), Ptcp)) <= 0) { if (rval == 0) { iperf_err(test, "the client has unexpectedly closed the connection"); i_errno = IECTRLCLOSE; diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c index b47ebda..1bbc248 100644 --- a/src/iperf_tcp.c +++ b/src/iperf_tcp.c @@ -79,7 +79,7 @@ int iperf_tcp_accept(struct iperf_test * test) { int s; - int rbuf = ACCESS_DENIED; + signed char rbuf = ACCESS_DENIED; char cookie[COOKIE_SIZE]; socklen_t len; struct sockaddr_storage addr; @@ -96,7 +96,7 @@ iperf_tcp_accept(struct iperf_test * test) } if (strcmp(test->cookie, cookie) != 0) { - if (Nwrite(s, (char*) &rbuf, sizeof(char), Ptcp) < 0) { + if (Nwrite(s, (char*) &rbuf, sizeof(signed char), Ptcp) < 0) { i_errno = IESENDMESSAGE; return -1; } diff --git a/src/main.c b/src/main.c index 4629d02..09d0904 100644 --- a/src/main.c +++ b/src/main.c @@ -86,7 +86,7 @@ main(int argc, char **argv) if (setjmp(env)) { if (test->ctrl_sck >= 0) { test->state = (test->role == 'c') ? CLIENT_TERMINATE : SERVER_TERMINATE; - if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) { + if (Nwrite(test->ctrl_sck, (char*) &test->state, sizeof(signed char), Ptcp) < 0) { i_errno = IESENDMESSAGE; return -1; }