From: Lucas De Marchi Date: Sat, 9 Nov 2024 22:20:18 +0000 (-0600) Subject: shared: Move cleanup attribute X-Git-Tag: v34~117 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f94b5c4c3711a07b83595713614ab64b476292bc;p=thirdparty%2Fkmod.git shared: Move cleanup attribute Move to macro.h where other attributes are located. The inline helper function can also move along as we don't need to keep it separate. Signed-off-by: Lucas De Marchi Link: https://github.com/kmod-project/kmod/pull/233 --- diff --git a/shared/macro.h b/shared/macro.h index 62876b05..28ec61af 100644 --- a/shared/macro.h +++ b/shared/macro.h @@ -43,10 +43,17 @@ #define _must_check_ __attribute__((warn_unused_result)) #define _printf_format_(a, b) __attribute__((format(printf, a, b))) #define _always_inline_ __inline__ __attribute__((always_inline)) -#define _cleanup_(x) __attribute__((cleanup(x))) #define _nonnull_(...) __attribute__((nonnull(__VA_ARGS__))) #define _nonnull_all_ __attribute__((nonnull)) +#define _cleanup_(x) __attribute__((cleanup(x))) + +static inline void freep(void *p) +{ + free(*(void **)p); +} +#define _cleanup_free_ _cleanup_(freep) + /* Define C11 noreturn without and even on older gcc * compiler versions */ #ifndef noreturn diff --git a/shared/util.h b/shared/util.h index a9ce00a3..65d90dba 100644 --- a/shared/util.h +++ b/shared/util.h @@ -87,11 +87,6 @@ static _always_inline_ unsigned int ALIGN_POWER2(unsigned int u) /* misc */ /* ************************************************************************ */ -static inline void freep(void *p) -{ - free(*(void **)p); -} -#define _cleanup_free_ _cleanup_(freep) static inline bool uadd32_overflow(uint32_t a, uint32_t b, uint32_t *res) {