Skip to content

Commit 9b1c066

Browse files
committed
core-macros: fix defer unused variable for Clang 14 with Ubuntu 22.04.
Seen with Ubuntu 22.04 and Clang 14.0.0-1ubuntu1.1, it produces a warning about the unused variable produced by the defer macro: ``` | tests/zchk.c:1101:13: error: unused variable '__defer__1103' [-Werror,-Wunused-variable,Unused Entity Issue] | defer({ | ^ | ./lib-common/core/macros.h:875:29: note: expanded from macro 'defer' | _defer_with_name(_code, PFX_LINE(__defer__)) | ^ | ./lib-common/core/macros.h:668:24: note: expanded from macro 'PFX_LINE' | #define PFX_LINE(pfx) _PFX_LINE_SFX(pfx, __LINE__, ) | ^ | ./lib-common/core/macros.h:665:41: note: expanded from macro '_PFX_LINE_SFX' | #define _PFX_LINE_SFX(pfx, line, sfx) __PFX_LINE_SFX(pfx, line, sfx) | ^ | ./lib-common/core/macros.h:664:41: note: expanded from macro '__PFX_LINE_SFX' | #define __PFX_LINE_SFX(pfx, line, sfx) pfx##line##sfx | ^ | <scratch space>:166:1: note: expanded from here | __defer__1103 ``` Add `__attr_unused__` to avoid this warning. Also add it for GCC to avoid any further compat issues. It is just ignored for newer compilers anyway. Change-Id: Ibf310812172d833d20190577793fe7df06f962bf Priv-Id: fdcb58e1e7f2d63d2c80467fb3d2b18808400a57
1 parent c76d1cf commit 9b1c066

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/core/macros.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ static ALWAYS_INLINE void _defer_blk_cleanup(_defer_inner_b *defer_blk)
868868
}
869869

870870
#define _defer_with_name(_code, _dname) \
871-
__attr_cleanup__(_defer_blk_cleanup) \
871+
__attr_cleanup__(_defer_blk_cleanup) __attr_unused__ \
872872
void (^_dname)(void) = ^(void) { _code } \
873873

874874
#define defer(_code) \
@@ -881,9 +881,9 @@ static ALWAYS_INLINE void _defer_blk_cleanup(_defer_inner_b *defer_blk)
881881
#define __deferred
882882

883883
#define _defer_with_name(_code, _dname_func, _dname_var) \
884-
auto ALWAYS_INLINE void _dname_func(int *); \
885-
__attr_cleanup__(_dname_func) int _dname_var; \
886-
ALWAYS_INLINE void _dname_func(int *__defer_var) \
884+
auto ALWAYS_INLINE __attr_unused__ void _dname_func(int *); \
885+
__attr_cleanup__(_dname_func) __attr_unused__ int _dname_var; \
886+
ALWAYS_INLINE __attr_unused__ void _dname_func(int *__defer_var) \
887887
{ \
888888
(void)__defer_var; \
889889
{ _code } \

0 commit comments

Comments
 (0)