<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bts/+/16739">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">measurement: use signed integer for division of ta256b_sum<br><br>The variable ta256b_sum is int32_t and num_ul_meas_actual is unsigned<br>int. When ta256b_sum is negative the division produces the wrong result.<br><br>This is beacuse the division is performed unsigned as the usual<br>arithmetic conversions promote to unsigned where both both operands are<br>the same width.<br><br>Lets fix this by casting num_ul_meas_actual to signed.<br><br>(Note that in the same function there are various other averages<br>computed in the same pattern, but they have unsigned operands and so are<br>correct.)<br><br>Related: SYS#4728<br>Change-Id: I37e3f69109c5ca2948bd4cdb7aa017bf2fcb8172<br>---<br>M src/common/measurement.c<br>1 file changed, 1 insertion(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/39/16739/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/common/measurement.c b/src/common/measurement.c</span><br><span>index 12fd779..3e0daf1 100644</span><br><span>--- a/src/common/measurement.c</span><br><span>+++ b/src/common/measurement.c</span><br><span>@@ -662,7 +662,7 @@</span><br><span>        if (!num_ul_meas_actual)</span><br><span>             ta256b_sum = lchan->meas.ms_toa256;</span><br><span>       else</span><br><span style="color: hsl(0, 100%, 40%);">-            ta256b_sum = ta256b_sum / num_ul_meas_actual;</span><br><span style="color: hsl(120, 100%, 40%);">+         ta256b_sum = ta256b_sum / (signed)num_ul_meas_actual;</span><br><span> </span><br><span>    if (!num_meas_sub)</span><br><span>           ber_sub_sum = MEASUREMENT_DUMMY_BER;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/16739">change 16739</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-bts/+/16739"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I37e3f69109c5ca2948bd4cdb7aa017bf2fcb8172 </div>
<div style="display:none"> Gerrit-Change-Number: 16739 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>