Change in libosmocore[master]: bitvec_read_field(): indicate errors using errno

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

fixeria gerrit-no-reply at lists.osmocom.org
Thu Nov 18 13:10:17 UTC 2021


fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/26307 )

Change subject: bitvec_read_field(): indicate errors using errno
......................................................................


Patch Set 1:

> Patch Set 1: Code-Review+1
> 
> deprecating the function would be the clean solution IMHO, but if you say it's not worth it... fine with me.

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:

  uint64_t field = bitvec_read_field(bv, offset, len);

would need to be rewritten to:

  uint64_t field;

  if (bitvec_read_field2(bv, &field, offset, len) != 0)
    // handle error

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:

  data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2);
  data->RRBP = bitvec_read_field(vector, &readIndex, 2);
  data->SP = bitvec_read_field(vector, &readIndex, 1);
  data->USF = bitvec_read_field(vector, &readIndex, 3);

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.


-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/26307
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2cc734caa3365d03c2ae2b3f2cd9544933c25e9e
Gerrit-Change-Number: 26307
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-Comment-Date: Thu, 18 Nov 2021 13:10:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211118/e7859aa4/attachment.htm>


More information about the gerrit-log mailing list