[rtems commit] libtest: Use dependency injection

Sebastian Huber sebh at rtems.org
Wed Jan 27 18:11:28 UTC 2021


Module:    rtems
Branch:    master
Commit:    426b6cdba9f0584addcf032c4294815b9d737737
Changeset: http://git.rtems.org/rtems/commit/?id=426b6cdba9f0584addcf032c4294815b9d737737

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jan 27 16:41:00 2021 +0100

libtest: Use dependency injection

This helps static analyzers.

---

 cpukit/libtest/t-test.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index 2652172..0f19f22 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -1002,6 +1002,8 @@ T_check_steps(unsigned int planned_steps, unsigned int steps,
 	}
 }
 
+static void T_do_pop_fixture(T_context *);
+
 static void
 T_do_case_end(T_context *ctx, const T_case_context *tc)
 {
@@ -1013,7 +1015,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc)
 	T_time_string ts;
 
 	while (ctx->fixtures != NULL) {
-		T_pop_fixture();
+		T_do_pop_fixture(ctx);
 	}
 
 	T_call_destructors(ctx);
@@ -1237,15 +1239,13 @@ T_push_fixture(T_fixture_node *node, const T_fixture *fixture)
 	return context;
 }
 
-void
-T_pop_fixture(void)
+static void
+T_do_pop_fixture(T_context *ctx)
 {
-	T_context *ctx;
 	T_fixture_node *node;
 	const T_fixture *fixture;
 	T_fixture_node *next;
 
-	ctx = &T_instance;
 	node = ctx->fixtures;
 	next = node->next;
 	ctx->fixtures = next;
@@ -1274,6 +1274,12 @@ T_pop_fixture(void)
 	memset(node, 0, sizeof(*node));
 }
 
+void
+T_pop_fixture(void)
+{
+	T_do_pop_fixture(&T_instance);
+}
+
 size_t
 T_get_scope(const char * const * const *desc, char *buf, size_t n,
     const size_t *second_indices)



More information about the vc mailing list