Fix format strings for Windows.
authorGuus Sliepen <guus@tinc-vpn.org>
Thu, 2 Jun 2011 22:46:56 +0000 (00:46 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Thu, 2 Jun 2011 22:46:56 +0000 (00:46 +0200)
Windows doesn't like %zd, so cast (s)size_t to int. Also, some shorts were
incorrectly printed with %d instead of %hd.

src/net_socket.c
src/node.c
src/route.c

index d470fef..a1dfcd3 100644 (file)
@@ -456,7 +456,7 @@ static void handle_meta_write(int sock, short events, void *data) {
 
        ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, 0);
        if(outlen <= 0) {
 
        ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, 0);
        if(outlen <= 0) {
-               logger(LOG_ERR, "Onoes, outlen = %zd (%s)", outlen, strerror(errno));
+               logger(LOG_ERR, "Onoes, outlen = %d (%s)", (int)outlen, strerror(errno));
                terminate_connection(c, c->status.active);
                return;
        }
                terminate_connection(c, c->status.active);
                return;
        }
index dbc5a7e..96b557a 100644 (file)
@@ -171,11 +171,11 @@ bool dump_nodes(connection_t *c) {
 
        for(node = node_tree->head; node; node = node->next) {
                n = node->data;
 
        for(node = node_tree->head; node; node = node->next) {
                n = node->data;
-               send_request(c, "%d %d %s at %s cipher %d digest %d maclength %zd compression %d options %x status %04x nexthop %s via %s distance %d pmtu %d (min %d max %d)", CONTROL, REQ_DUMP_NODES,
+               send_request(c, "%d %d %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %hd (min %hd max %hd)", CONTROL, REQ_DUMP_NODES,
                           n->name, n->hostname, cipher_get_nid(&n->outcipher),
                           n->name, n->hostname, cipher_get_nid(&n->outcipher),
-                          digest_get_nid(&n->outdigest), digest_length(&n->outdigest), n->outcompression,
+                          digest_get_nid(&n->outdigest), (int)digest_length(&n->outdigest), n->outcompression,
                           n->options, bitfield_to_int(&n->status, sizeof n->status), n->nexthop ? n->nexthop->name : "-",
                           n->options, bitfield_to_int(&n->status, sizeof n->status), n->nexthop ? n->nexthop->name : "-",
-                          n->via ? n->via->name : "-", n->distance, n->mtu, n->minmtu, n->maxmtu);
+                          n->via ? n->via->name ?: "-" : "-", n->distance, n->mtu, n->minmtu, n->maxmtu);
        }
 
        return send_request(c, "%d %d", CONTROL, REQ_DUMP_NODES);
        }
 
        return send_request(c, "%d %d", CONTROL, REQ_DUMP_NODES);
index 618b0ab..0b2d22e 100644 (file)
@@ -347,7 +347,7 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet) {
        todo = ntohs(ip.ip_len) - ip_size;
 
        if(ether_size + ip_size + todo != packet->len) {
        todo = ntohs(ip.ip_len) - ip_size;
 
        if(ether_size + ip_size + todo != packet->len) {
-               ifdebug(TRAFFIC) logger(LOG_WARNING, "Length of packet (%d) doesn't match length in IPv4 header (%zd)", packet->len, ether_size + ip_size + todo);
+               ifdebug(TRAFFIC) logger(LOG_WARNING, "Length of packet (%d) doesn't match length in IPv4 header (%d)", packet->len, (int)(ether_size + ip_size + todo));
                return;
        }
 
                return;
        }