projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move repeating MIN/MAX macros into dropin.h.
[tinc]
/
src
/
sptps_test.c
diff --git
a/src/sptps_test.c
b/src/sptps_test.c
index
64b8cb2
..
5e785b3
100644
(file)
--- a/
src/sptps_test.c
+++ b/
src/sptps_test.c
@@
-34,10
+34,6
@@
#include "sptps.h"
#include "utils.h"
#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
#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) {
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;
}
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));
}
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) {
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);
}
fprintf(stderr, "Read %lld bytes from input\n", nread);
}
-
char
*start = buf;
+
uint8_t
*start = buf;
ssize_t nleft = nread;
while(nleft) {
ssize_t nleft = nread;
while(nleft) {
@@
-479,7
+475,7
@@
int main(int argc, char *argv[]) {
} else {
fprintf(stderr, "Listening...\n");
} else {
fprintf(stderr, "Listening...\n");
-
char
buf[65536];
+
uint8_t
buf[65536];
struct sockaddr addr;
socklen_t addrlen = sizeof(addr);
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);
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) {
}
if(packetloss && (rand() % 100) < packetloss) {
@@
-673,7
+669,7
@@
int main(int argc, char *argv[]) {
}
bufp += done;
}
bufp += done;
- len -= done;
+ len -=
(ssize_t)
done;
}
}
}
}
}
}