From: Philippe Proulx Date: Thu, 16 Apr 2020 13:53:01 +0000 (-0400) Subject: lib: object.h: convert precondition assertions to internal assertions X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=5d70aba9ff10108133afa62f839b27f87a378772 lib: object.h: convert precondition assertions to internal assertions The `object.h` API is completely internal. We used to have only two public reference counting modification functions (to get and put references), but since c5b9b4417 ("lib: make public reference count functions have strict types"), each shared object type has its own reference counting modification functions. Therefore it's impossible that bt_object_get_ref() or bt_object_put_ref() be called with a unique object without at least getting a compiler warning. Signed-off-by: Philippe Proulx Change-Id: I80286144f3f29af933694d5e824473abd7ec9103 Reviewed-on: https://review.lttng.org/c/babeltrace/+/3430 --- diff --git a/src/lib/object.h b/src/lib/object.h index c0180dce..2fbe7f02 100644 --- a/src/lib/object.h +++ b/src/lib/object.h @@ -317,10 +317,7 @@ void bt_object_get_ref(const void *ptr) return; } -#ifdef BT_ASSERT_PRE_DEV - BT_ASSERT_PRE_DEV(obj->is_shared, "Object is not shared: %!+O", obj); -#endif - + BT_ASSERT_DBG(obj->is_shared); bt_object_get_ref_no_null_check(obj); } @@ -333,12 +330,8 @@ void bt_object_put_ref(const void *ptr) return; } -#ifdef BT_ASSERT_PRE_DEV - BT_ASSERT_PRE_DEV(obj->is_shared, "Object is not shared: %!+O", obj); - BT_ASSERT_PRE_DEV(bt_object_get_ref_count(obj) > 0, - "Decrementing a reference count set to 0: %!+O", ptr); -#endif - + BT_ASSERT_DBG(obj->is_shared); + BT_ASSERT_DBG(bt_object_get_ref_count(obj) > 0); bt_object_put_ref_no_null_check(obj); }