[MERGED] osmo-msc[master]: sms_queue_test: sanitize: clean up talloc contexts when done

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Nov 23 13:23:58 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: sms_queue_test: sanitize: clean up talloc contexts when done
......................................................................


sms_queue_test: sanitize: clean up talloc contexts when done

To avoid sanitizer build failures, ensure that the talloc contexts are empty
when done and free them.

Separate the msgb context from the overall talloc context for clarity: if
nested, the outer one would contain two blocks.

Change the "sms_queue_test" context from 1 byte to 0 in order to get a size of
zero in the end.

Change-Id: If08ba48ab9c28bf3c2db4014837c1304cec04aaf
---
M tests/sms_queue/sms_queue_test.c
1 file changed, 22 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/sms_queue/sms_queue_test.c b/tests/sms_queue/sms_queue_test.c
index 0d073db..0ff636e 100644
--- a/tests/sms_queue/sms_queue_test.c
+++ b/tests/sms_queue/sms_queue_test.c
@@ -197,8 +197,10 @@
 
 int main(int argc, char **argv)
 {
-	talloc_ctx = talloc_named_const(NULL, 1, "sms_queue_test");
-	msgb_talloc_ctx_init(talloc_ctx, 0);
+	void *msgb_ctx;
+
+	talloc_ctx = talloc_named_const(NULL, 0, "sms_queue_test");
+	msgb_ctx = msgb_talloc_ctx_init(NULL, 0);
 	osmo_init_logging(&info);
 
 	OSMO_ASSERT(osmo_stderr_target);
@@ -211,5 +213,23 @@
 	test_next_sms();
 	printf("Done\n");
 
+	if (talloc_total_blocks(msgb_ctx) != 1
+	    || talloc_total_size(msgb_ctx) != 0) {
+		talloc_report_full(msgb_ctx, stderr);
+		fflush(stderr);
+	}
+
+	OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1);
+	OSMO_ASSERT(talloc_total_size(msgb_ctx) == 0);
+	talloc_free(msgb_ctx);
+
+	if (talloc_total_blocks(talloc_ctx) != 1
+	    || talloc_total_size(talloc_ctx) != 0)
+		talloc_report_full(talloc_ctx, stderr);
+
+	OSMO_ASSERT(talloc_total_blocks(talloc_ctx) == 1);
+	OSMO_ASSERT(talloc_total_size(talloc_ctx) == 0);
+	talloc_free(talloc_ctx);
+
 	return 0;
 }

-- 
To view, visit https://gerrit.osmocom.org/4965
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If08ba48ab9c28bf3c2db4014837c1304cec04aaf
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list