From: Guus Sliepen Date: Sun, 23 Sep 2018 13:49:38 +0000 (+0200) Subject: Don't check for NULL-pointers before calling free(). X-Git-Tag: release-1.0.35~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=26203e250433b846118be1b2e236bf2541aa260d;p=oweals%2Ftinc.git Don't check for NULL-pointers before calling free(). --- diff --git a/src/conf.c b/src/conf.c index 0388799..58d7b6d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -81,18 +81,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/subnet.c b/src/subnet.c index ab18194..dc30b01 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -627,13 +627,8 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { } // Prepare the SUBNET and WEIGHT variables - if(envp[5]) { - free(envp[5]); - } - - if(envp[6]) { - free(envp[6]); - } + free(envp[5]); + free(envp[6]); xasprintf(&envp[5], "SUBNET=%s", netstr); xasprintf(&envp[6], "WEIGHT=%s", weight); diff --git a/src/tincd.c b/src/tincd.c index 9253d9f..b4704c4 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -562,25 +562,11 @@ static void make_names(void) { } static void free_names() { - if(identname) { - free(identname); - } - - if(netname) { - free(netname); - } - - if(pidfilename) { - free(pidfilename); - } - - if(logfilename) { - free(logfilename); - } - - if(confbase) { - free(confbase); - } + free(identname); + free(netname); + free(pidfilename); + free(logfilename); + free(confbase); } static bool drop_privs() { diff --git a/src/uml_device.c b/src/uml_device.c index 49f26ff..66de431 100644 --- a/src/uml_device.c +++ b/src/uml_device.c @@ -181,10 +181,7 @@ void close_device(void) { unlink(device); free(device); - - if(iface) { - free(iface); - } + free(iface); } static bool read_packet(vpn_packet_t *packet) {