Change in osmocom-bb[master]: trxcon/trxcon.c: do not expose tall_trx_ctx

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

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Thu Jan 17 12:48:47 UTC 2019


Vadim Yanitskiy has submitted this change and it was merged. ( https://gerrit.osmocom.org/12584 )

Change subject: trxcon/trxcon.c: do not expose tall_trx_ctx
......................................................................

trxcon/trxcon.c: do not expose tall_trx_ctx

Both l1ctl_link_init() and trx_if_open() do accept 'tall_ctx' now,
so there is no need to expose the root context anymore. For
logging initialization, we can just pass a pointer.

Change-Id: I7a2231eb880a995d3296b94481a7799e6ff07489
---
M src/host/trxcon/logging.c
M src/host/trxcon/logging.h
M src/host/trxcon/trxcon.c
M src/host/trxcon/trxcon.h
4 files changed, 14 insertions(+), 15 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, approved



diff --git a/src/host/trxcon/logging.c b/src/host/trxcon/logging.c
index 6a3043b..78915f2 100644
--- a/src/host/trxcon/logging.c
+++ b/src/host/trxcon/logging.c
@@ -26,7 +26,6 @@
 #include <osmocom/core/utils.h>
 
 #include "logging.h"
-#include "trxcon.h"
 
 static struct log_info_cat trx_log_info_cat[] = {
 	[DAPP] = {
@@ -78,9 +77,9 @@
 	.num_cat = ARRAY_SIZE(trx_log_info_cat),
 };
 
-int trx_log_init(const char *category_mask)
+int trx_log_init(void *tall_ctx, const char *category_mask)
 {
-	osmo_init_logging2(tall_trx_ctx, &trx_log_info);
+	osmo_init_logging2(tall_ctx, &trx_log_info);
 
 	if (category_mask)
 		log_parse_category_mask(osmo_stderr_target, category_mask);
diff --git a/src/host/trxcon/logging.h b/src/host/trxcon/logging.h
index 0206362..152c346 100644
--- a/src/host/trxcon/logging.h
+++ b/src/host/trxcon/logging.h
@@ -14,4 +14,4 @@
 	DSCHD,
 };
 
-int trx_log_init(const char *category_mask);
+int trx_log_init(void *tall_ctx, const char *category_mask);
diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c
index 777138f..8e371df 100644
--- a/src/host/trxcon/trxcon.c
+++ b/src/host/trxcon/trxcon.c
@@ -74,7 +74,7 @@
 	uint32_t trx_fn_advance;
 } app_data;
 
-void *tall_trx_ctx = NULL;
+static void *tall_trxcon_ctx = NULL;
 struct osmo_fsm_inst *trxcon_fsm;
 
 static void trxcon_fsm_idle_action(struct osmo_fsm_inst *fi,
@@ -242,7 +242,7 @@
 	case SIGABRT:
 	case SIGUSR1:
 	case SIGUSR2:
-		talloc_report_full(tall_trx_ctx, stderr);
+		talloc_report_full(tall_trxcon_ctx, stderr);
 		break;
 	default:
 		break;
@@ -261,8 +261,8 @@
 	talloc_enable_null_tracking();
 
 	/* Init talloc memory management system */
-	tall_trx_ctx = talloc_init("trxcon context");
-	msgb_talloc_ctx_init(tall_trx_ctx, 0);
+	tall_trxcon_ctx = talloc_init("trxcon context");
+	msgb_talloc_ctx_init(tall_trxcon_ctx, 0);
 
 	/* Setup signal handlers */
 	signal(SIGINT, &signal_handler);
@@ -271,20 +271,21 @@
 	osmo_init_ignore_signals();
 
 	/* Init logging system */
-	trx_log_init(app_data.debug_mask);
+	trx_log_init(tall_trxcon_ctx, app_data.debug_mask);
 
 	/* Allocate the application state machine */
 	osmo_fsm_register(&trxcon_fsm_def);
-	trxcon_fsm = osmo_fsm_inst_alloc(&trxcon_fsm_def, tall_trx_ctx,
+	trxcon_fsm = osmo_fsm_inst_alloc(&trxcon_fsm_def, tall_trxcon_ctx,
 		NULL, LOGL_DEBUG, "main");
 
 	/* Init L1CTL server */
-	app_data.l1l = l1ctl_link_init(tall_trx_ctx, app_data.bind_socket);
+	app_data.l1l = l1ctl_link_init(tall_trxcon_ctx,
+		app_data.bind_socket);
 	if (app_data.l1l == NULL)
 		goto exit;
 
 	/* Init transceiver interface */
-	app_data.trx = trx_if_open(tall_trx_ctx,
+	app_data.trx = trx_if_open(tall_trxcon_ctx,
 		app_data.trx_bind_ip, app_data.trx_remote_ip,
 		app_data.trx_base_port);
 	if (!app_data.trx)
@@ -331,8 +332,8 @@
 	 * Print report for the root talloc context in order
 	 * to be able to find and fix potential memory leaks.
 	 */
-	talloc_report_full(tall_trx_ctx, stderr);
-	talloc_free(tall_trx_ctx);
+	talloc_report_full(tall_trxcon_ctx, stderr);
+	talloc_free(tall_trxcon_ctx);
 
 	/* Make both Valgrind and ASAN happy */
 	talloc_report_full(NULL, stderr);
diff --git a/src/host/trxcon/trxcon.h b/src/host/trxcon/trxcon.h
index 65b5e85..f66a628 100644
--- a/src/host/trxcon/trxcon.h
+++ b/src/host/trxcon/trxcon.h
@@ -3,7 +3,6 @@
 #define GEN_MASK(state) (0x01 << state)
 
 extern struct osmo_fsm_inst *trxcon_fsm;
-extern void *tall_trx_ctx;
 
 enum trxcon_fsm_states {
 	TRXCON_STATE_IDLE = 0,

-- 
To view, visit https://gerrit.osmocom.org/12584
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7a2231eb880a995d3296b94481a7799e6ff07489
Gerrit-Change-Number: 12584
Gerrit-PatchSet: 3
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-CC: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190117/86086891/attachment.htm>


More information about the gerrit-log mailing list