aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2021-04-24 14:49:23 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2021-04-28 16:32:19 +0200
commitef28721c16e67ef7084d3ebb7297b5c9f60e9d70 (patch)
treeb6b0d885a650107ab8a133b56d5b55c52d7988b1
parent7a0bc6f881ab39a5e058ba45444b429b6df5d662 (diff)
gsm_lchan_name_compute with ctx
Use a talloc ctx directly without an intermediate static buffer. A subsequent patch will add a name tweak for VAMOS secondary lchans, so it felt appropriate to first clean this. Change-Id: Idb922605c15242a2cdc7c34668c845a179a15660
-rw-r--r--include/osmocom/bsc/gsm_data.h2
-rw-r--r--src/osmo-bsc/bts_trx.c4
-rw-r--r--src/osmo-bsc/gsm_data.c9
3 files changed, 5 insertions, 10 deletions
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 0bc881bf9..9aecd2c08 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -944,7 +944,7 @@ const char *gsm_lchant_name(enum gsm_chan_t c);
const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
-char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
+char *gsm_lchan_name_compute(void *ctx, const struct gsm_lchan *lchan);
static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
{
diff --git a/src/osmo-bsc/bts_trx.c b/src/osmo-bsc/bts_trx.c
index 6d98929b5..1dfca9565 100644
--- a/src/osmo-bsc/bts_trx.c
+++ b/src/osmo-bsc/bts_trx.c
@@ -105,15 +105,13 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
for (l = 0; l < TS_MAX_LCHAN; l++) {
struct gsm_lchan *lchan;
- char *name;
lchan = &ts->lchan[l];
lchan->ts = ts;
lchan->nr = l;
lchan->type = GSM_LCHAN_NONE;
- name = gsm_lchan_name_compute(lchan);
- lchan->name = talloc_strdup(trx, name);
+ lchan->name = gsm_lchan_name_compute(trx, lchan);
}
}
diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c
index 916ba686c..47aceb0be 100644
--- a/src/osmo-bsc/gsm_data.c
+++ b/src/osmo-bsc/gsm_data.c
@@ -334,14 +334,11 @@ char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts)
return ts2str;
}
-char *gsm_lchan_name_compute(const struct gsm_lchan *lchan)
+char *gsm_lchan_name_compute(void *ctx, const struct gsm_lchan *lchan)
{
struct gsm_bts_trx_ts *ts = lchan->ts;
-
- snprintf(ts2str, sizeof(ts2str), "(bts=%d,trx=%d,ts=%d,ss=%d)",
- ts->trx->bts->nr, ts->trx->nr, ts->nr, lchan->nr);
-
- return ts2str;
+ return talloc_asprintf(ctx, "(bts=%d,trx=%d,ts=%d,ss=%d)",
+ ts->trx->bts->nr, ts->trx->nr, ts->nr, lchan->nr);
}
/* obtain the MO structure for a given object instance */