Change in osmo-bts[master]: measurement: use signed integer for division of ta256b_sum

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

dexter gerrit-no-reply at lists.osmocom.org
Mon Jan 6 11:12:32 UTC 2020


dexter has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/39/16739/1

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 <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200106/da1084c8/attachment.htm>


More information about the gerrit-log mailing list