]> git.meshlink.io Git - utcp/blobdiff - test.c
Fix warnings when compiling with -Wall -W.
[utcp] / test.c
diff --git a/test.c b/test.c
index 4a1bf16e3bff39ca60ac67472b3c4e0c8f9f0cd5..14747ffaeae9be4970019c67ad3961663de26b9e 100644 (file)
--- a/test.c
+++ b/test.c
@@ -47,10 +47,11 @@ void debug(const char *format, ...) {
        va_end(ap);
 }
 #else
-#define debug(...)
+#define debug(...) do {} while(0)
 #endif
 
 ssize_t do_recv(struct utcp_connection *c, const void *data, size_t len) {
+       (void)c;
        if(!data || !len) {
                if(errno) {
                        debug("Error: %s\n", strerror(errno));
@@ -76,6 +77,7 @@ ssize_t do_recv(struct utcp_connection *c, const void *data, size_t len) {
 }
 
 void do_accept(struct utcp_connection *nc, uint16_t port) {
+       (void)port;
        utcp_accept(nc, do_recv, NULL);
        c = nc;
        utcp_set_accept_cb(c->utcp, NULL, NULL);
@@ -127,6 +129,8 @@ int main(int argc, char *argv[]) {
 
        bool server = argc == 2;
        bool connected = false;
+       uint32_t flags = UTCP_TCP;
+       size_t read_size = 102400;
 
        if(getenv("DROPIN")) dropin = atof(getenv("DROPIN"));
        if(getenv("DROPOUT")) dropout = atof(getenv("DROPOUT"));
@@ -134,6 +138,8 @@ int main(int argc, char *argv[]) {
        if(getenv("DROPTO")) dropto = atoi(getenv("DROPTO"));
        if(getenv("REORDER")) reorder = atof(getenv("REORDER"));
        if(getenv("REORDER_DIST")) reorder_dist = atoi(getenv("REORDER_DIST"));
+       if(getenv("FLAGS")) flags = atoi(getenv("FLAGS"));
+       if(getenv("READ_SIZE")) read_size = atoi(getenv("READ_SIZE"));
 
        char *reference_filename = getenv("REFERENCE");
        if(reference_filename)
@@ -175,7 +181,7 @@ int main(int argc, char *argv[]) {
        utcp_set_user_timeout(u, 10);
 
        if(!server)
-               c = utcp_connect(u, 1, do_recv, NULL);
+               c = utcp_connect_ex(u, 1, do_recv, NULL, flags);
 
        struct pollfd fds[2] = {
                {.fd = 0, .events = POLLIN | POLLERR | POLLHUP},
@@ -189,6 +195,8 @@ int main(int argc, char *argv[]) {
                size_t max = c ? utcp_get_sndbuf_free(c) : 0;
                if(max > sizeof buf)
                        max = sizeof buf;
+               if(max > read_size)
+                       max = read_size;
 
                int timeout_ms = timeout.tv_sec * 1000 + timeout.tv_usec / 1000 + 1;