cleanup: Remove NULL check from unconditional guards
PATCH 1/1 cleanup: Remove NULL check from unconditional guards
The unconditional guard destructors check whether the lock pointer is NULL before unlocking. This check is unnecessary because unconditional guards always acquire the lock: the pointer can never be NULL.
Conditional (_try) variants have their own destructors via EXTEND_CLASS_COND() that handle the failure case before reaching the base destructor.
As compiled by GCC-16 with defconfig on top of the locking/core:
Total: Before=23770501, After=23716538, chg -0.23%
Signed-off-by Dmitry Ilvokhin <[email protected]>
--- include/linux/cleanup.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/cleanup.h +2 -2
@@ -397,7 +397,7 @@ static __maybe_unused const bool class_##_name##_is_conditional = _is_cond __DEFINE_GUARD_LOCK_PTR(_name, _T)#define DEFINE_GUARD (_name, _type, _lock, _unlock) \ - DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \ + DEFINE_CLASS(_name, _type, _unlock, ({ _lock; _T; }), _type _T); \ DEFINE_CLASS_IS_GUARD(_name)#define DEFINE_GUARD_COND_4 (_name, _ext, _lock, _cond) \
@@ -491,7 +491,7 @@ typedef struct { \ static __always_inline void class_##_name##_destructor(class_##_name##_t *_T) \ __no_context_analysis \ { \ -if (_T->lock) { _unlock; } \ + _unlock; \ } \ \__DEFINE_GUARD_LOCK_PTR (_name, &_T->lock)
Signature · 1 line
2.52.0