Don't check for NULL-pointers before calling free().
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 23 Sep 2018 13:49:38 +0000 (15:49 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 23 Sep 2018 15:19:59 +0000 (17:19 +0200)
src/conf.c
src/subnet.c
src/tincd.c
src/uml_device.c

index 03887991cdc5bc80908ff124523b3dd3234ba895..58d7b6d30e94b4975aa016ed697bf39340bcdfd7 100644 (file)
@@ -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);
 }
 
index ab181945da15ade67dbf4cc9ae0ba4bfc751e9dc..dc30b01344dd0efce40920fda32ba93eaf099204 100644 (file)
@@ -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);
index 9253d9f28c7c5d96b1302d65ad5cd718ab4cc406..b4704c47a0aadfb760730c24589b4acb2f99fd46 100644 (file)
@@ -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() {
index 49f26ffeb2054b1b9a419c6ee09918bb99c90486..66de431b353764148eee1c72a43222d09bb73b7a 100644 (file)
@@ -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) {