]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared/macro: avoid nesting macros where possible
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 3 Jun 2025 18:00:49 +0000 (19:00 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 11 Jun 2025 12:54:40 +0000 (07:54 -0500)
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 <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
.clang-format
shared/macro.h

index d964045a53a0f1edb5f6c6d6646ea92ed6509ca7..ed2db61cb4f7aa7e7881bebbacfc67d8f95fde93 100644 (file)
@@ -81,9 +81,9 @@ AttributeMacros:
   - KMOD_EXPORT
   - TS_EXPORT
   - _always_inline_
-  - _clang_suppress_
   - _clang_suppress_alloc_
   - _cleanup_
+  - _cleanup_free_
   - _must_check_
   - _nonnull_
   - _nonnull_all_
index 15a95a3b0d8770e0d090fac42258fe6ae7cb0e11..b3e379201dd26c040ecdc64556efcd051bd2b58a 100644 (file)
 #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 <stdnoreturn.h> and even on older gcc
  * compiler versions */