Convert sizeof foo to sizeof(foo).
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 7 Oct 2017 15:46:52 +0000 (17:46 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 7 Oct 2017 15:46:52 +0000 (17:46 +0200)
While technically sizeof is an operator and doesn't need the parentheses
around expressions it operates on, except if they are type names, code
formatters don't seem to handle this very well.

22 files changed:
src/bsd/device.c
src/conf.c
src/connection.c
src/graph.c
src/logger.c
src/multicast_device.c
src/net.c
src/net_packet.c
src/net_setup.c
src/net_socket.c
src/node.c
src/process.c
src/protocol.c
src/protocol_subnet.c
src/proxy.c
src/route.c
src/solaris/device.c
src/subnet.c
src/tincd.c
src/uml_device.c
src/utils.c
src/xalloc.h

index 95e65f9cbfa9bb866f27d95f488ea87e71035047..f6614b29a0b5e13e309fc2b9578e04d745a06b93 100644 (file)
@@ -75,7 +75,7 @@ static bool setup_utun(void) {
        }
 
        struct ctl_info info = {};
        }
 
        struct ctl_info info = {};
-       strlcpy(info.ctl_name, UTUN_CONTROL_NAME, sizeof info.ctl_name);
+       strlcpy(info.ctl_name, UTUN_CONTROL_NAME, sizeof(info.ctl_name));
 
        if(ioctl(device_fd, CTLIOCGINFO, &info) == -1) {
                logger(LOG_ERR, "ioctl(CTLIOCGINFO) failed: %s", strerror(errno));
 
        if(ioctl(device_fd, CTLIOCGINFO, &info) == -1) {
                logger(LOG_ERR, "ioctl(CTLIOCGINFO) failed: %s", strerror(errno));
@@ -92,7 +92,7 @@ static bool setup_utun(void) {
 
        struct sockaddr_ctl sc = {
                .sc_id = info.ctl_id,
 
        struct sockaddr_ctl sc = {
                .sc_id = info.ctl_id,
-               .sc_len = sizeof sc,
+               .sc_len = sizeof(sc),
                .sc_family = AF_SYSTEM,
                .ss_sysaddr = AF_SYS_CONTROL,
                .sc_unit = unit + 1,
                .sc_family = AF_SYSTEM,
                .ss_sysaddr = AF_SYS_CONTROL,
                .sc_unit = unit + 1,
@@ -104,7 +104,7 @@ static bool setup_utun(void) {
        }
 
        char name[64] = "";
        }
 
        char name[64] = "";
-       socklen_t len = sizeof name;
+       socklen_t len = sizeof(name);
        if(getsockopt(device_fd, SYSPROTO_CONTROL, UTUN_OPT_IFNAME, name, &len)) {
                iface = xstrdup(device);
        } else {
        if(getsockopt(device_fd, SYSPROTO_CONTROL, UTUN_OPT_IFNAME, name, &len)) {
                iface = xstrdup(device);
        } else {
@@ -225,7 +225,7 @@ static bool setup_device(void) {
 #ifdef TUNSIFHEAD
                {       
                        const int zero = 0;
 #ifdef TUNSIFHEAD
                {       
                        const int zero = 0;
-                       if(ioctl(device_fd, TUNSIFHEAD, &zero, sizeof zero) == -1) {
+                       if(ioctl(device_fd, TUNSIFHEAD, &zero, sizeof(zero)) == -1) {
                                logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno));
                                return false;
                        }
                                logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno));
                                return false;
                        }
@@ -234,7 +234,7 @@ static bool setup_device(void) {
 #if defined(TUNSIFMODE) && defined(IFF_BROADCAST) && defined(IFF_MULTICAST)
                {
                        const int mode = IFF_BROADCAST | IFF_MULTICAST;
 #if defined(TUNSIFMODE) && defined(IFF_BROADCAST) && defined(IFF_MULTICAST)
                {
                        const int mode = IFF_BROADCAST | IFF_MULTICAST;
-                       ioctl(device_fd, TUNSIFMODE, &mode, sizeof mode);
+                       ioctl(device_fd, TUNSIFMODE, &mode, sizeof(mode));
                }
 #endif
 
                }
 #endif
 
@@ -244,7 +244,7 @@ static bool setup_device(void) {
 #ifdef TUNSIFHEAD
                {
                        const int one = 1;
 #ifdef TUNSIFHEAD
                {
                        const int one = 1;
-                       if(ioctl(device_fd, TUNSIFHEAD, &one, sizeof one) == -1) {
+                       if(ioctl(device_fd, TUNSIFHEAD, &one, sizeof(one)) == -1) {
                                logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno));
                                return false;
                        }
                                logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno));
                                return false;
                        }
@@ -253,7 +253,7 @@ static bool setup_device(void) {
 #if defined(TUNSIFMODE) && defined(IFF_BROADCAST) && defined(IFF_MULTICAST)
                {
                                const int mode = IFF_BROADCAST | IFF_MULTICAST;
 #if defined(TUNSIFMODE) && defined(IFF_BROADCAST) && defined(IFF_MULTICAST)
                {
                                const int mode = IFF_BROADCAST | IFF_MULTICAST;
-                               ioctl(device_fd, TUNSIFMODE, &mode, sizeof mode);
+                               ioctl(device_fd, TUNSIFMODE, &mode, sizeof(mode));
                }
 #endif
 
                }
 #endif
 
@@ -429,7 +429,7 @@ static bool write_packet(vpn_packet_t *packet) {
                                        return false;
                        }
 
                                        return false;
                        }
 
-                       memcpy(packet->data + 10, &type, sizeof type);
+                       memcpy(packet->data + 10, &type, sizeof(type));
 
                        if(write(device_fd, packet->data + 10, packet->len - 10) < 0) {
                                logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device,
 
                        if(write(device_fd, packet->data + 10, packet->len - 10) < 0) {
                                logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device,
index 1c250d7bc3c76f4846d6de58351936a2cf48b6a5..82bc52163b11881588e7010d6921c70f2bc79ba9 100644 (file)
@@ -303,7 +303,7 @@ bool read_config_file(avl_tree_t *config_tree, const char *fname) {
        }
 
        for(;;) {
        }
 
        for(;;) {
-               line = readline(fp, buffer, sizeof buffer);
+               line = readline(fp, buffer, sizeof(buffer));
 
                if(!line) {
                        if(feof(fp))
 
                if(!line) {
                        if(feof(fp))
@@ -375,14 +375,14 @@ bool read_server_config(void) {
 
        read_config_options(config_tree, NULL);
 
 
        read_config_options(config_tree, NULL);
 
-       snprintf(fname, sizeof fname, "%s/tinc.conf", confbase);
+       snprintf(fname, sizeof(fname), "%s/tinc.conf", confbase);
        errno = 0;
        x = read_config_file(config_tree, fname);
 
        // We will try to read the conf files in the "conf.d" dir
        if (x) {
                char dname[PATH_MAX];
        errno = 0;
        x = read_config_file(config_tree, fname);
 
        // We will try to read the conf files in the "conf.d" dir
        if (x) {
                char dname[PATH_MAX];
-               snprintf(dname, sizeof dname, "%s/conf.d", confbase);
+               snprintf(dname, sizeof(dname), "%s/conf.d", confbase);
                DIR *dir = opendir (dname);
                // If we can find this dir
                if (dir) { 
                DIR *dir = opendir (dname);
                // If we can find this dir
                if (dir) { 
@@ -392,7 +392,7 @@ bool read_server_config(void) {
                                size_t l = strlen(ep->d_name);
                                // And we try to read the ones that end with ".conf"
                                if (l > 5 && !strcmp(".conf", & ep->d_name[ l - 5 ])) {
                                size_t l = strlen(ep->d_name);
                                // And we try to read the ones that end with ".conf"
                                if (l > 5 && !strcmp(".conf", & ep->d_name[ l - 5 ])) {
-                                       snprintf(fname, sizeof fname, "%s/%s", dname, ep->d_name);
+                                       snprintf(fname, sizeof(fname), "%s/%s", dname, ep->d_name);
                                        x = read_config_file(config_tree, fname);
                                }
                        }
                                        x = read_config_file(config_tree, fname);
                                }
                        }
@@ -413,7 +413,7 @@ bool read_connection_config(connection_t *c) {
 
        read_config_options(c->config_tree, c->name);
 
 
        read_config_options(c->config_tree, c->name);
 
-       snprintf(fname, sizeof fname, "%s/hosts/%s", confbase, c->name);
+       snprintf(fname, sizeof(fname), "%s/hosts/%s", confbase, c->name);
        x = read_config_file(c->config_tree, fname);
 
        return x;
        x = read_config_file(c->config_tree, fname);
 
        return x;
@@ -429,11 +429,11 @@ static void disable_old_keys(const char *filename) {
        if(!r)
                return;
 
        if(!r)
                return;
 
-       snprintf(tmpfile, sizeof tmpfile, "%s.tmp", filename);
+       snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename);
 
        w = fopen(tmpfile, "w");
 
 
        w = fopen(tmpfile, "w");
 
-       while(fgets(buf, sizeof buf, r)) {
+       while(fgets(buf, sizeof(buf), r)) {
                if(!strncmp(buf, "-----BEGIN RSA", 14)) {       
                        buf[11] = 'O';
                        buf[12] = 'L';
                if(!strncmp(buf, "-----BEGIN RSA", 14)) {       
                        buf[11] = 'O';
                        buf[12] = 'L';
@@ -465,7 +465,7 @@ static void disable_old_keys(const char *filename) {
 #ifdef HAVE_MINGW
                // We cannot atomically replace files on Windows.
                char bakfile[PATH_MAX] = "";
 #ifdef HAVE_MINGW
                // We cannot atomically replace files on Windows.
                char bakfile[PATH_MAX] = "";
-               snprintf(bakfile, sizeof bakfile, "%s.bak", filename);
+               snprintf(bakfile, sizeof(bakfile), "%s.bak", filename);
                if(rename(filename, bakfile) || rename(tmpfile, filename)) {
                        rename(bakfile, filename);
 #else
                if(rename(filename, bakfile) || rename(tmpfile, filename)) {
                        rename(bakfile, filename);
 #else
@@ -502,7 +502,7 @@ FILE *ask_and_open(const char *filename, const char *what) {
                                what, filename);
                fflush(stdout);
 
                                what, filename);
                fflush(stdout);
 
-               fn = readline(stdin, line, sizeof line);
+               fn = readline(stdin, line, sizeof(line));
 
                if(!fn) {
                        fprintf(stderr, "Error while reading stdin: %s\n",
 
                if(!fn) {
                        fprintf(stderr, "Error while reading stdin: %s\n",
@@ -521,8 +521,8 @@ FILE *ask_and_open(const char *filename, const char *what) {
        if(fn[0] != '/') {
 #endif
                /* The directory is a relative path or a filename. */
        if(fn[0] != '/') {
 #endif
                /* The directory is a relative path or a filename. */
-               getcwd(directory, sizeof directory);
-               snprintf(abspath, sizeof abspath, "%s/%s", directory, fn);
+               getcwd(directory, sizeof(directory));
+               snprintf(abspath, sizeof(abspath), "%s/%s", directory, fn);
                fn = abspath;
        }
 
                fn = abspath;
        }
 
index d27e6fd3ca72dee5c2cb362ba75eb18c70da8928..46b11c8546dce5aafc11c99ea79b461b07144656 100644 (file)
@@ -141,7 +141,7 @@ void dump_connections(void) {
        for(node = connection_tree->head; node; node = node->next) {
                c = node->data;
                logger(LOG_DEBUG, " %s at %s options %x socket %d status %04x outbuf %d/%d/%d",
        for(node = connection_tree->head; node; node = node->next) {
                c = node->data;
                logger(LOG_DEBUG, " %s at %s options %x socket %d status %04x outbuf %d/%d/%d",
-                          c->name, c->hostname, c->options, c->socket, bitfield_to_int(&c->status, sizeof c->status),
+                          c->name, c->hostname, c->options, c->socket, bitfield_to_int(&c->status, sizeof(c->status)),
                           c->outbufsize, c->outbufstart, c->outbuflen);
        }
 
                           c->outbufsize, c->outbufstart, c->outbuflen);
        }
 
index 8ffd70e455892935b2675bcfa6a1f5061761f737..5b90c62578165b0872443eff1f21635334211ef4 100644 (file)
@@ -293,7 +293,7 @@ static void sssp_bfs(void) {
 
                        if(!n->status.reachable) {
                                update_node_udp(n, NULL);
 
                        if(!n->status.reachable) {
                                update_node_udp(n, NULL);
-                               memset(&n->status, 0, sizeof n->status);
+                               memset(&n->status, 0, sizeof(n->status));
                                n->options = 0;
                        } else if(n->connection) {
                                send_ans_key(n);
                                n->options = 0;
                        } else if(n->connection) {
                                send_ans_key(n);
index 3f60edbaec094e8cae35b23861ecfdc5e96f549d..77c81339c4c8f51cb71ccdb084ea3651f1c4f122 100644 (file)
@@ -97,7 +97,7 @@ void logger(int priority, const char *format, ...) {
                        break;
                case LOGMODE_FILE:
                        now = time(NULL);
                        break;
                case LOGMODE_FILE:
                        now = time(NULL);
-                       strftime(timestr, sizeof timestr, "%Y-%m-%d %H:%M:%S", localtime(&now));
+                       strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", localtime(&now));
                        fprintf(logfile, "%s %s[%ld]: ", timestr, logident, (long)logpid);
                        vfprintf(logfile, format, ap);
                        fprintf(logfile, "\n");
                        fprintf(logfile, "%s %s[%ld]: ", timestr, logident, (long)logpid);
                        vfprintf(logfile, format, ap);
                        fprintf(logfile, "\n");
@@ -109,7 +109,7 @@ void logger(int priority, const char *format, ...) {
                                char message[4096];
                                const char *messages[] = {message};
                                vsnprintf(message, sizeof(message), format, ap);
                                char message[4096];
                                const char *messages[] = {message};
                                vsnprintf(message, sizeof(message), format, ap);
-                               message[sizeof message - 1] = 0;
+                               message[sizeof(message) - 1] = 0;
                                ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL);
                        }
 #else
                                ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL);
                        }
 #else
index ceaa3efc78d2881dc0bbd11d682571839b28fb14..5053036e21a626a3bfb8cf78df4b52e94e969924 100644 (file)
@@ -87,7 +87,7 @@ static bool setup_device(void) {
 #endif
 
        static const int one = 1;
 #endif
 
        static const int one = 1;
-       setsockopt(device_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof one);
+       setsockopt(device_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one));
 
        if(bind(device_fd, ai->ai_addr, ai->ai_addrlen)) {
                closesocket(device_fd);
 
        if(bind(device_fd, ai->ai_addr, ai->ai_addrlen)) {
                closesocket(device_fd);
@@ -101,20 +101,20 @@ static bool setup_device(void) {
                case AF_INET: {
                        struct ip_mreq mreq;
                        struct sockaddr_in in;
                case AF_INET: {
                        struct ip_mreq mreq;
                        struct sockaddr_in in;
-                       memcpy(&in, ai->ai_addr, sizeof in);
+                       memcpy(&in, ai->ai_addr, sizeof(in));
                        mreq.imr_multiaddr.s_addr = in.sin_addr.s_addr;
                        mreq.imr_interface.s_addr = htonl(INADDR_ANY);
                        mreq.imr_multiaddr.s_addr = in.sin_addr.s_addr;
                        mreq.imr_interface.s_addr = htonl(INADDR_ANY);
-                       if(setsockopt(device_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof mreq)) {
+                       if(setsockopt(device_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq))) {
                                logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno));
                                closesocket(device_fd);
                                free(host);
                                return false;
                        }
 #ifdef IP_MULTICAST_LOOP
                                logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno));
                                closesocket(device_fd);
                                free(host);
                                return false;
                        }
 #ifdef IP_MULTICAST_LOOP
-                       setsockopt(device_fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const void *)&one, sizeof one);
+                       setsockopt(device_fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const void *)&one, sizeof(one));
 #endif
 #ifdef IP_MULTICAST_TTL
 #endif
 #ifdef IP_MULTICAST_TTL
-                       setsockopt(device_fd, IPPROTO_IP, IP_MULTICAST_TTL, (void *)&ttl, sizeof ttl);
+                       setsockopt(device_fd, IPPROTO_IP, IP_MULTICAST_TTL, (void *)&ttl, sizeof(ttl));
 #endif
                } break;
 #endif
 #endif
                } break;
 #endif
@@ -123,20 +123,20 @@ static bool setup_device(void) {
                case AF_INET6: {
                        struct ipv6_mreq mreq;
                        struct sockaddr_in6 in6;
                case AF_INET6: {
                        struct ipv6_mreq mreq;
                        struct sockaddr_in6 in6;
-                       memcpy(&in6, ai->ai_addr, sizeof in6);
-                       memcpy(&mreq.ipv6mr_multiaddr, &in6.sin6_addr, sizeof mreq.ipv6mr_multiaddr);
+                       memcpy(&in6, ai->ai_addr, sizeof(in6));
+                       memcpy(&mreq.ipv6mr_multiaddr, &in6.sin6_addr, sizeof(mreq.ipv6mr_multiaddr));
                        mreq.ipv6mr_interface = in6.sin6_scope_id;
                        mreq.ipv6mr_interface = in6.sin6_scope_id;
-                       if(setsockopt(device_fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (void *)&mreq, sizeof mreq)) {
+                       if(setsockopt(device_fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (void *)&mreq, sizeof(mreq))) {
                                logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno));
                                closesocket(device_fd);
                                free(host);
                                return false;
                        }
 #ifdef IPV6_MULTICAST_LOOP
                                logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno));
                                closesocket(device_fd);
                                free(host);
                                return false;
                        }
 #ifdef IPV6_MULTICAST_LOOP
-                       setsockopt(device_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (const void *)&one, sizeof one);
+                       setsockopt(device_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (const void *)&one, sizeof(one));
 #endif
 #ifdef IPV6_MULTICAST_HOPS
 #endif
 #ifdef IPV6_MULTICAST_HOPS
-                       setsockopt(device_fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (void *)&ttl, sizeof ttl);
+                       setsockopt(device_fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (void *)&ttl, sizeof(ttl));
 #endif
                } break;
 #endif
 #endif
                } break;
 #endif
@@ -173,7 +173,7 @@ static bool read_packet(vpn_packet_t *packet) {
                return false;
        }
 
                return false;
        }
 
-       if(!memcmp(&ignore_src, packet->data + 6, sizeof ignore_src)) {
+       if(!memcmp(&ignore_src, packet->data + 6, sizeof(ignore_src))) {
                ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Ignoring loopback packet of %d bytes from %s", lenin, device_info);
                packet->len = 0;
                return true;
                ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Ignoring loopback packet of %d bytes from %s", lenin, device_info);
                packet->len = 0;
                return true;
@@ -201,7 +201,7 @@ static bool write_packet(vpn_packet_t *packet) {
 
        device_total_out += packet->len;
 
 
        device_total_out += packet->len;
 
-       memcpy(&ignore_src, packet->data + 6, sizeof ignore_src);
+       memcpy(&ignore_src, packet->data + 6, sizeof(ignore_src));
 
        return true;
 }
 
        return true;
 }
index b82dae805c843c5428beb908424c159d43a0aeaa..cac15f906c6fa9572a842891cebaa4191531105b 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -255,7 +255,7 @@ static void check_dead_connections(void) {
                        } else {
                                if(c->status.remove) {
                                        logger(LOG_WARNING, "Old connection_t for %s (%s) status %04x still lingering, deleting...",
                        } else {
                                if(c->status.remove) {
                                        logger(LOG_WARNING, "Old connection_t for %s (%s) status %04x still lingering, deleting...",
-                                                  c->name, c->hostname, bitfield_to_int(&c->status, sizeof c->status));
+                                                  c->name, c->hostname, bitfield_to_int(&c->status, sizeof(c->status)));
                                        connection_del(c);
                                        continue;
                                }
                                        connection_del(c);
                                        continue;
                                }
index 18eaf34bf16a2279680382a8bcdce34c0114ffd3..849c65acdd2ac71bf13d566bbe54b82b34083689 100644 (file)
@@ -264,7 +264,7 @@ static void receive_packet(node_t *n, vpn_packet_t *packet) {
 static bool try_mac(const node_t *n, const vpn_packet_t *inpkt) {
        unsigned char hmac[EVP_MAX_MD_SIZE];
 
 static bool try_mac(const node_t *n, const vpn_packet_t *inpkt) {
        unsigned char hmac[EVP_MAX_MD_SIZE];
 
-       if(!n->indigest || !n->inmaclength || !n->inkey || inpkt->len < sizeof inpkt->seqno + n->inmaclength)
+       if(!n->indigest || !n->inmaclength || !n->inkey || inpkt->len < sizeof(inpkt->seqno) + n->inmaclength)
                return false;
 
        HMAC(n->indigest, n->inkey, n->inkeylength, (unsigned char *) &inpkt->seqno, inpkt->len - n->inmaclength, (unsigned char *)hmac, NULL);
                return false;
 
        HMAC(n->indigest, n->inkey, n->inkeylength, (unsigned char *) &inpkt->seqno, inpkt->len - n->inmaclength, (unsigned char *)hmac, NULL);
@@ -394,7 +394,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) {
 void receive_tcppacket(connection_t *c, const char *buffer, int len) {
        vpn_packet_t outpkt;
 
 void receive_tcppacket(connection_t *c, const char *buffer, int len) {
        vpn_packet_t outpkt;
 
-       if(len > sizeof outpkt.data)
+       if(len > sizeof(outpkt.data))
                return;
 
        outpkt.len = len;
                return;
 
        outpkt.len = len;
@@ -522,7 +522,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) {
 
        if(origpriority == -1 && n->prevedge) {
                sock = rand() % listen_sockets;
 
        if(origpriority == -1 && n->prevedge) {
                sock = rand() % listen_sockets;
-               memset(&broadcast, 0, sizeof broadcast);
+               memset(&broadcast, 0, sizeof(broadcast));
                if(listen_socket[sock].sa.sa.sa_family == AF_INET6) {
                        broadcast.in6.sin6_family = AF_INET6;
                        broadcast.in6.sin6_addr.s6_addr[0x0] = 0xff;
                if(listen_socket[sock].sa.sa.sa_family == AF_INET6) {
                        broadcast.in6.sin6_family = AF_INET6;
                        broadcast.in6.sin6_addr.s6_addr[0x0] = 0xff;
index 2371f7ee099c5390800ec484387867d874bf0c75..d0ab464d3430eeb7e3a85dee644fe28f0d558f8a 100644 (file)
@@ -326,7 +326,7 @@ char *get_name(void) {
                                free(name);
                                return false;
                        }
                                free(name);
                                return false;
                        }
-                       if(gethostname(hostname, sizeof hostname) || !*hostname) {
+                       if(gethostname(hostname, sizeof(hostname)) || !*hostname) {
                                fprintf(stderr, "Could not get hostname: %s\n", strerror(errno));
                                free(name);
                                return false;
                                fprintf(stderr, "Could not get hostname: %s\n", strerror(errno));
                                free(name);
                                return false;
@@ -801,7 +801,7 @@ static bool setup_myself(void) {
                }
 
                for(i = 0; i < listen_sockets; i++) {
                }
 
                for(i = 0; i < listen_sockets; i++) {
-                       salen = sizeof sa;
+                       salen = sizeof(sa);
                        if(getsockname(i + 3, &sa.sa, &salen) < 0) {
                                logger(LOG_ERR, "Could not get address of listen fd %d: %s", i + 3, sockstrerror(errno));
                                return false;
                        if(getsockname(i + 3, &sa.sa, &salen) < 0) {
                                logger(LOG_ERR, "Could not get address of listen fd %d: %s", i + 3, sockstrerror(errno));
                                return false;
@@ -906,7 +906,7 @@ static bool setup_myself(void) {
 
        if(!port_specified) {
                sockaddr_t sa;
 
        if(!port_specified) {
                sockaddr_t sa;
-               socklen_t salen = sizeof sa;
+               socklen_t salen = sizeof(sa);
                if(!getsockname(listen_socket[0].udp, &sa.sa, &salen)) {
                        free(myport);
                        sockaddr2str(&sa, NULL, &myport);
                if(!getsockname(listen_socket[0].udp, &sa.sa, &salen)) {
                        free(myport);
                        sockaddr2str(&sa, NULL, &myport);
index 9d5837f99053b43e4993a5325c48675820fbc9e1..1497a8d0089e677bd848f783f530de1503de6231 100644 (file)
@@ -140,7 +140,7 @@ int setup_listen_socket(const sockaddr_t *sa) {
 
 #if defined(SOL_IPV6) && defined(IPV6_V6ONLY)
        if(sa->sa.sa_family == AF_INET6)
 
 #if defined(SOL_IPV6) && defined(IPV6_V6ONLY)
        if(sa->sa.sa_family == AF_INET6)
-               setsockopt(nfd, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option);
+               setsockopt(nfd, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
 #endif
 
        if(get_config_string(lookup_config(config_tree, "BindToInterface"), &iface)) {
 #endif
 
        if(get_config_string(lookup_config(config_tree, "BindToInterface"), &iface)) {
@@ -230,7 +230,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa) {
 
 #if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
        if(sa->sa.sa_family == AF_INET6)
 
 #if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
        if(sa->sa.sa_family == AF_INET6)
-               setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option);
+               setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
 #endif
 
 #if defined(IP_DONTFRAG) && !defined(IP_DONTFRAGMENT)
 #endif
 
 #if defined(IP_DONTFRAG) && !defined(IP_DONTFRAGMENT)
@@ -404,7 +404,7 @@ begin:
 
                // If we cannot resolve the address, maybe we are using a proxy that can?
                if(!c->outgoing->ai && proxytype != PROXY_NONE && is_valid_host_port(address, port)) {
 
                // If we cannot resolve the address, maybe we are using a proxy that can?
                if(!c->outgoing->ai && proxytype != PROXY_NONE && is_valid_host_port(address, port)) {
-                       memset(&c->address, 0, sizeof c->address);
+                       memset(&c->address, 0, sizeof(c->address));
                        c->address.sa.sa_family = AF_UNKNOWN;
                        c->address.unknown.address = address;
                        c->address.unknown.port = port;
                        c->address.sa.sa_family = AF_UNKNOWN;
                        c->address.unknown.address = address;
                        c->address.unknown.port = port;
@@ -468,7 +468,7 @@ connect:
 #if defined(SOL_IPV6) && defined(IPV6_V6ONLY)
                int option = 1;
                if(c->address.sa.sa_family == AF_INET6)
 #if defined(SOL_IPV6) && defined(IPV6_V6ONLY)
                int option = 1;
                if(c->address.sa.sa_family == AF_INET6)
-                       setsockopt(c->socket, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option);
+                       setsockopt(c->socket, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
 #endif
 
                bind_to_interface(c->socket);
 #endif
 
                bind_to_interface(c->socket);
index 19f37306d9a5f193233cbfd5081c983cc2278dfe..23ebd8dea9698cc53f42ea671ae96bf7d95bb8a9 100644 (file)
@@ -159,7 +159,7 @@ void update_node_udp(node_t *n, const sockaddr_t *sa) {
                avl_insert(node_udp_tree, n);
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
        } else {
                avl_insert(node_udp_tree, n);
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname);
        } else {
-               memset(&n->address, 0, sizeof n->address);
+               memset(&n->address, 0, sizeof(n->address));
                n->hostname = NULL;
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name);
        }
                n->hostname = NULL;
                ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name);
        }
@@ -176,7 +176,7 @@ void dump_nodes(void) {
                logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s pmtu %d (min %d max %d)",
                           n->name, n->hostname, n->outcipher ? EVP_CIPHER_nid(n->outcipher) : 0,
                           n->outdigest ? EVP_MD_type(n->outdigest) : 0, n->outmaclength, n->outcompression,
                logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s pmtu %d (min %d max %d)",
                           n->name, n->hostname, n->outcipher ? EVP_CIPHER_nid(n->outcipher) : 0,
                           n->outdigest ? EVP_MD_type(n->outdigest) : 0, n->outmaclength, 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->mtu, n->minmtu, n->maxmtu);
        }
 
                           n->via ? n->via->name : "-", n->mtu, n->minmtu, n->maxmtu);
        }
 
index bd85a80f281b6eb12cde5aff6d6c4d6087e0a22a..9969146f5b00ce42d00c5f8d5260b2c9d63e238b 100644 (file)
@@ -72,25 +72,25 @@ bool install_service(void) {
        }
 
        if(!strchr(program_name, '\\')) {
        }
 
        if(!strchr(program_name, '\\')) {
-               GetCurrentDirectory(sizeof command - 1, command + 1);
-               strncat(command, "\\", sizeof command - strlen(command));
+               GetCurrentDirectory(sizeof(command) - 1, command + 1);
+               strncat(command, "\\", sizeof(command) - strlen(command));
        }
 
        }
 
-       strncat(command, program_name, sizeof command - strlen(command));
+       strncat(command, program_name, sizeof(command) - strlen(command));
 
 
-       strncat(command, "\"", sizeof command - strlen(command));
+       strncat(command, "\"", sizeof(command) - strlen(command));
 
        for(argp = g_argv + 1; *argp; argp++) {
                space = strchr(*argp, ' ');
 
        for(argp = g_argv + 1; *argp; argp++) {
                space = strchr(*argp, ' ');
-               strncat(command, " ", sizeof command - strlen(command));
+               strncat(command, " ", sizeof(command) - strlen(command));
                
                if(space)
                
                if(space)
-                       strncat(command, "\"", sizeof command - strlen(command));
+                       strncat(command, "\"", sizeof(command) - strlen(command));
                
                
-               strncat(command, *argp, sizeof command - strlen(command));
+               strncat(command, *argp, sizeof(command) - strlen(command));
 
                if(space)
 
                if(space)
-                       strncat(command, "\"", sizeof command - strlen(command));
+                       strncat(command, "\"", sizeof(command) - strlen(command));
        }
 
        service = CreateService(manager, identname, identname,
        }
 
        service = CreateService(manager, identname, identname,
index eadca13fc3790a3ddd41750f5c864cf0bce596db..3c9668314cbbcd3b73c1e9dc755eb3ca1eb672a0 100644 (file)
@@ -75,11 +75,11 @@ bool send_request(connection_t *c, const char *format, ...) {
           input buffer anyway */
 
        va_start(args, format);
           input buffer anyway */
 
        va_start(args, format);
-       len = vsnprintf(buffer, sizeof buffer, format, args);
-       buffer[sizeof buffer - 1] = 0;
+       len = vsnprintf(buffer, sizeof(buffer), format, args);
+       buffer[sizeof(buffer) - 1] = 0;
        va_end(args);
 
        va_end(args);
 
-       if(len < 0 || len > sizeof buffer - 1) {
+       if(len < 0 || len > sizeof(buffer) - 1) {
                logger(LOG_ERR, "Output buffer overflow while sending request to %s (%s)",
                           c->name, c->hostname);
                return false;
                logger(LOG_ERR, "Output buffer overflow while sending request to %s (%s)",
                           c->name, c->hostname);
                return false;
index 62656c38302e8587ab10dfb4cb1f36e24ad2239e..15ec8bf4c807ce33f0a24e20920416f39f96a2b8 100644 (file)
@@ -35,7 +35,7 @@
 bool send_add_subnet(connection_t *c, const subnet_t *subnet) {
        char netstr[MAXNETSTR];
 
 bool send_add_subnet(connection_t *c, const subnet_t *subnet) {
        char netstr[MAXNETSTR];
 
-       if(!net2str(netstr, sizeof netstr, subnet))
+       if(!net2str(netstr, sizeof(netstr), subnet))
                return false;
 
        return send_request(c, "%d %x %s %s", ADD_SUBNET, rand(), subnet->owner->name, netstr);
                return false;
 
        return send_request(c, "%d %x %s %s", ADD_SUBNET, rand(), subnet->owner->name, netstr);
@@ -144,7 +144,7 @@ bool add_subnet_h(connection_t *c) {
 bool send_del_subnet(connection_t *c, const subnet_t *s) {
        char netstr[MAXNETSTR];
 
 bool send_del_subnet(connection_t *c, const subnet_t *s) {
        char netstr[MAXNETSTR];
 
-       if(!net2str(netstr, sizeof netstr, s))
+       if(!net2str(netstr, sizeof(netstr), s))
                return false;
 
        return send_request(c, "%d %x %s %s", DEL_SUBNET, rand(), s->owner->name, netstr);
                return false;
 
        return send_request(c, "%d %x %s %s", DEL_SUBNET, rand(), s->owner->name, netstr);
index ba48218cbf488b25195962f5da4901d0fe9677e6..75e41ded306a2beb6d721d81d6232ffa2c4dcedd 100644 (file)
@@ -35,7 +35,7 @@ char *proxypass;
 
 static void update_address_ipv4(connection_t *c, void *address, void *port) {
        sockaddrfree(&c->address);
 
 static void update_address_ipv4(connection_t *c, void *address, void *port) {
        sockaddrfree(&c->address);
-       memset(&c->address, 0, sizeof c->address);
+       memset(&c->address, 0, sizeof(c->address));
        c->address.sa.sa_family = AF_INET;
        if(address)
                memcpy(&c->address.in.sin_addr, address, sizeof(ipv4_t));
        c->address.sa.sa_family = AF_INET;
        if(address)
                memcpy(&c->address.in.sin_addr, address, sizeof(ipv4_t));
@@ -48,7 +48,7 @@ static void update_address_ipv4(connection_t *c, void *address, void *port) {
 
 static void update_address_ipv6(connection_t *c, void *address, void *port) {
        sockaddrfree(&c->address);
 
 static void update_address_ipv6(connection_t *c, void *address, void *port) {
        sockaddrfree(&c->address);
-       memset(&c->address, 0, sizeof c->address);
+       memset(&c->address, 0, sizeof(c->address));
        c->address.sa.sa_family = AF_INET6;
        if(address)
                memcpy(&c->address.in6.sin6_addr, address, sizeof(ipv6_t));
        c->address.sa.sa_family = AF_INET6;
        if(address)
                memcpy(&c->address.in6.sin6_addr, address, sizeof(ipv6_t));
@@ -92,9 +92,9 @@ bool send_proxyrequest(connection_t *c) {
                        strcpy(s4req + 8, proxyuser);
                else
                        s4req[8] = 0;
                        strcpy(s4req + 8, proxyuser);
                else
                        s4req[8] = 0;
-               s4req[sizeof s4req - 1] = 0;
+               s4req[sizeof(s4req) - 1] = 0;
                c->allow_request = PROXY;
                c->allow_request = PROXY;
-               return send_meta(c, s4req, sizeof s4req);
+               return send_meta(c, s4req, sizeof(s4req));
        }
 
        case PROXY_SOCKS5: {
        }
 
        case PROXY_SOCKS5: {
@@ -158,7 +158,7 @@ bool send_proxyrequest(connection_t *c) {
                if(i > len)
                        abort();
                c->allow_request = PROXY;
                if(i > len)
                        abort();
                c->allow_request = PROXY;
-               return send_meta(c, s5req, sizeof s5req);
+               return send_meta(c, s5req, sizeof(s5req));
        }
 
        case PROXY_HTTP: {
        }
 
        case PROXY_HTTP: {
index 107ad7490025bbd4bccdc0471d3352adbf3d7db1..ef6875955976ef7cafef22fdeb8c2bbfce498e11 100644 (file)
@@ -104,9 +104,9 @@ static bool checklength(node_t *source, vpn_packet_t *packet, length_t length) {
 
 static void swap_mac_addresses(vpn_packet_t *packet) {
        mac_t tmp;
 
 static void swap_mac_addresses(vpn_packet_t *packet) {
        mac_t tmp;
-       memcpy(&tmp, &packet->data[0], sizeof tmp);
-       memcpy(&packet->data[0], &packet->data[6], sizeof tmp);
-       memcpy(&packet->data[6], &tmp, sizeof tmp);
+       memcpy(&tmp, &packet->data[0], sizeof(tmp));
+       memcpy(&packet->data[0], &packet->data[6], sizeof(tmp));
+       memcpy(&packet->data[6], &tmp, sizeof(tmp));
 }
 
 /* RFC 792 */
 }
 
 /* RFC 792 */
@@ -483,7 +483,7 @@ void age_subnets(void) {
                if(s->expires && s->expires <= now) {
                        ifdebug(TRAFFIC) {
                                char netstr[MAXNETSTR];
                if(s->expires && s->expires <= now) {
                        ifdebug(TRAFFIC) {
                                char netstr[MAXNETSTR];
-                               if(net2str(netstr, sizeof netstr, s))
+                               if(net2str(netstr, sizeof(netstr), s))
                                        logger(LOG_INFO, "Subnet %s expired", netstr);
                        }
 
                                        logger(LOG_INFO, "Subnet %s expired", netstr);
                        }
 
@@ -562,7 +562,7 @@ static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet) {
        node_t *via;
        ipv4_t dest;
 
        node_t *via;
        ipv4_t dest;
 
-       memcpy(&dest, &packet->data[30], sizeof dest);
+       memcpy(&dest, &packet->data[30], sizeof(dest));
        subnet = lookup_subnet_ipv4(&dest);
 
        if(!subnet) {
        subnet = lookup_subnet_ipv4(&dest);
 
        if(!subnet) {
@@ -641,7 +641,7 @@ static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet) {
        node_t *via;
        ipv6_t dest;
 
        node_t *via;
        ipv6_t dest;
 
-       memcpy(&dest, &packet->data[38], sizeof dest);
+       memcpy(&dest, &packet->data[38], sizeof(dest));
        subnet = lookup_subnet_ipv6(&dest);
 
        if(!subnet) {
        subnet = lookup_subnet_ipv6(&dest);
 
        if(!subnet) {
@@ -938,13 +938,13 @@ static void route_mac(node_t *source, vpn_packet_t *packet) {
 
        if(source == myself) {
                mac_t src;
 
        if(source == myself) {
                mac_t src;
-               memcpy(&src, &packet->data[6], sizeof src);
+               memcpy(&src, &packet->data[6], sizeof(src));
                learn_mac(&src);
        }
 
        /* Lookup destination address */
 
                learn_mac(&src);
        }
 
        /* Lookup destination address */
 
-       memcpy(&dest, &packet->data[0], sizeof dest);
+       memcpy(&dest, &packet->data[0], sizeof(dest));
        subnet = lookup_subnet_mac(NULL, &dest);
 
        if(!subnet) {
        subnet = lookup_subnet_mac(NULL, &dest);
 
        if(!subnet) {
index 0074615db3979d28bd20f19ca0f6d54c73200e4b..73046b8c8f9e76c17afcc9fefe6d73c98e4691cb 100644 (file)
@@ -115,7 +115,7 @@ static bool setup_device(void) {
 
        struct strioctl strioc_ppa = {
                .ic_cmd = TUNNEWPPA,
 
        struct strioctl strioc_ppa = {
                .ic_cmd = TUNNEWPPA,
-               .ic_len = sizeof ppa,
+               .ic_len = sizeof(ppa),
                .ic_dp = (char *)&ppa,
        };
 
                .ic_dp = (char *)&ppa,
        };
 
@@ -156,7 +156,7 @@ static bool setup_device(void) {
        {
                /* Remove muxes just in case they are left over from a crashed tincd */
                struct lifreq ifr = {};
        {
                /* Remove muxes just in case they are left over from a crashed tincd */
                struct lifreq ifr = {};
-               strncpy(ifr.lifr_name, iface, sizeof ifr.lifr_name);
+               strncpy(ifr.lifr_name, iface, sizeof(ifr.lifr_name));
                if(ioctl(ip_fd, SIOCGLIFMUXID, &ifr) >= 0) {
                        int muxid = ifr.lifr_arp_muxid;
                        ioctl(ip_fd, I_PUNLINK, muxid);
                if(ioctl(ip_fd, SIOCGLIFMUXID, &ifr) >= 0) {
                        int muxid = ifr.lifr_arp_muxid;
                        ioctl(ip_fd, I_PUNLINK, muxid);
@@ -229,7 +229,7 @@ static bool setup_device(void) {
                /* Set ifname to arp */
                struct strioctl strioc_if = {
                        .ic_cmd = SIOCSLIFNAME,
                /* Set ifname to arp */
                struct strioctl strioc_if = {
                        .ic_cmd = SIOCSLIFNAME,
-                       .ic_len = sizeof ifr,
+                       .ic_len = sizeof(ifr),
                        .ic_dp = (char *)&ifr,
                };
 
                        .ic_dp = (char *)&ifr,
                };
 
@@ -285,7 +285,7 @@ static bool setup_device(void) {
 static void close_device(void) {
        if(iface) {
                struct lifreq ifr = {};
 static void close_device(void) {
        if(iface) {
                struct lifreq ifr = {};
-               strncpy(ifr.lifr_name, iface, sizeof ifr.lifr_name);
+               strncpy(ifr.lifr_name, iface, sizeof(ifr.lifr_name));
                if(ioctl(ip_fd, SIOCGLIFMUXID, &ifr) >= 0) {
                        int muxid = ifr.lifr_arp_muxid;
                        ioctl(ip_fd, I_PUNLINK, muxid);
                if(ioctl(ip_fd, SIOCGLIFMUXID, &ifr) >= 0) {
                        int muxid = ifr.lifr_arp_muxid;
                        ioctl(ip_fd, I_PUNLINK, muxid);
index b4a636b3026ca201b7e70519eb4a1577c2a41df2..43a7ad218f10bb60b5c5bf38a442e0424fe8d85a 100644 (file)
@@ -413,7 +413,7 @@ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) {
                        continue;
                if(owner && cache_mac_subnet[i] && cache_mac_subnet[i]->owner != owner)
                        continue;
                        continue;
                if(owner && cache_mac_subnet[i] && cache_mac_subnet[i]->owner != owner)
                        continue;
-               if(!memcmp(address, &cache_mac_address[i], sizeof *address))
+               if(!memcmp(address, &cache_mac_address[i], sizeof(*address)))
                        return cache_mac_subnet[i];
        }
 
                        return cache_mac_subnet[i];
        }
 
@@ -425,7 +425,7 @@ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) {
                if(!p || p->type != SUBNET_MAC)
                        continue;
 
                if(!p || p->type != SUBNET_MAC)
                        continue;
 
-               if(!memcmp(address, &p->net.mac.address, sizeof *address)) {
+               if(!memcmp(address, &p->net.mac.address, sizeof(*address))) {
                        r = p;
                        if(p->owner->status.reachable)
                                break;
                        r = p;
                        if(p->owner->status.reachable)
                                break;
@@ -435,7 +435,7 @@ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) {
        // Cache the result
 
        cache_mac_slot = !cache_mac_slot;
        // Cache the result
 
        cache_mac_slot = !cache_mac_slot;
-       memcpy(&cache_mac_address[cache_mac_slot], address, sizeof *address);
+       memcpy(&cache_mac_address[cache_mac_slot], address, sizeof(*address));
        cache_mac_subnet[cache_mac_slot] = r;
        cache_mac_valid[cache_mac_slot] = true;
 
        cache_mac_subnet[cache_mac_slot] = r;
        cache_mac_valid[cache_mac_slot] = true;
 
@@ -452,7 +452,7 @@ subnet_t *lookup_subnet_ipv4(const ipv4_t *address) {
        for(i = 0; i < 2; i++) {
                if(!cache_ipv4_valid[i])
                        continue;
        for(i = 0; i < 2; i++) {
                if(!cache_ipv4_valid[i])
                        continue;
-               if(!memcmp(address, &cache_ipv4_address[i], sizeof *address))
+               if(!memcmp(address, &cache_ipv4_address[i], sizeof(*address)))
                        return cache_ipv4_subnet[i];
        }
 
                        return cache_ipv4_subnet[i];
        }
 
@@ -474,7 +474,7 @@ subnet_t *lookup_subnet_ipv4(const ipv4_t *address) {
        // Cache the result
 
        cache_ipv4_slot = !cache_ipv4_slot;
        // Cache the result
 
        cache_ipv4_slot = !cache_ipv4_slot;
-       memcpy(&cache_ipv4_address[cache_ipv4_slot], address, sizeof *address);
+       memcpy(&cache_ipv4_address[cache_ipv4_slot], address, sizeof(*address));
        cache_ipv4_subnet[cache_ipv4_slot] = r;
        cache_ipv4_valid[cache_ipv4_slot] = true;
 
        cache_ipv4_subnet[cache_ipv4_slot] = r;
        cache_ipv4_valid[cache_ipv4_slot] = true;
 
@@ -491,7 +491,7 @@ subnet_t *lookup_subnet_ipv6(const ipv6_t *address) {
        for(i = 0; i < 2; i++) {
                if(!cache_ipv6_valid[i])
                        continue;
        for(i = 0; i < 2; i++) {
                if(!cache_ipv6_valid[i])
                        continue;
-               if(!memcmp(address, &cache_ipv6_address[i], sizeof *address))
+               if(!memcmp(address, &cache_ipv6_address[i], sizeof(*address)))
                        return cache_ipv6_subnet[i];
        }
 
                        return cache_ipv6_subnet[i];
        }
 
@@ -513,7 +513,7 @@ subnet_t *lookup_subnet_ipv6(const ipv6_t *address) {
        // Cache the result
 
        cache_ipv6_slot = !cache_ipv6_slot;
        // Cache the result
 
        cache_ipv6_slot = !cache_ipv6_slot;
-       memcpy(&cache_ipv6_address[cache_ipv6_slot], address, sizeof *address);
+       memcpy(&cache_ipv6_address[cache_ipv6_slot], address, sizeof(*address));
        cache_ipv6_subnet[cache_ipv6_slot] = r;
        cache_ipv6_valid[cache_ipv6_slot] = true;
 
        cache_ipv6_subnet[cache_ipv6_slot] = r;
        cache_ipv6_valid[cache_ipv6_slot] = true;
 
@@ -550,7 +550,7 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) {
        if(!subnet) {
                for(node = owner->subnet_tree->head; node; node = node->next) {
                        subnet = node->data;
        if(!subnet) {
                for(node = owner->subnet_tree->head; node; node = node->next) {
                        subnet = node->data;
-                       if(!net2str(netstr, sizeof netstr, subnet))
+                       if(!net2str(netstr, sizeof(netstr), subnet))
                                continue;
                        // Strip the weight from the subnet, and put it in its own environment variable
                        char *weight = strchr(netstr, '#');
                                continue;
                        // Strip the weight from the subnet, and put it in its own environment variable
                        char *weight = strchr(netstr, '#');
@@ -570,7 +570,7 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) {
                        execute_script(name, envp);
                }
        } else {
                        execute_script(name, envp);
                }
        } else {
-               if(net2str(netstr, sizeof netstr, subnet)) {
+               if(net2str(netstr, sizeof(netstr), subnet)) {
                        // Strip the weight from the subnet, and put it in its own environment variable
                        char *weight = strchr(netstr, '#');
                        if(weight)
                        // Strip the weight from the subnet, and put it in its own environment variable
                        char *weight = strchr(netstr, '#');
                        if(weight)
@@ -599,7 +599,7 @@ void dump_subnets(void) {
 
        for(node = subnet_tree->head; node; node = node->next) {
                subnet = node->data;
 
        for(node = subnet_tree->head; node; node = node->next) {
                subnet = node->data;
-               if(!net2str(netstr, sizeof netstr, subnet))
+               if(!net2str(netstr, sizeof(netstr), subnet))
                        continue;
                logger(LOG_DEBUG, " %s owner %s", netstr, subnet->owner->name);
        }
                        continue;
                logger(LOG_DEBUG, " %s owner %s", netstr, subnet->owner->name);
        }
index e338850aa6fa08142606d83ffb219d0ccbe5409d..c731e1d3c79fdeda0374c8d36790ca5efdd6f40e 100644 (file)
@@ -418,7 +418,7 @@ static bool keygen(int bits) {
        } else
                fprintf(stderr, "Done.\n");
 
        } else
                fprintf(stderr, "Done.\n");
 
-       snprintf(filename, sizeof filename, "%s/rsa_key.priv", confbase);
+       snprintf(filename, sizeof(filename), "%s/rsa_key.priv", confbase);
        f = ask_and_open(filename, "private RSA key");
 
        if(!f) {
        f = ask_and_open(filename, "private RSA key");
 
        if(!f) {
@@ -438,10 +438,10 @@ static bool keygen(int bits) {
        char *name = get_name();
 
        if(name) {
        char *name = get_name();
 
        if(name) {
-               snprintf(filename, sizeof filename, "%s/hosts/%s", confbase, name);
+               snprintf(filename, sizeof(filename), "%s/hosts/%s", confbase, name);
                free(name);
        } else {
                free(name);
        } else {
-               snprintf(filename, sizeof filename, "%s/rsa_key.pub", confbase);
+               snprintf(filename, sizeof(filename), "%s/rsa_key.pub", confbase);
        }
 
        f = ask_and_open(filename, "public RSA key");
        }
 
        f = ask_and_open(filename, "public RSA key");
index 2db5896c4ec7a4f65ce3fa1a28c5c39aa68f853f..5dcf8aa9c3780c7176306dd89e9d7b4b9d44eb60 100644 (file)
@@ -81,7 +81,7 @@ static bool setup_device(void) {
        fcntl(write_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
        fcntl(write_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
-       setsockopt(write_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one);
+       setsockopt(write_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
 
        if(fcntl(write_fd, F_SETFL, O_NONBLOCK) < 0) {
                logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno));
 
        if(fcntl(write_fd, F_SETFL, O_NONBLOCK) < 0) {
                logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno));
@@ -99,7 +99,7 @@ static bool setup_device(void) {
        fcntl(data_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
        fcntl(data_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
-       setsockopt(data_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one);
+       setsockopt(data_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
 
        if(fcntl(data_fd, F_SETFL, O_NONBLOCK) < 0) {
                logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno));
 
        if(fcntl(data_fd, F_SETFL, O_NONBLOCK) < 0) {
                logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno));
@@ -112,9 +112,9 @@ static bool setup_device(void) {
        gettimeofday(&tv, NULL);
        name.usecs = tv.tv_usec;
        data_sun.sun_family = AF_UNIX;
        gettimeofday(&tv, NULL);
        name.usecs = tv.tv_usec;
        data_sun.sun_family = AF_UNIX;
-       memcpy(&data_sun.sun_path, &name, sizeof name);
+       memcpy(&data_sun.sun_path, &name, sizeof(name));
        
        
-       if(bind(data_fd, (struct sockaddr *)&data_sun, sizeof data_sun) < 0) {
+       if(bind(data_fd, (struct sockaddr *)&data_sun, sizeof(data_sun)) < 0) {
                logger(LOG_ERR, "Could not bind data %s: %s", device_info, strerror(errno));
                running = false;
                return false;
                logger(LOG_ERR, "Could not bind data %s: %s", device_info, strerror(errno));
                running = false;
                return false;
@@ -130,7 +130,7 @@ static bool setup_device(void) {
        fcntl(device_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
        fcntl(device_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
-       setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one);
+       setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
 
        if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) {
                logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno));
 
        if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) {
                logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno));
@@ -138,8 +138,8 @@ static bool setup_device(void) {
        }
 
        listen_sun.sun_family = AF_UNIX;
        }
 
        listen_sun.sun_family = AF_UNIX;
-       strncpy(listen_sun.sun_path, device, sizeof listen_sun.sun_path);
-       if(bind(listen_fd, (struct sockaddr *)&listen_sun, sizeof listen_sun) < 0) {
+       strncpy(listen_sun.sun_path, device, sizeof(listen_sun.sun_path));
+       if(bind(listen_fd, (struct sockaddr *)&listen_sun, sizeof(listen_sun)) < 0) {
                logger(LOG_ERR, "Could not bind %s to %s: %s", device_info, device, strerror(errno));
                return false;
        }
                logger(LOG_ERR, "Could not bind %s to %s: %s", device_info, device, strerror(errno));
                return false;
        }
@@ -185,7 +185,7 @@ static bool read_packet(vpn_packet_t *packet) {
        switch(state) {
                case 0: {
                        struct sockaddr sa;
        switch(state) {
                case 0: {
                        struct sockaddr sa;
-                       socklen_t salen = sizeof sa;
+                       socklen_t salen = sizeof(sa);
 
                        request_fd = accept(listen_fd, &sa, &salen);
                        if(request_fd < 0) {
 
                        request_fd = accept(listen_fd, &sa, &salen);
                        if(request_fd < 0) {
@@ -212,7 +212,7 @@ static bool read_packet(vpn_packet_t *packet) {
                }
 
                case 1: {
                }
 
                case 1: {
-                       if((lenin = read(request_fd, &request, sizeof request)) != sizeof request) {
+                       if((lenin = read(request_fd, &request, sizeof(request))) != sizeof request) {
                                logger(LOG_ERR, "Error while reading request from %s %s: %s", device_info,
                                           device, strerror(errno));
                                running = false;
                                logger(LOG_ERR, "Error while reading request from %s %s: %s", device_info,
                                           device, strerror(errno));
                                running = false;
@@ -226,13 +226,13 @@ static bool read_packet(vpn_packet_t *packet) {
                                return false;
                        }
 
                                return false;
                        }
 
-                       if(connect(write_fd, &request.sock, sizeof request.sock) < 0) {
+                       if(connect(write_fd, &request.sock, sizeof(request.sock)) < 0) {
                                logger(LOG_ERR, "Could not bind write %s: %s", device_info, strerror(errno));
                                running = false;
                                return false;
                        }
 
                                logger(LOG_ERR, "Could not bind write %s: %s", device_info, strerror(errno));
                                running = false;
                                return false;
                        }
 
-                       write(request_fd, &data_sun, sizeof data_sun);
+                       write(request_fd, &data_sun, sizeof(data_sun));
                        device_fd = data_fd;
 
                        logger(LOG_INFO, "Connection with UML established");
                        device_fd = data_fd;
 
                        logger(LOG_INFO, "Connection with UML established");
index 555ea50d7461b38c9a000bfe559e10ed275e0ccf..656f1ea41ac38b46f243a6c67f3658327408b359 100644 (file)
@@ -73,8 +73,8 @@ const char *winerror(int err) {
 
 unsigned int bitfield_to_int(const void *bitfield, size_t size) {
        unsigned int value = 0;
 
 unsigned int bitfield_to_int(const void *bitfield, size_t size) {
        unsigned int value = 0;
-       if(size > sizeof value)
-               size = sizeof value;
+       if(size > sizeof(value))
+               size = sizeof(value);
        memcpy(&value, bitfield, size);
        return value;
 }
        memcpy(&value, bitfield, size);
        return value;
 }
index 468d6bb1bf162e9cd43c0720cf85a26b463eb714..9d3a71e5f5992ef9c6e0fbd6bb620c9edbdd9c2a 100644 (file)
@@ -55,7 +55,7 @@ static inline char *xstrdup(const char *s) {
 static inline int xvasprintf(char **strp, const char *fmt, va_list ap) {
 #ifdef HAVE_MINGW
        char buf[1024];
 static inline int xvasprintf(char **strp, const char *fmt, va_list ap) {
 #ifdef HAVE_MINGW
        char buf[1024];
-       int result = vsnprintf(buf, sizeof buf, fmt, ap);
+       int result = vsnprintf(buf, sizeof(buf), fmt, ap);
        if(result < 0)
                abort();
        *strp = xstrdup(buf);
        if(result < 0)
                abort();
        *strp = xstrdup(buf);