interface: remove unnecessary NULL checks before free() master
authorFelix Fietkau <nbd@nbd.name>
Tue, 17 Dec 2024 13:25:20 +0000 (14:25 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 17 Dec 2024 13:25:21 +0000 (14:25 +0100)
Calling free(NULL) is always valid

Signed-off-by: Felix Fietkau <nbd@nbd.name>
interface.c

index ff4289be33ccfb2ff2b841903fb0a3ad06239a4e..60b18070903bda9e052270decc4c3c5bfa4f76ea 100644 (file)
@@ -711,13 +711,9 @@ interface_do_free(struct interface *iface)
        netifd_ubus_remove_interface(iface);
        avl_delete(&interfaces.avl, &iface->node.avl);
        free(iface->zone);
-       if (iface->jail)
-               free(iface->jail);
-       if (iface->jail_device)
-               free(iface->jail_device);
-       if (iface->host_device)
-               free(iface->host_device);
-
+       free(iface->jail);
+       free(iface->jail_device);
+       free(iface->host_device);
        free(iface);
 }
 
@@ -1341,21 +1337,16 @@ interface_change_config(struct interface *if_old, struct interface *if_new)
 
        if_old->device_config = if_new->device_config;
        if_old->config_autostart = if_new->config_autostart;
-       if (if_old->jail)
-               free(if_old->jail);
 
+       free(if_old->jail);
        if_old->jail = if_new->jail;
        if (if_old->jail)
                if_old->autostart = false;
 
-       if (if_old->jail_device)
-               free(if_old->jail_device);
-
+       free(if_old->jail_device);
        if_old->jail_device = if_new->jail_device;
 
-       if (if_old->host_device)
-               free(if_old->host_device);
-
+       free(if_old->host_device);
        if_old->host_device = if_new->host_device;
 
        if_old->device = if_new->device;