From 6145bb4f78ce1f7259c746dab8b1fedb38352341 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 21 Mar 2019 13:49:42 +0100 Subject: nspawn: port to static destructors --- src/nspawn/nspawn.c | 65 +++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 95a7d2a5f7..c8a7226de0 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -121,7 +121,7 @@ typedef enum ContainerStatus { CONTAINER_TERMINATED, - CONTAINER_REBOOTED + CONTAINER_REBOOTED, } ContainerStatus; static char *arg_directory = NULL; @@ -229,6 +229,38 @@ static size_t arg_n_extra_nodes = 0; static char **arg_sysctl = NULL; static ConsoleMode arg_console_mode = _CONSOLE_MODE_INVALID; +STATIC_DESTRUCTOR_REGISTER(arg_directory, freep); +STATIC_DESTRUCTOR_REGISTER(arg_template, freep); +STATIC_DESTRUCTOR_REGISTER(arg_chdir, freep); +STATIC_DESTRUCTOR_REGISTER(arg_pivot_root_new, freep); +STATIC_DESTRUCTOR_REGISTER(arg_pivot_root_old, freep); +STATIC_DESTRUCTOR_REGISTER(arg_user, freep); +STATIC_DESTRUCTOR_REGISTER(arg_supplementary_gids, freep); +STATIC_DESTRUCTOR_REGISTER(arg_machine, freep); +STATIC_DESTRUCTOR_REGISTER(arg_hostname, freep); +STATIC_DESTRUCTOR_REGISTER(arg_slice, freep); +STATIC_DESTRUCTOR_REGISTER(arg_setenv, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_network_interfaces, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_network_macvlan, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_network_ipvlan, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_network_veth_extra, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_network_bridge, freep); +STATIC_DESTRUCTOR_REGISTER(arg_network_zone, freep); +STATIC_DESTRUCTOR_REGISTER(arg_network_namespace_path, freep); +STATIC_DESTRUCTOR_REGISTER(arg_image, freep); +STATIC_DESTRUCTOR_REGISTER(arg_oci_bundle, freep); +STATIC_DESTRUCTOR_REGISTER(arg_property, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_property_message, sd_bus_message_unrefp); +STATIC_DESTRUCTOR_REGISTER(arg_parameters, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_root_hash, freep); +STATIC_DESTRUCTOR_REGISTER(arg_syscall_whitelist, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_syscall_blacklist, strv_freep); +#if HAVE_SECCOMP +STATIC_DESTRUCTOR_REGISTER(arg_seccomp, seccomp_releasep); +#endif +STATIC_DESTRUCTOR_REGISTER(arg_cpuset, CPU_FREEp); +STATIC_DESTRUCTOR_REGISTER(arg_sysctl, strv_freep); + static int help(void) { _cleanup_free_ char *link = NULL; int r; @@ -5027,41 +5059,10 @@ finish: (void) remove_veth_links(veth_name, arg_network_veth_extra); (void) remove_bridge(arg_network_zone); - free(arg_directory); - free(arg_template); - free(arg_image); - free(arg_machine); - free(arg_hostname); - free(arg_user); - free(arg_supplementary_gids); - free(arg_pivot_root_new); - free(arg_pivot_root_old); - free(arg_chdir); - strv_free(arg_setenv); - free(arg_network_bridge); - strv_free(arg_network_interfaces); - strv_free(arg_network_macvlan); - strv_free(arg_network_ipvlan); - strv_free(arg_network_veth_extra); - strv_free(arg_parameters); - free(arg_network_zone); - free(arg_network_namespace_path); - strv_free(arg_property); - sd_bus_message_unref(arg_property_message); custom_mount_free_all(arg_custom_mounts, arg_n_custom_mounts); expose_port_free_all(arg_expose_ports); - free(arg_root_hash); rlimit_free_all(arg_rlimit); - strv_free(arg_syscall_whitelist); - strv_free(arg_syscall_blacklist); -#if HAVE_SECCOMP - seccomp_release(arg_seccomp); -#endif - arg_cpuset = cpu_set_mfree(arg_cpuset); - free(arg_oci_bundle); device_node_free_many(arg_extra_nodes, arg_n_extra_nodes); - strv_free(arg_sysctl); - free(arg_slice); if (r < 0) return r; -- cgit v1.2.1