summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-01-16 09:49:25 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-01-17 19:38:14 +0700
commit65d74d9864ceee752678ee22fd38d07067746b93 (patch)
treeafb65ecf80c27f2663e0a419b0fdc9f1bf04c7f1
parent030a6154a69be9353e68fc23cb1be2fff7673b70 (diff)
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
-rw-r--r--src/host/trxcon/logging.c5
-rw-r--r--src/host/trxcon/logging.h2
-rw-r--r--src/host/trxcon/trxcon.c21
-rw-r--r--src/host/trxcon/trxcon.h1
4 files changed, 14 insertions, 15 deletions
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 @@ static const struct log_info trx_log_info = {
.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 @@ enum {
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 @@ static struct {
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 @@ static void signal_handler(int signal)
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 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
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 @@ exit:
* 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,