<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 1: Code-Review+1</p><p style="white-space: pre-wrap; word-wrap: break-word;">deprecating the function would be the clean solution IMHO, but if you say it's not worth it... fine with me.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">If we go for bitvec_read_field2(), we would have to rework a lot of stuff in osmo-pcu. Basically all invocations of this function, for example:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  uint64_t field = bitvec_read_field(bv, offset, len);</pre><p style="white-space: pre-wrap; word-wrap: break-word;">would need to be rewritten to:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  uint64_t field;</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  if (bitvec_read_field2(bv, &field, offset, len) != 0)<br>    // handle error</pre><p style="white-space: pre-wrap; word-wrap: break-word;">The problem here is that oftentimes it makes more sense to check if the vector has enough data *once*, and then invoke bitvec_read_field() many times without any checks. Here is a good example from osmo-pcu:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2);<br>  data->RRBP = bitvec_read_field(vector, &readIndex, 2);<br>  data->SP = bitvec_read_field(vector, &readIndex, 1);<br>  data->USF = bitvec_read_field(vector, &readIndex, 3);</pre><p style="white-space: pre-wrap; word-wrap: break-word;">This is why I prefer the errno approach: you get a possibility to detect errors, but you don't force the user to use the new API, what makes sense in places where checking for errors is not needed.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/26307">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/26307">change 26307</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/libosmocore/+/26307"/><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-Change-Id: I2cc734caa3365d03c2ae2b3f2cd9544933c25e9e </div>
<div style="display:none"> Gerrit-Change-Number: 26307 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 18 Nov 2021 13:10:17 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>