mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-14 22:43:44 +08:00
shared: Ignore clang-analyzer on cleanup attribute
When using the cleanup attribute we know we are not leaking that allocation. Most of the time the assignment is together with the declaration, so we can simplify additional clang annotations by making the cleanup attribute imply clang::suppress. In cases declaration and assignment are not together, provide _clang_suppress_alloc_ to annotate the code. That is only defined for clang analyzer. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com> Link: https://github.com/kmod-project/kmod/pull/233
This commit is contained in:
parent
4063401a05
commit
317f89a59a
@ -43,10 +43,19 @@
|
||||
#define _must_check_ __attribute__((warn_unused_result))
|
||||
#define _printf_format_(a, b) __attribute__((format(printf, a, b)))
|
||||
#define _always_inline_ __inline__ __attribute__((always_inline))
|
||||
|
||||
#if defined(__clang_analyzer__)
|
||||
#define _clang_suppress_ __attribute__((suppress))
|
||||
#define _clang_suppress_alloc_ __attribute__((suppress))
|
||||
#else
|
||||
#define _clang_suppress_
|
||||
#define _clang_suppress_alloc_
|
||||
#endif
|
||||
|
||||
#define _nonnull_(...) __attribute__((nonnull(__VA_ARGS__)))
|
||||
#define _nonnull_all_ __attribute__((nonnull))
|
||||
|
||||
#define _cleanup_(x) __attribute__((cleanup(x)))
|
||||
#define _cleanup_(x) _clang_suppress_alloc_ __attribute__((cleanup(x)))
|
||||
|
||||
static inline void freep(void *p)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user