From: Emil Velikov Date: Tue, 3 Jun 2025 18:00:49 +0000 (+0100) Subject: shared/macro: avoid nesting macros where possible X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20e91b3a6b38812aacb2c3308bde50ab5b103bc6;p=thirdparty%2Fkmod.git shared/macro: avoid nesting macros where possible Always try to use the attribute notation, so that we can reliably collect all the macros in our .clang-format. In the process, we can remove some (no longer used) macros. Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/361 Signed-off-by: Lucas De Marchi --- diff --git a/.clang-format b/.clang-format index d964045a..ed2db61c 100644 --- a/.clang-format +++ b/.clang-format @@ -81,9 +81,9 @@ AttributeMacros: - KMOD_EXPORT - TS_EXPORT - _always_inline_ - - _clang_suppress_ - _clang_suppress_alloc_ - _cleanup_ + - _cleanup_free_ - _must_check_ - _nonnull_ - _nonnull_all_ diff --git a/shared/macro.h b/shared/macro.h index 15a95a3b..b3e37920 100644 --- a/shared/macro.h +++ b/shared/macro.h @@ -48,14 +48,11 @@ #define _used_ __attribute((used)) #define _retain_ __attribute((retain)) #define _section_(a) __attribute((section(a))) -#define _aligned_(a) __attribute((aligned(a))) -#define _alignedptr_ _aligned_(sizeof(void *)) +#define _alignedptr_ __attribute((aligned(sizeof(void *)))) #if defined(__clang_analyzer__) -#define _clang_suppress_ __attribute__((suppress)) #define _clang_suppress_alloc_ __attribute__((suppress)) #else -#define _clang_suppress_ #define _clang_suppress_alloc_ #endif @@ -68,7 +65,7 @@ static inline void freep(void *p) { free(*(void **)p); } -#define _cleanup_free_ _cleanup_(freep) +#define _cleanup_free_ _clang_suppress_alloc_ __attribute__((cleanup(freep))) /* Define C11 noreturn without and even on older gcc * compiler versions */