<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/17091">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">csn1: fix csnStreamDecoder(): avoid conditional calls to bitvec_read_field()<br><br>As was discovered by pespin, changing logging level of DCSN1 makes<br>the CSN.1 decoder behave differently (see OS4375). In particular,<br>this makes RLCMACTest (encode / decode test) fail.<br><br>I did a quick investigation and noticed that some of the logging<br>statements call bitvec_read_field(). By definition this function<br>moves the internal pointer (current bit position) of a given<br>vector and increments readIndex by a given amount of bits.<br><br>The problem is that LOGPC would not evaluate its format string if<br>the logging message is not going to be printed, e.g. if a given<br>logging level is lower than the current one, or in case if<br>logging is not enabled at all.<br><br>The first two conditional calls to bitvec_read_field() are related<br>to CSN_PADDING_BITS, so that's not critical because padding is<br>always in the end of messages. The later two are related to<br>CSN_RECURSIVE_ARRAY and CSN_RECURSIVE_TARRAY respectively.<br><br>Let's use bitvec_get_uint() instead to keep readIndex unchanged.<br><br>Change-Id: Ia331048db9f790ca407fd341ced01df12d10a233<br>Fixes: OS#4375<br>---<br>M src/csn1.cpp<br>1 file changed, 4 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/91/17091/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/csn1.cpp b/src/csn1.cpp</span><br><span>index 1a3a530..12f9819 100644</span><br><span>--- a/src/csn1.cpp</span><br><span>+++ b/src/csn1.cpp</span><br><span>@@ -1153,13 +1153,13 @@</span><br><span>             guint bits_to_handle = remaining_bits_len%8;</span><br><span>             if (bits_to_handle > 0)</span><br><span>             {</span><br><span style="color: hsl(0, 100%, 40%);">-         LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, bits_to_handle));</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGPC(DCSN1, LOGL_NOTICE, "%d|", bitvec_get_uint(vector, bits_to_handle));</span><br><span>               remaining_bits_len -= bits_to_handle;</span><br><span>               bit_offset += bits_to_handle;</span><br><span>             }</span><br><span>             else if (bits_to_handle == 0)</span><br><span>             {</span><br><span style="color: hsl(0, 100%, 40%);">-              LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, 8));</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGPC(DCSN1, LOGL_NOTICE, "%d|", bitvec_get_uint(vector, 8));</span><br><span>               remaining_bits_len -= 8;</span><br><span>               bit_offset += 8;</span><br><span>             }</span><br><span>@@ -1247,7 +1247,7 @@</span><br><span>           bit_offset += no_of_bits;</span><br><span>         }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1));</span><br><span style="color: hsl(120, 100%, 40%);">+        LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , bitvec_get_uint(vector, 1));</span><br><span>         /* existNextElement() returned FALSE, 1 bit consumed */</span><br><span>         bit_offset++;</span><br><span>         remaining_bits_len--;</span><br><span>@@ -1300,7 +1300,7 @@</span><br><span>           }</span><br><span>         }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1));</span><br><span style="color: hsl(120, 100%, 40%);">+        LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , bitvec_get_uint(vector, 1));</span><br><span> </span><br><span>         /* existNextElement() returned FALSE, 1 bit consumed */</span><br><span>         bit_offset++;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/17091">change 17091</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-pcu/+/17091"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ia331048db9f790ca407fd341ced01df12d10a233 </div>
<div style="display:none"> Gerrit-Change-Number: 17091 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>