Don't check for NULL-pointers before calling free().
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 7 Oct 2018 11:32:25 +0000 (13:32 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 7 Oct 2018 11:32:25 +0000 (13:32 +0200)
src/bsd/device.c
src/conf.c
src/gcrypt/cipher.c
src/node.c
src/protocol.c
src/protocol_auth.c
src/uml_device.c

index 5a572ba361d6ecdeab34ceeb682c456cabd9b5d0..0eeee6e93a84cc7907a3c8edd465b1940cc3a3e3 100644 (file)
@@ -298,10 +298,7 @@ static bool setup_device(void) {
                        struct ifreq ifr;
 
                        if(ioctl(device_fd, TAPGIFNAME, (void *)&ifr) == 0) {
-                               if(iface) {
-                                       free(iface);
-                               }
-
+                               free(iface);
                                iface = xstrdup(ifr.ifr_name);
                        }
                }
index 0b84ad71ee4a84aece0d2563c055a8ec74c7967a..a33bdfea3b0b0624ef5681e79924582e20568b2b 100644 (file)
@@ -80,18 +80,9 @@ config_t *new_config(void) {
 }
 
 void free_config(config_t *cfg) {
-       if(cfg->variable) {
-               free(cfg->variable);
-       }
-
-       if(cfg->value) {
-               free(cfg->value);
-       }
-
-       if(cfg->file) {
-               free(cfg->file);
-       }
-
+       free(cfg->variable);
+       free(cfg->value);
+       free(cfg->file);
        free(cfg);
 }
 
index 176b62b19e95ef258f26c704c2d291312527485f..3eed8e9570d2755ef166d05d48714fd18cc7bfed 100644 (file)
@@ -146,10 +146,8 @@ void cipher_close(cipher_t *cipher) {
                cipher->handle = NULL;
        }
 
-       if(cipher->key) {
-               free(cipher->key);
-               cipher->key = NULL;
-       }
+       free(cipher->key);
+       cipher->key = NULL;
 }
 
 size_t cipher_keylength(const cipher_t *cipher) {
index b5e033c11a2fcd84d798fb1b005b0a4eb90a3306..8f4b6eeeb018b3c1c718b9c3fc66dd22d00f4cc9 100644 (file)
@@ -108,17 +108,9 @@ void free_node(node_t *n) {
 
        timeout_del(&n->udp_ping_timeout);
 
-       if(n->hostname) {
-               free(n->hostname);
-       }
-
-       if(n->name) {
-               free(n->name);
-       }
-
-       if(n->late) {
-               free(n->late);
-       }
+       free(n->hostname);
+       free(n->name);
+       free(n->late);
 
        if(n->address_cache) {
                close_address_cache(n->address_cache);
index 1ca24e571d0acd892792baeb33db8bdaf6014f40..d8b8867376d13c91c933c814091b036e89aec927 100644 (file)
@@ -165,10 +165,7 @@ static int past_request_compare(const past_request_t *a, const past_request_t *b
 }
 
 static void free_past_request(past_request_t *r) {
-       if(r->request) {
-               free((char *)r->request);
-       }
-
+       free((char *)r->request);
        free(r);
 }
 
index eb1754c1cf83e5c4066633836350e9535713699e..3a84c22105d60a4fdce25fd3c8552f90324a06f2 100644 (file)
@@ -407,10 +407,7 @@ bool id_h(connection_t *c, const char *request) {
                        return false;
                }
        } else {
-               if(c->name) {
-                       free(c->name);
-               }
-
+               free(c->name);
                c->name = xstrdup(name);
        }
 
index be609114bdd0fe4bdcfd9c01d1dd0f6a6df0c5b5..a675b62e045ab8b2c285d2c028c8f0441892c432 100644 (file)
@@ -183,10 +183,8 @@ void close_device(void) {
        free(device);
        device = NULL;
 
-       if(iface) {
-               free(iface);
-               iface = NULL;
-       }
+       free(iface);
+       iface = NULL;
 
        device_info = NULL;
 }