Drop h and hh length modifiers from printf format strings.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 May 2014 14:35:37 +0000 (16:35 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 May 2014 14:35:37 +0000 (16:35 +0200)
C already guarantees that chars and shorts get passed as int. The few uses in tinc are mainly
to print fields of struct addrinfo, and fields like ai_family have different sizes on different
platforms, which actually caused some warnings to be generated.

src/multicast_device.c
src/protocol_auth.c
src/route.c
src/subnet.c

index ad0185a..ea43e2c 100644 (file)
@@ -1,7 +1,7 @@
 /*
     device.c -- multicast socket
     Copyright (C) 2002-2005 Ivo Timmermans,
 /*
     device.c -- multicast socket
     Copyright (C) 2002-2005 Ivo Timmermans,
-                  2002-2013 Guus Sliepen <guus@tinc-vpn.org>
+                  2002-2014 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -140,7 +140,7 @@ static bool setup_device(void) {
 #endif
        
                default:
 #endif
        
                default:
-                       logger(LOG_ERR, "Multicast for address family %hx unsupported", ai->ai_family);
+                       logger(LOG_ERR, "Multicast for address family %x unsupported", ai->ai_family);
                        closesocket(device_fd);
                        free(host);
                        return false;
                        closesocket(device_fd);
                        free(host);
                        return false;
index 66b7d03..971341f 100644 (file)
@@ -1,7 +1,7 @@
 /*
     protocol_auth.c -- handle the meta-protocol, authentication
     Copyright (C) 1999-2005 Ivo Timmermans,
 /*
     protocol_auth.c -- handle the meta-protocol, authentication
     Copyright (C) 1999-2005 Ivo Timmermans,
-                  2000-2013 Guus Sliepen <guus@tinc-vpn.org>
+                  2000-2014 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -107,7 +107,7 @@ static bool send_proxyrequest(connection_t *c) {
                                i += 2;
                                c->tcplen += 22;
                        } else {
                                i += 2;
                                c->tcplen += 22;
                        } else {
-                               logger(LOG_ERR, "Address family %hx not supported for SOCKS 5 proxies!", c->address.sa.sa_family);
+                               logger(LOG_ERR, "Address family %x not supported for SOCKS 5 proxies!", c->address.sa.sa_family);
                                return false;
                        }
                        if(i > len)
                                return false;
                        }
                        if(i > len)
index e196f44..c11267b 100644 (file)
@@ -1,7 +1,7 @@
 /*
     route.c -- routing
     Copyright (C) 2000-2005 Ivo Timmermans,
 /*
     route.c -- routing
     Copyright (C) 2000-2005 Ivo Timmermans,
-                  2000-2013 Guus Sliepen <guus@tinc-vpn.org>
+                  2000-2014 Guus Sliepen <guus@tinc-vpn.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -197,7 +197,7 @@ static void learn_mac(mac_t *address) {
        /* If we don't know this MAC address yet, store it */
 
        if(!subnet) {
        /* If we don't know this MAC address yet, store it */
 
        if(!subnet) {
-               ifdebug(TRAFFIC) logger(LOG_INFO, "Learned new MAC address %hx:%hx:%hx:%hx:%hx:%hx",
+               ifdebug(TRAFFIC) logger(LOG_INFO, "Learned new MAC address %x:%x:%x:%x:%x:%x",
                                   address->x[0], address->x[1], address->x[2], address->x[3],
                                   address->x[4], address->x[5]);
 
                                   address->x[0], address->x[1], address->x[2], address->x[3],
                                   address->x[4], address->x[5]);
 
index f8a3461..6e8ad07 100644 (file)
@@ -1,6 +1,6 @@
 /*
     subnet.c -- handle subnet lookups and lists
 /*
     subnet.c -- handle subnet lookups and lists
-    Copyright (C) 2000-2013 Guus Sliepen <guus@tinc-vpn.org>,
+    Copyright (C) 2000-2014 Guus Sliepen <guus@tinc-vpn.org>,
                   2000-2005 Ivo Timmermans
 
     This program is free software; you can redistribute it and/or modify
                   2000-2005 Ivo Timmermans
 
     This program is free software; you can redistribute it and/or modify
@@ -351,7 +351,7 @@ bool net2str(char *netstr, int len, const subnet_t *subnet) {
 
        switch (subnet->type) {
                case SUBNET_MAC:
 
        switch (subnet->type) {
                case SUBNET_MAC:
-                       snprintf(netstr, len, "%hx:%hx:%hx:%hx:%hx:%hx#%d",
+                       snprintf(netstr, len, "%x:%x:%x:%x:%x:%x#%d",
                                         subnet->net.mac.address.x[0],
                                         subnet->net.mac.address.x[1],
                                         subnet->net.mac.address.x[2],
                                         subnet->net.mac.address.x[0],
                                         subnet->net.mac.address.x[1],
                                         subnet->net.mac.address.x[2],
@@ -362,7 +362,7 @@ bool net2str(char *netstr, int len, const subnet_t *subnet) {
                        break;
 
                case SUBNET_IPV4:
                        break;
 
                case SUBNET_IPV4:
-                       snprintf(netstr, len, "%hu.%hu.%hu.%hu/%d#%d",
+                       snprintf(netstr, len, "%u.%u.%u.%u/%d#%d",
                                         subnet->net.ipv4.address.x[0],
                                         subnet->net.ipv4.address.x[1],
                                         subnet->net.ipv4.address.x[2],
                                         subnet->net.ipv4.address.x[0],
                                         subnet->net.ipv4.address.x[1],
                                         subnet->net.ipv4.address.x[2],
@@ -372,7 +372,7 @@ bool net2str(char *netstr, int len, const subnet_t *subnet) {
                        break;
 
                case SUBNET_IPV6:
                        break;
 
                case SUBNET_IPV6:
-                       snprintf(netstr, len, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%d#%d",
+                       snprintf(netstr, len, "%x:%x:%x:%x:%x:%x:%x:%x/%d#%d",
                                         ntohs(subnet->net.ipv6.address.x[0]),
                                         ntohs(subnet->net.ipv6.address.x[1]),
                                         ntohs(subnet->net.ipv6.address.x[2]),
                                         ntohs(subnet->net.ipv6.address.x[0]),
                                         ntohs(subnet->net.ipv6.address.x[1]),
                                         ntohs(subnet->net.ipv6.address.x[2]),