From: Christian Brauner Date: Fri, 29 Jan 2021 23:55:19 +0000 (+0100) Subject: croups: improve __do_bpf_program_free X-Git-Tag: lxc-5.0.0~312^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7af21d2962a7aab8b4b62fec6a1beae878a39b03;p=thirdparty%2Flxc.git croups: improve __do_bpf_program_free Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgroup2_devices.h b/src/lxc/cgroups/cgroup2_devices.h index 04f493e02..2da101ab4 100644 --- a/src/lxc/cgroups/cgroup2_devices.h +++ b/src/lxc/cgroups/cgroup2_devices.h @@ -19,6 +19,7 @@ #include "compiler.h" #include "conf.h" #include "config.h" +#include "memory_utils.h" #include "syscall_numbers.h" #ifdef HAVE_STRUCT_BPF_CGROUP_DEV_CTX @@ -65,14 +66,6 @@ __hidden extern void bpf_program_free(struct bpf_program *prog); __hidden extern void bpf_device_program_free(struct cgroup_ops *ops); __hidden extern bool bpf_devices_cgroup_supported(void); -static inline void __auto_bpf_program_free__(struct bpf_program **prog) -{ - if (*prog) { - bpf_program_free(*prog); - *prog = NULL; - } -} - __hidden extern int bpf_list_add_device(struct lxc_conf *conf, struct device_item *device); #else /* !HAVE_STRUCT_BPF_CGROUP_DEV_CTX */ @@ -129,10 +122,6 @@ static inline bool bpf_devices_cgroup_supported(void) return false; } -static inline void __auto_bpf_program_free__(struct bpf_program **prog) -{ -} - static inline int bpf_list_add_device(struct lxc_conf *conf, struct device_item *device) { @@ -141,7 +130,7 @@ static inline int bpf_list_add_device(struct lxc_conf *conf, } #endif /* !HAVE_STRUCT_BPF_CGROUP_DEV_CTX */ -#define __do_bpf_program_free \ - __attribute__((__cleanup__(__auto_bpf_program_free__))) +define_cleanup_function(struct bpf_program *, bpf_program_free); +#define __do_bpf_program_free call_cleaner(bpf_program_free) #endif /* __LXC_CGROUP2_DEVICES_H */