X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fsptps_test.c;h=5e785b3af96e0e9dafb4f9a156da3b8939cbd6bb;hb=3b6d366005b6fc23c705b3156e365316f6ab776c;hp=64b8cb22d24664687df5abff53d4141bcc59b6bd;hpb=d72a450975bed625e058eb857410f0d78caee2d1;p=tinc diff --git a/src/sptps_test.c b/src/sptps_test.c index 64b8cb22..5e785b3a 100644 --- a/src/sptps_test.c +++ b/src/sptps_test.c @@ -34,10 +34,6 @@ #include "sptps.h" #include "utils.h" -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - #ifndef HAVE_MINGW #define closesocket(s) close(s) #endif @@ -76,7 +72,7 @@ static bool send_data(void *handle, uint8_t type, const void *data, size_t len) bin2hex(data, hex, len); if(verbose) { - fprintf(stderr, "Sending %d bytes of data:\n%s\n", (int)len, hex); + fprintf(stderr, "Sending %zu bytes of data:\n%s\n", len, hex); } const int *sock = handle; @@ -162,7 +158,7 @@ void *stdin_reader_thread(void *arg) { fprintf(stderr, "New connection received from :%d\n", ntohs(sa.sin_port)); } - char buf[1024]; + uint8_t buf[1024]; ssize_t nread; while((nread = read(STDIN_FILENO, buf, sizeof(buf))) > 0) { @@ -170,7 +166,7 @@ void *stdin_reader_thread(void *arg) { fprintf(stderr, "Read %lld bytes from input\n", nread); } - char *start = buf; + uint8_t *start = buf; ssize_t nleft = nread; while(nleft) { @@ -479,7 +475,7 @@ int main(int argc, char *argv[]) { } else { fprintf(stderr, "Listening...\n"); - char buf[65536]; + uint8_t buf[65536]; struct sockaddr addr; socklen_t addrlen = sizeof(addr); @@ -648,7 +644,7 @@ int main(int argc, char *argv[]) { if(verbose) { char hex[len * 2 + 1]; bin2hex(buf, hex, len); - fprintf(stderr, "Received %d bytes of data:\n%s\n", (int)len, hex); + fprintf(stderr, "Received %zd bytes of data:\n%s\n", len, hex); } if(packetloss && (rand() % 100) < packetloss) { @@ -673,7 +669,7 @@ int main(int argc, char *argv[]) { } bufp += done; - len -= done; + len -= (ssize_t) done; } } }