From: Guus Sliepen Date: Sun, 7 Oct 2018 11:32:25 +0000 (+0200) Subject: Don't check for NULL-pointers before calling free(). X-Git-Tag: release-1.1pre17~4 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=a03991b7911a5f0afbf1269ac47143d09be76c52;p=tinc Don't check for NULL-pointers before calling free(). --- diff --git a/src/bsd/device.c b/src/bsd/device.c index 5a572ba3..0eeee6e9 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -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); } } diff --git a/src/conf.c b/src/conf.c index 0b84ad71..a33bdfea 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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); } diff --git a/src/gcrypt/cipher.c b/src/gcrypt/cipher.c index 176b62b1..3eed8e95 100644 --- a/src/gcrypt/cipher.c +++ b/src/gcrypt/cipher.c @@ -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) { diff --git a/src/node.c b/src/node.c index b5e033c1..8f4b6eee 100644 --- a/src/node.c +++ b/src/node.c @@ -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); diff --git a/src/protocol.c b/src/protocol.c index 1ca24e57..d8b88673 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -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); } diff --git a/src/protocol_auth.c b/src/protocol_auth.c index eb1754c1..3a84c221 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -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); } diff --git a/src/uml_device.c b/src/uml_device.c index be609114..a675b62e 100644 --- a/src/uml_device.c +++ b/src/uml_device.c @@ -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; }