[MERGED] osmo-sgsn[master]: use osmo_init_logging2(), fix regression test memleaks

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Apr 16 15:28:15 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: use osmo_init_logging2(), fix regression test memleaks
......................................................................


use osmo_init_logging2(), fix regression test memleaks

Particularly gbproxy_test.c had various mem leaks, which (will) show up with
gcc (Debian 7.3.0-15) 7.3.0 address sanitizer. Fix those leaks to verify that
we don't have memleaks in the production code.

Change-Id: Ia4204c8b3d895b42c103edecb61b99d3d22bd36f
---
M src/gprs/gb_proxy_main.c
M src/gprs/gtphub_main.c
M src/gprs/sgsn_main.c
M src/libcommon/gsup_test_client.c
M tests/gbproxy/gbproxy_test.c
M tests/gprs/gprs_test.c
M tests/gtphub/gtphub_test.c
M tests/oap/oap_client_test.c
M tests/sgsn/sgsn_test.c
M tests/slhc/slhc_test.c
M tests/sndcp_xid/sndcp_xid_test.c
M tests/v42bis/v42bis_test.c
M tests/xid/xid_test.c
13 files changed, 96 insertions(+), 40 deletions(-)

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



diff --git a/src/gprs/gb_proxy_main.c b/src/gprs/gb_proxy_main.c
index 1416ff5..04143bb 100644
--- a/src/gprs/gb_proxy_main.c
+++ b/src/gprs/gb_proxy_main.c
@@ -275,7 +275,7 @@
 	signal(SIGUSR2, &signal_handler);
 	osmo_init_ignore_signals();
 
-	osmo_init_logging(&gprs_log_info);
+	osmo_init_logging2(tall_bsc_ctx, &gprs_log_info);
 
 	vty_info.copyright = openbsc_copyright;
 	vty_init(&vty_info);
diff --git a/src/gprs/gtphub_main.c b/src/gprs/gtphub_main.c
index 197c5e3..a1a2c1d 100644
--- a/src/gprs/gtphub_main.c
+++ b/src/gprs/gtphub_main.c
@@ -346,7 +346,7 @@
 	signal(SIGUSR2, &signal_handler);
 	osmo_init_ignore_signals();
 
-	osmo_init_logging(&gtphub_log_info);
+	osmo_init_logging2(osmo_gtphub_ctx, &gtphub_log_info);
 
 	vty_info.copyright = gtphub_copyright;
 	vty_init(&vty_info);
diff --git a/src/gprs/sgsn_main.c b/src/gprs/sgsn_main.c
index 0276e34..feffefb 100644
--- a/src/gprs/sgsn_main.c
+++ b/src/gprs/sgsn_main.c
@@ -386,7 +386,7 @@
 	signal(SIGUSR2, &signal_handler);
 
 	osmo_init_ignore_signals();
-	osmo_init_logging(&gprs_log_info);
+	osmo_init_logging2(tall_bsc_ctx, &gprs_log_info);
 	osmo_stats_init(tall_bsc_ctx);
 
 	vty_info.copyright = openbsc_copyright;
diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index cc0f58b..2357ba5 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -272,10 +272,11 @@
 	unsigned long long i;
 	char *server_host = "127.0.0.1";
 	uint16_t server_port = OSMO_GSUP_PORT;
+	void *ctx = talloc_named_const(NULL, 0, "gsup_test_client");
 
-	osmo_init_logging(&gsup_test_client_log_info);
+	osmo_init_logging2(ctx, &gsup_test_client_log_info);
 
