diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-02-15 01:27:37 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2021-02-15 10:58:54 +0000 |
commit | d37041b1ea3cf382b6168daf7d8dbd5d7ad7615e (patch) | |
tree | bbc8f392cc7010816ca319be8d33e276de616b9d /src/common/measurement.c | |
parent | 7d29ff9345e2bae58fe99d7442848253e6312de7 (diff) |
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
Diffstat (limited to 'src/common/measurement.c')
-rw-r--r-- | src/common/measurement.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/common/measurement.c b/src/common/measurement.c index 95d60f67..03afaa3e 100644 --- a/src/common/measurement.c +++ b/src/common/measurement.c @@ -318,9 +318,12 @@ static uint8_t modulus_by_lchan(struct gsm_lchan *lchan) /* 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 @@ int lchan_new_ul_meas(struct gsm_lchan *lchan, struct bts_ul_meas *ulm, uint32_t 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 @@ int lchan_meas_check_compute(struct gsm_lchan *lchan, uint32_t fn) * 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); |