From 727170fcc3f4002562f42deeac27c985fa69f57f Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 4 Oct 2019 06:54:29 -0400 Subject: [PATCH] trace{-class}.c: BT_ASSERT_PRE() -> BT_ASSERT_POST() (ref. count check) Those are postcondition assertions because they check some state after a user function returns. Signed-off-by: Philippe Proulx Change-Id: I3705ee451ff8ae024a2eb17fbe6ae9cc2b11d05e Reviewed-on: https://review.lttng.org/c/babeltrace/+/2127 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- src/lib/trace-ir/trace-class.c | 3 ++- src/lib/trace-ir/trace.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/trace-ir/trace-class.c b/src/lib/trace-ir/trace-class.c index fb9f8a5a..f9b8adea 100644 --- a/src/lib/trace-ir/trace-class.c +++ b/src/lib/trace-ir/trace-class.c @@ -25,6 +25,7 @@ #include "lib/logging.h" #include "lib/assert-pre.h" +#include "lib/assert-post.h" #include #include #include @@ -106,7 +107,7 @@ void destroy_trace_class(struct bt_object *obj) * The destruction listener should not have kept a * reference to the trace class. */ - BT_ASSERT_PRE(tc->base.ref_count == 1, "Destruction listener kept a reference to the trace class being destroyed: %![tc-]+T", tc); + BT_ASSERT_POST(tc->base.ref_count == 1, "Destruction listener kept a reference to the trace class being destroyed: %![tc-]+T", tc); } g_array_free(tc->destruction_listeners, TRUE); tc->destruction_listeners = NULL; diff --git a/src/lib/trace-ir/trace.c b/src/lib/trace-ir/trace.c index 72493a48..184fc070 100644 --- a/src/lib/trace-ir/trace.c +++ b/src/lib/trace-ir/trace.c @@ -25,6 +25,7 @@ #include "lib/logging.h" #include "lib/assert-pre.h" +#include "lib/assert-post.h" #include #include #include @@ -108,7 +109,7 @@ void destroy_trace(struct bt_object *obj) * The destruction listener should not have kept a * reference to the trace. */ - BT_ASSERT_PRE(trace->base.ref_count == 1, "Destruction listener kept a reference to the trace being destroyed: %![trace-]+t", trace); + BT_ASSERT_POST(trace->base.ref_count == 1, "Destruction listener kept a reference to the trace being destroyed: %![trace-]+t", trace); } g_array_free(trace->destruction_listeners, TRUE); trace->destruction_listeners = NULL; -- 2.34.1