-	g_gc = gsup_client_create("GSUPTEST", server_host, server_port,
+	g_gc = gsup_client_create(ctx, "GSUPTEST", server_host, server_port,
 				  gsupc_read_cb, NULL);
 
 
diff --git a/tests/gbproxy/gbproxy_test.c b/tests/gbproxy/gbproxy_test.c
index 8edb171..f9a1c6b 100644
--- a/tests/gbproxy/gbproxy_test.c
+++ b/tests/gbproxy/gbproxy_test.c
@@ -47,7 +47,7 @@
 
 #define MATCH_ANY (-1)
 
-void *tall_bsc_ctx;
+void *tall_bsc_ctx = NULL;
 
 struct gbproxy_config gbcfg = {0};
 
@@ -1329,7 +1329,7 @@
 
 static void test_gbproxy()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[4] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 
@@ -1497,7 +1497,7 @@
 
 static void test_gbproxy_ident_changes()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	uint16_t nsei[2] = {0x1000, 0x2000};
@@ -1629,7 +1629,7 @@
 
 static void test_gbproxy_ra_patching()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	struct  gprs_ra_id rai_bss =
@@ -1657,7 +1657,7 @@
 	gbcfg.nsi = bssgp_nsi;
 	gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
 	gbcfg.core_plmn = (struct osmo_plmn_id){ .mcc = 123, .mnc = 456 };
-	gbcfg.core_apn = talloc_zero_size(NULL, 100);
+	gbcfg.core_apn = talloc_zero_size(tall_bsc_ctx, 100);
 	gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
 	gbcfg.patch_ptmsi = 0;
 
@@ -1960,6 +1960,9 @@
 	OSMO_ASSERT(!expect_msg());
 	received_messages = NULL;
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_PATCHING]);
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
@@ -1968,7 +1971,7 @@
 
 static void test_gbproxy_ptmsi_assignment()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	struct  gprs_ra_id rai_bss =
@@ -1997,7 +2000,7 @@
 	gbcfg.nsi = bssgp_nsi;
 	gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
 	gbcfg.core_plmn = (struct osmo_plmn_id){};
-	gbcfg.core_apn = talloc_zero_size(NULL, 100);
+	gbcfg.core_apn = talloc_zero_size(tall_bsc_ctx, 100);
 	gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
 	gbcfg.patch_ptmsi = 0;
 
@@ -2172,6 +2175,9 @@
 
 	dump_global(stdout, 0);
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
 	nsi = NULL;
@@ -2181,7 +2187,7 @@
 
 static void test_gbproxy_ptmsi_patching()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	struct  gprs_ra_id rai_bss =
@@ -2230,7 +2236,7 @@
 	gbcfg.nsi = bssgp_nsi;
 	gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
 	gbcfg.core_plmn = (struct osmo_plmn_id){ .mcc = 123, .mnc = 456 };
-	gbcfg.core_apn = talloc_zero_size(NULL, 100);
+	gbcfg.core_apn = talloc_zero_size(tall_bsc_ctx, 100);
 	gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
 	gbcfg.patch_ptmsi = 1;
 
@@ -2508,6 +2514,9 @@
 
 	dump_global(stdout, 0);
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
 	nsi = NULL;
@@ -2517,7 +2526,7 @@
 
 static void test_gbproxy_ptmsi_patching_bad_cases()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	struct  gprs_ra_id rai_bss =
@@ -2548,7 +2557,7 @@
 	gbcfg.nsi = bssgp_nsi;
 	gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
 	gbcfg.core_plmn = (struct osmo_plmn_id){ .mcc = 123, .mnc = 456 };
-	gbcfg.core_apn = talloc_zero_size(NULL, 100);
+	gbcfg.core_apn = talloc_zero_size(tall_bsc_ctx, 100);
 	gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
 	gbcfg.patch_ptmsi = 1;
 
@@ -2686,6 +2695,9 @@
 
 	dump_global(stdout, 0);
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
 	nsi = NULL;
@@ -2696,7 +2708,7 @@
 
 static void test_gbproxy_imsi_acquisition()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	struct  gprs_ra_id rai_bss =
@@ -2731,7 +2743,7 @@
 	gbcfg.nsi = bssgp_nsi;
 	gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
 	gbcfg.core_plmn = (struct osmo_plmn_id){ .mcc = 123, .mnc = 456 };
-	gbcfg.core_apn = talloc_zero_size(NULL, 100);
+	gbcfg.core_apn = talloc_zero_size(tall_bsc_ctx, 100);
 	gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
 	gbcfg.patch_ptmsi = 1;
 	gbcfg.acquire_imsi = 1;
