<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/10066">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">utils_test: fix isqrt_test calculation range<br><br>Multiplying the uint16_t x by itself seems to default to be calculated in<br>int32_t range, while it obviously needs uint32_t. This causes sporadic<br>sanitizer barfs:<br><br>    Testing integer square-root<br>    utils_test.c:445:18: runtime error: signed integer overflow: 60369 * 60369 cannot be represented in type 'int'<br><br>The final result is still correct, because it is in fact interpreted as uint32_t.<br><br>Cast to uint32_t to make sure the sanitizer doesn't complain.<br><br>Change-Id: I83c14e38deaa466d977ee43c9420534ed90f090d<br>---<br>M tests/utils/utils_test.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/libosmocore refs/changes/66/10066/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c</span><br><span>index cb4e476..84964f5 100644</span><br><span>--- a/tests/utils/utils_test.c</span><br><span>+++ b/tests/utils/utils_test.c</span><br><span>@@ -439,7 +439,7 @@</span><br><span>                       x = r * (UINT16_MAX/RAND_MAX);</span><br><span>               else</span><br><span>                         x = r;</span><br><span style="color: hsl(0, 100%, 40%);">-          uint32_t sq = x*x;</span><br><span style="color: hsl(120, 100%, 40%);">+            uint32_t sq = (uint32_t)x*x;</span><br><span>                 uint32_t y = osmo_isqrt32(sq);</span><br><span>               if (y != x)</span><br><span>                  printf("ERROR: x=%u, sq=%u, osmo_isqrt(%u) = %u\n", x, sq, sq, y);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10066">change 10066</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/10066"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I83c14e38deaa466d977ee43c9420534ed90f090d </div>
<div style="display:none"> Gerrit-Change-Number: 10066 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>