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://git.librecmc.org/?a=commitdiff_plain;h=a03991b7911a5f0afbf1269ac47143d09be76c52;p=oweals%2Ftinc.git Don't check for NULL-pointers before calling free(). --- diff --git a/src/bsd/device.c b/src/bsd/device.c index 5a572ba..0eeee6e 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 0b84ad7..a33bdfe 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 176b62b..3eed8e9 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 b5e033c..8f4b6ee 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 1ca24e5..d8b8867 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 eb1754c..3a84c22 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 be60911..a675b62 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; }