@@ -2997,6 +3009,9 @@
 
 	dump_global(stdout, 0);
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
 	nsi = NULL;
@@ -3006,7 +3021,7 @@
 
 static void test_gbproxy_secondary_sgsn()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer[2]= {{0},};
 	struct  gprs_ra_id rai_bss =
@@ -3056,7 +3071,7 @@
 	gbcfg.nsi = bssgp_nsi;
 	gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
 	gbcfg.core_plmn = (struct osmo_plmn_id){ .mcc = 123, .mnc = 456 };
-	gbcfg.core_apn = talloc_zero_size(NULL, 100);
+	gbcfg.core_apn = talloc_zero_size(tall_bsc_ctx, 100);
 	gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
 	gbcfg.patch_ptmsi = 1;
 	gbcfg.acquire_imsi = 1;
@@ -3497,6 +3512,9 @@
 
 	dump_global(stdout, 0);
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbproxy_clear_patch_filter(&gbcfg.matches[GBPROX_MATCH_ROUTING]);
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
@@ -3507,7 +3525,7 @@
 
 static void test_gbproxy_keep_info()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	struct  gprs_ra_id rai_bss =
@@ -4440,6 +4458,9 @@
 
 	dump_global(stdout, 0);
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
 	nsi = NULL;
@@ -4728,6 +4749,8 @@
 	}
 	gbproxy_clear_patch_filter(&cfg.matches[GBPROX_MATCH_PATCHING]);
 	gbprox_reset(&cfg);
+	/* gbprox_reset() frees the rate_ctr, but re-allocates it again. */
+	rate_ctr_group_free(cfg.ctrg);
 
 	cleanup_test();
 }
@@ -4810,7 +4833,7 @@
 
 static void test_gbproxy_stored_messages()
 {
-	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, NULL);
+	struct gprs_ns_inst *nsi = gprs_ns_instantiate(gprs_ns_callback, tall_bsc_ctx);
 	struct sockaddr_in bss_peer[1] = {{0},};
 	struct sockaddr_in sgsn_peer= {0};
 	struct  gprs_ra_id rai_bss =
@@ -4834,7 +4857,7 @@
 	gbcfg.nsi = bssgp_nsi;
 	gbcfg.nsip_sgsn_nsei = SGSN_NSEI;
 	gbcfg.core_plmn = (struct osmo_plmn_id){};
-	gbcfg.core_apn = talloc_zero_size(NULL, 100);
+	gbcfg.core_apn = talloc_zero_size(tall_bsc_ctx, 100);
 	gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar");
 	gbcfg.patch_ptmsi = 0;
 	gbcfg.acquire_imsi = 1;
@@ -4894,6 +4917,9 @@
 
 	dump_global(stdout, 0);
 
+	talloc_free(gbcfg.core_apn);
+	gbcfg.core_apn = NULL;
+
 	gbprox_reset(&gbcfg);
 	gprs_ns_destroy(nsi);
 	nsi = NULL;
@@ -4926,9 +4952,13 @@
 
 int main(int argc, char **argv)
 {
-	msgb_talloc_ctx_init(NULL, 0);
+	talloc_enable_leak_report();
+	tall_bsc_ctx = talloc_named_const(NULL, 0, "gbproxy_test");
+	void *log_ctx = talloc_named_const(tall_bsc_ctx, 0, "log");
 
-	osmo_init_logging(&info);
+	msgb_talloc_ctx_init(tall_bsc_ctx, 0);
+
+	osmo_init_logging2(log_ctx, &info);
 	log_set_use_color(osmo_stderr_target, 0);
 	log_set_print_filename(osmo_stderr_target, 0);
 	osmo_signal_register_handler(SS_L_NS, &test_signal, &gbcfg);
@@ -4937,7 +4967,7 @@
 	log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
 	log_set_all_filter(osmo_stderr_target, 1);
 
-	rate_ctr_init(NULL);
+	rate_ctr_init(tall_bsc_ctx);
 
 	setlinebuf(stdout);
 
@@ -4955,7 +4985,15 @@
 	test_gbproxy_keep_info();
 	test_gbproxy_tlli_expire();
 	test_gbproxy_stored_messages();
+	gbprox_reset(&gbcfg);
+	/* gbprox_reset() frees the rate_ctr, but re-allocates it again. */
+	rate_ctr_group_free(gbcfg.ctrg);
 	printf("===== GbProxy test END\n\n");
 
-	exit(EXIT_SUCCESS);
+	talloc_free(log_ctx);
+	/* expecting root and msgb ctx, empty */
+	OSMO_ASSERT(talloc_total_blocks(tall_bsc_ctx) == 2);
+	talloc_free(tall_bsc_ctx);
+
+	return 0;
 }
