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/.
Max gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/4339
Simplify bitvec_write_field()
Use existing function instead of copy-pasted loop.
Change-Id: I9fe27c06125ac52e02e63dcded056a5f1cf68f41
Related: OS#1526
---
M src/bitvec.c
1 file changed, 7 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/4339/1
diff --git a/src/bitvec.c b/src/bitvec.c
index 5b742fc..0683694 100644
--- a/src/bitvec.c
+++ b/src/bitvec.c
@@ -505,18 +505,16 @@
*/
int bitvec_write_field(struct bitvec *bv, unsigned int *write_index, uint64_t val, unsigned int len)
{
- unsigned int i;
int rc;
+
bv->cur_bit = *write_index;
- for (i = 0; i < len; i++) {
- int bit = 0;
- if (val & ((uint64_t)1 << (len - i - 1)))
- bit = 1;
- rc = bitvec_set_bit(bv, bit);
- if (rc)
- return rc;
- }
+
+ rc = bitvec_set_u64(bv, val, len, false);
+ if (rc != 0)
+ return rc;
+
*write_index += len;
+
return 0;
}
--
To view, visit https://gerrit.osmocom.org/4339
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fe27c06125ac52e02e63dcded056a5f1cf68f41
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>