[MERGED] openbsc[master]: msgb ctx: use new msgb_talloc_ctx_init(), don't access tallo...

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 Oct 13 13:14:41 UTC 2016


Neels Hofmeyr has submitted this change and it was merged.

Change subject: msgb ctx: use new msgb_talloc_ctx_init(), don't access talloc_msgb_ctx
......................................................................


msgb ctx: use new msgb_talloc_ctx_init(), don't access talloc_msgb_ctx

Drop extern definitions of talloc_msgb_ctx and use msgb_talloc_ctx_init()
instead.

In sgsn_test.c, use a local variable msgb_ctx to do the talloc report
from the return value of msgb_talloc_ctx_init().

Change-Id: I2f9ace855f0ecbdc9adf5d75bcb1a3d666570de4
---
M openbsc/src/gprs/gb_proxy_main.c
M openbsc/src/gprs/sgsn_main.c
M openbsc/src/libcommon/talloc_ctx.c
M openbsc/src/osmo-bsc_nat/bsc_nat.c
M openbsc/tests/sgsn/sgsn_test.c
5 files changed, 7 insertions(+), 13 deletions(-)

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



diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c
index 2ddfca7..04875c7 100644
--- a/openbsc/src/gprs/gb_proxy_main.c
+++ b/openbsc/src/gprs/gb_proxy_main.c
@@ -189,8 +189,6 @@
 	}
 }
 
-extern void *tall_msgb_ctx;
-
 extern int bsc_vty_go_parent(struct vty *vty);
 
 static struct vty_app_info vty_info = {
@@ -231,7 +229,7 @@
 	int rc;
 
 	tall_bsc_ctx = talloc_named_const(NULL, 0, "nsip_proxy");
-	tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
+	msgb_talloc_ctx_init(tall_bsc_ctx, 0);
 
 	signal(SIGINT, &signal_handler);
 	signal(SIGABRT, &signal_handler);
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index 822c359..b4be631 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -163,7 +163,6 @@
 
 /* NSI that BSSGP uses when transmitting on NS */
 extern struct gprs_ns_inst *bssgp_nsi;
-extern void *tall_msgb_ctx;
 
 extern int bsc_vty_go_parent(struct vty *vty);
 
@@ -328,7 +327,7 @@
 
 	srand(time(NULL));
 	tall_bsc_ctx = talloc_named_const(NULL, 0, "osmo_sgsn");
-	tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
+	msgb_talloc_ctx_init(tall_bsc_ctx, 0);
 
 	signal(SIGINT, &signal_handler);
 	signal(SIGABRT, &signal_handler);
diff --git a/openbsc/src/libcommon/talloc_ctx.c b/openbsc/src/libcommon/talloc_ctx.c
index a917a8c..7a8bfd3 100644
--- a/openbsc/src/libcommon/talloc_ctx.c
+++ b/openbsc/src/libcommon/talloc_ctx.c
@@ -20,7 +20,6 @@
 #include <osmocom/core/talloc.h>
 
 extern void *tall_bsc_ctx;
-extern void *tall_msgb_ctx;
 extern void *tall_fle_ctx;
 extern void *tall_locop_ctx;
 extern void *tall_authciphop_ctx;
@@ -38,7 +37,7 @@
 
 void talloc_ctx_init(void *ctx_root)
 {
-	tall_msgb_ctx = talloc_named_const(ctx_root, 0, "msgb");
+	msgb_talloc_ctx_init(ctx_root, 0);
 	tall_fle_ctx = talloc_named_const(ctx_root, 0, "bs11_file_list_entry");
 	tall_locop_ctx = talloc_named_const(ctx_root, 0, "loc_updating_oper");
 	tall_authciphop_ctx = talloc_named_const(ctx_root, 0, "auth_ciph_oper");
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 6ae8c05..a4dd679 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1573,12 +1573,11 @@
 	osmo_timer_schedule(&sccp_close, SCCP_CLOSE_TIME, 0);
 }
 
-extern void *tall_msgb_ctx;
 extern void *tall_ctr_ctx;
 static void talloc_init_ctx()
 {
 	tall_bsc_ctx = talloc_named_const(NULL, 0, "nat");
-	tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
+	msgb_talloc_ctx_init(tall_bsc_ctx, 0);
 	tall_ctr_ctx = talloc_named_const(tall_bsc_ctx, 0, "counter");
 }
 
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 5ee5fa4..789817c 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -39,8 +39,6 @@
 
 #include <stdio.h>
 
-extern void *tall_msgb_ctx;
-
 void *tall_bsc_ctx;
 static struct sgsn_instance sgsn_inst = {
 	.config_file = "osmo_sgsn.cfg",
@@ -2423,11 +2421,12 @@
 int main(int argc, char **argv)
 {
 	void *osmo_sgsn_ctx;
+	void *msgb_ctx;
 
 	osmo_init_logging(&info);
 	osmo_sgsn_ctx = talloc_named_const(NULL, 0, "osmo_sgsn");
 	tall_bsc_ctx = talloc_named_const(osmo_sgsn_ctx, 0, "bsc");
-	tall_msgb_ctx = talloc_named_const(osmo_sgsn_ctx, 0, "msgb");
+	msgb_ctx = msgb_talloc_ctx_init(osmo_sgsn_ctx, 0);
 
 	sgsn_rate_ctr_init();
 	sgsn_auth_init();
@@ -2458,7 +2457,7 @@
 	printf("Done\n");
 
 	talloc_report_full(osmo_sgsn_ctx, stderr);
-	OSMO_ASSERT(talloc_total_blocks(tall_msgb_ctx) == 1);
+	OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1);
 	OSMO_ASSERT(talloc_total_blocks(tall_bsc_ctx) == 2);
 	return 0;
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2f9ace855f0ecbdc9adf5d75bcb1a3d666570de4
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
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