diff --git a/tests/gprs/gprs_test.c b/tests/gprs/gprs_test.c
index 2dcbafa..99e3ea5 100644
--- a/tests/gprs/gprs_test.c
+++ b/tests/gprs/gprs_test.c
@@ -130,7 +130,8 @@
 
 int main(int argc, char **argv)
 {
-	osmo_init_logging(&info);
+	void *ctx = talloc_named_const(NULL, 0, "gprs_test");
+	osmo_init_logging2(ctx, &info);
 
 	test_8_4_2();
 	test_gprs_timer_enc_dec();
diff --git a/tests/gtphub/gtphub_test.c b/tests/gtphub/gtphub_test.c
index ac0223b..2e48bb1 100644
--- a/tests/gtphub/gtphub_test.c
+++ b/tests/gtphub/gtphub_test.c
@@ -1762,8 +1762,9 @@
 
 int main(int argc, char **argv)
 {
-	osmo_init_logging(&info);
 	osmo_gtphub_ctx = talloc_named_const(NULL, 0, "osmo_gtphub");
+	void *log_ctx = talloc_named_const(osmo_gtphub_ctx, 0, "log");
+	osmo_init_logging2(log_ctx, &info);
 
 	test_nr_map_basic();
 	test_nr_map_wrap();
@@ -1780,7 +1781,9 @@
 	printf("Done\n");
 
 	talloc_report_full(osmo_gtphub_ctx, stderr);
+	talloc_free(log_ctx);
 	OSMO_ASSERT(talloc_total_blocks(osmo_gtphub_ctx) == 1);
+	talloc_free(osmo_gtphub_ctx);
 	return 0;
 }
 
diff --git a/tests/oap/oap_client_test.c b/tests/oap/oap_client_test.c
index 7adae83..87d2070 100644
--- a/tests/oap/oap_client_test.c
+++ b/tests/oap/oap_client_test.c
@@ -252,8 +252,9 @@
 
 int main(int argc, char **argv)
 {
-	msgb_talloc_ctx_init(NULL, 0);
-	osmo_init_logging(&info);
+	void *ctx = talloc_named_const(NULL, 0, "oap_client_test");
+	msgb_talloc_ctx_init(ctx, 0);
+	osmo_init_logging2(ctx, &info);
 
 	OSMO_ASSERT(osmo_stderr_target);
 	log_set_use_color(osmo_stderr_target, 0);
diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c
index 2fbd6e4..df4df3b 100644
--- a/tests/sgsn/sgsn_test.c
+++ b/tests/sgsn/sgsn_test.c
@@ -2444,8 +2444,8 @@
 	void *osmo_sgsn_ctx;
 	void *msgb_ctx;
 
-	osmo_init_logging(&info);
 	osmo_sgsn_ctx = talloc_named_const(NULL, 0, "osmo_sgsn");
+	osmo_init_logging2(osmo_sgsn_ctx, &info);
 	tall_bsc_ctx = talloc_named_const(osmo_sgsn_ctx, 0, "bsc");
 	msgb_ctx = msgb_talloc_ctx_init(osmo_sgsn_ctx, 0);
 
diff --git a/tests/slhc/slhc_test.c b/tests/slhc/slhc_test.c
index bb0e26c..5c13313 100644
--- a/tests/slhc/slhc_test.c
+++ b/tests/slhc/slhc_test.c
@@ -250,17 +250,20 @@
 int main(int argc, char **argv)
 {
 	void *ctx;
-
-	osmo_init_logging(&info);
+	void *log_ctx;
 
 	ctx = talloc_named_const(NULL, 0, "slhc_ctx");
+	log_ctx = talloc_named_const(ctx, 0, "log");
+	osmo_init_logging2(log_ctx, &info);
 
 	test_slhc(ctx);
 
 	printf("Done\n");
 
 	talloc_report_full(ctx, stderr);
+	talloc_free(log_ctx);
 	OSMO_ASSERT(talloc_total_blocks(ctx) == 1);
+	talloc_free(ctx);
 	return 0;
 }
 
diff --git a/tests/sndcp_xid/sndcp_xid_test.c b/tests/sndcp_xid/sndcp_xid_test.c
index dc6da82..5ed695c 100644
--- a/tests/sndcp_xid/sndcp_xid_test.c
+++ b/tests/sndcp_xid/sndcp_xid_test.c
@@ -261,10 +261,11 @@
 int main(int argc, char **argv)
 {
 	void *xid_ctx;
-
-	osmo_init_logging(&info);
+	void *log_ctx;
 
 	xid_ctx = talloc_named_const(NULL, 0, "xid_ctx");
+	log_ctx = talloc_named_const(xid_ctx, 0, "log");
+	osmo_init_logging2(log_ctx, &info);
 
 	test_xid_decode_realworld(xid_ctx);
 	test_xid_encode_decode(xid_ctx);
@@ -272,7 +273,9 @@
 	printf("Done\n");
 
 	talloc_report_full(xid_ctx, stderr);
+	talloc_free(log_ctx);
 	OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1);
+	talloc_free(xid_ctx);
 	return 0;
 }
 
diff --git a/tests/v42bis/v42bis_test.c b/tests/v42bis/v42bis_test.c
index 41d23b0..e9c5069 100644
--- a/tests/v42bis/v42bis_test.c
+++ b/tests/v42bis/v42bis_test.c
@@ -407,11 +407,12 @@
 int main(int argc, char **argv)
 {
 	void *v42bis_ctx;
+	void *log_ctx;
 	int i;
 
-	osmo_init_logging(&info);
-
 	v42bis_ctx = talloc_named_const(NULL, 0, "v42bis_ctx");
+	log_ctx = talloc_named_const(v42bis_ctx, 0, "log");
+	osmo_init_logging2(log_ctx, &info);
 
 	test_v42bis(v42bis_ctx);
 
@@ -423,7 +424,9 @@
 
 	printf("Done\n");
 	talloc_report_full(v42bis_ctx, stderr);
+	talloc_free(log_ctx);
 	OSMO_ASSERT(talloc_total_blocks(v42bis_ctx) == 1);
+	talloc_free(v42bis_ctx);
 	return 0;
 }
 
diff --git a/tests/xid/xid_test.c b/tests/xid/xid_test.c
index e30a14f..89d82e9 100644
--- a/tests/xid/xid_test.c
+++ b/tests/xid/xid_test.c
@@ -142,17 +142,20 @@
 int main(int argc, char **argv)
 {
 	void *xid_ctx;
-
-	osmo_init_logging(&info);
+	void *log_ctx;
 
 	xid_ctx = talloc_named_const(NULL, 0, "xid_ctx");
+	log_ctx = talloc_named_const(xid_ctx, 0, "log");
+	osmo_init_logging2(log_ctx, &info);
 
 	test_xid_decode(xid_ctx);
 	test_xid_encode(xid_ctx);
 	printf("Done\n");
 
 	talloc_report_full(xid_ctx, stderr);
+	talloc_free(log_ctx);
 	OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1);
+	talloc_free(xid_ctx);
 	return 0;
 }
 

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

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



More information about the gerrit-log mailing list