From ea01ed41f3212ecbe000422f3c122a01b93fe874 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 17 Dec 2024 14:25:20 +0100 Subject: [PATCH] interface: remove unnecessary NULL checks before free() Calling free(NULL) is always valid Signed-off-by: Felix Fietkau --- interface.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/interface.c b/interface.c index ff4289b..60b1807 100644 --- a/interface.c +++ b/interface.c @@ -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; -- 2.30.2