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

Change subject: measurement: use signed integer for division of ta256b_sum
......................................................................

measurement: use signed integer for division of ta256b_sum

The variable ta256b_sum is int32_t and num_ul_meas_actual is unsigned
int. When ta256b_sum is negative the division produces the wrong result.

This is beacuse the division is performed unsigned as the usual
arithmetic conversions promote to unsigned where both both operands are
the same width.

Lets fix this by casting num_ul_meas_actual to signed.

(Note that in the same function there are various other averages
computed in the same pattern, but they have unsigned operands and so are
correct.)

Related: SYS#4728
Change-Id: I37e3f69109c5ca2948bd4cdb7aa017bf2fcb8172
---
M src/common/measurement.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/common/measurement.c b/src/common/measurement.c
index 12fd779..3e0daf1 100644
--- a/src/common/measurement.c
+++ b/src/common/measurement.c
@@ -662,7 +662,7 @@
        if (!num_ul_meas_actual)
                ta256b_sum = lchan->meas.ms_toa256;
        else
-               ta256b_sum = ta256b_sum / num_ul_meas_actual;
+               ta256b_sum = ta256b_sum / (signed)num_ul_meas_actual;

        if (!num_meas_sub)
                ber_sub_sum = MEASUREMENT_DUMMY_BER;

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I37e3f69109c5ca2948bd4cdb7aa017bf2fcb8172
Gerrit-Change-Number: 16739
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to