Change in osmo-bsc[master]: gsm_lchan_name_compute with ctx

neels gerrit-no-reply at lists.osmocom.org
Wed Apr 28 14:40:02 UTC 2021


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/23938 )


Change subject: gsm_lchan_name_compute with ctx
......................................................................

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
---
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/bts_trx.c
M src/osmo-bsc/gsm_data.c
3 files changed, 5 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/38/23938/1

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 0bc881b..9aecd2c 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -944,7 +944,7 @@
 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 6d98929..1dfca95 100644
--- a/src/osmo-bsc/bts_trx.c
+++ b/src/osmo-bsc/bts_trx.c
@@ -105,15 +105,13 @@
 
 		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 916ba68..47aceb0 100644
--- a/src/osmo-bsc/gsm_data.c
+++ b/src/osmo-bsc/gsm_data.c
@@ -334,14 +334,11 @@
 	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 */

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/23938
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Idb922605c15242a2cdc7c34668c845a179a15660
Gerrit-Change-Number: 23938
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210428/c004e1f0/attachment.htm>


More information about the gerrit-log mailing list