From 2823568a30a76a0d0d5ddcb84c261998c13ece63 Mon Sep 17 00:00:00 2001 From: Zhenlin Wang Date: Wed, 17 Sep 2025 15:46:34 +0800 Subject: [PATCH] refactor guards: remove return function Signed-off-by: Zhenlin Wang --- examples/guards/cleanup.c | 2 +- include/bfdev/guards.h | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/guards/cleanup.c b/examples/guards/cleanup.c index 7a433448..14cfaee8 100644 --- a/examples/guards/cleanup.c +++ b/examples/guards/cleanup.c @@ -27,7 +27,7 @@ test_clean_keep(void) { BFDEV_CLEAN(malloc) void *block; block = malloc(8); - bfdev_return(block); + return bfdev_taken(block); } int diff --git a/include/bfdev/guards.h b/include/bfdev/guards.h index 8433aff1..2d7b402f 100644 --- a/include/bfdev/guards.h +++ b/include/bfdev/guards.h @@ -54,14 +54,12 @@ __bfdev_class_##name##_destructor(type *p) \ __bfdev_cleanup(__bfdev_class_##name##_destructor) = \ __bfdev_class_##name##_constructor -#define bfdev_lasting(object) ({ \ +#define bfdev_taken(object) ({ \ __auto_type __ptr = (object); \ - (object) = BFDEV_NULL; __ptr; \ + (object) = BFDEV_NULL; \ + __ptr; \ }) -#define bfdev_return(object) \ - return bfdev_lasting(object) - BFDEV_END_DECLS #endif /* _BFDEV_GUARDS_H_ */