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 5a572ba..0eeee6e 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 0b84ad7..a33bdfe 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 176b62b..3eed8e9 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 b5e033c..8f4b6ee 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 1ca24e5..d8b8867 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 eb1754c..3a84c22 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 be60911..a675b62 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;
 }