Change in osmo-bts[master]: ta_control: make 'struct bts_ul_meas' parameters const

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

laforge gerrit-no-reply at lists.osmocom.org
Mon Feb 15 10:58:55 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/22906 )

Change subject: ta_control: make 'struct bts_ul_meas' parameters const
......................................................................

ta_control: make 'struct bts_ul_meas' parameters const

The only reason why it was not 'const' is that in lchan_new_ul_meas()
we may need to overwrite 'ulm->is_sub'.  This can still be done after
memcpy()ing a new set of samples to the destination buffer.

Change-Id: I0cabf75f8e0bf793c01225a4a8433e994c93f562
Related: OS#5024
---
M include/osmo-bts/measurement.h
M src/common/measurement.c
M tests/meas/meas_test.c
3 files changed, 19 insertions(+), 10 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/measurement.h b/include/osmo-bts/measurement.h
index 8e91c33..45f275f 100644
--- a/include/osmo-bts/measurement.h
+++ b/include/osmo-bts/measurement.h
@@ -4,11 +4,15 @@
 #define MEAS_MAX_TIMING_ADVANCE 63
 #define MEAS_MIN_TIMING_ADVANCE 0
 
-int lchan_new_ul_meas(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn);
+int lchan_new_ul_meas(struct gsm_lchan *lchan,
+		      const struct bts_ul_meas *ulm,
+		      uint32_t fn);
 
 int lchan_meas_check_compute(struct gsm_lchan *lchan, uint32_t fn);
 
-int lchan_meas_process_measurement(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn);
+int lchan_meas_process_measurement(struct gsm_lchan *lchan,
+				   const struct bts_ul_meas *ulm,
+				   uint32_t fn);
 
 void lchan_meas_reset(struct gsm_lchan *lchan);
 
diff --git a/src/common/measurement.c b/src/common/measurement.c
index 95d60f6..03afaa3 100644
--- a/src/common/measurement.c
+++ b/src/common/measurement.c
@@ -318,9 +318,12 @@
 
 /* receive a L1 uplink measurement from L1 (this function is only used
  * internally, it is public to call it from unit-tests)  */
-int lchan_new_ul_meas(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn)
+int lchan_new_ul_meas(struct gsm_lchan *lchan,
+		      const struct bts_ul_meas *ulm,
+		      uint32_t fn)
 {
 	uint32_t fn_mod = fn % modulus_by_lchan(lchan);
+	struct bts_ul_meas *dest;
 
 	if (lchan->state != LCHAN_S_ACTIVE) {
 		LOGPFN(DMEAS, LOGL_NOTICE, fn,
@@ -336,19 +339,19 @@
 		return -ENOSPC;
 	}
 
+	dest = &lchan->meas.uplink[lchan->meas.num_ul_meas++];
+	memcpy(dest, ulm, sizeof(*ulm));
+
 	/* We expect the lower layers to mark AMR SID_UPDATE frames already as such.
 	 * In this function, we only deal with the common logic as per the TS 45.008 tables */
 	if (!ulm->is_sub)
-		ulm->is_sub = ts45008_83_is_sub(lchan, fn);
+		dest->is_sub = ts45008_83_is_sub(lchan, fn);
 
 	DEBUGPFN(DMEAS, fn, "%s adding measurement (ber10k=%u, ta_offs=%d, ci=%0.2f, is_sub=%u, rssi=-%u), num_ul_meas=%d, fn_mod=%u\n",
 		 gsm_lchan_name(lchan), ulm->ber10k, ulm->ta_offs_256bits,
-		 ulm->c_i, ulm->is_sub, ulm->inv_rssi, lchan->meas.num_ul_meas,
+		 ulm->c_i, dest->is_sub, ulm->inv_rssi, lchan->meas.num_ul_meas,
 		 fn_mod);
 
-	memcpy(&lchan->meas.uplink[lchan->meas.num_ul_meas++], ulm,
-		sizeof(*ulm));
-
 	lchan->meas.last_fn = fn;
 
 	return 0;
@@ -757,7 +760,9 @@
  * l1sap.c every time a measurement indication is received. It collects the
  * measurement samples and automatically detects the end of the measurement
  * interval. */
-int lchan_meas_process_measurement(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t fn)
+int lchan_meas_process_measurement(struct gsm_lchan *lchan,
+				   const struct bts_ul_meas *ulm,
+				   uint32_t fn)
 {
 	lchan_new_ul_meas(lchan, ulm, fn);
 	return lchan_meas_check_compute(lchan, fn);
diff --git a/tests/meas/meas_test.c b/tests/meas/meas_test.c
index 174abbe..d129336 100644
--- a/tests/meas/meas_test.c
+++ b/tests/meas/meas_test.c
@@ -89,7 +89,7 @@
 
 	/* feed uplink measurements into the code */
 	for (i = 0; i < mtc->ulm_count; i++) {
-		lchan_new_ul_meas(lchan, (struct bts_ul_meas *) &mtc->ulm[i], fn);
+		lchan_new_ul_meas(lchan, &mtc->ulm[i], fn);
 		fn += 1;
 	}
 

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I0cabf75f8e0bf793c01225a4a8433e994c93f562
Gerrit-Change-Number: 22906
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210215/a6505c00/attachment.htm>


More information about the gerrit-log mailing list