Max has submitted this change and it was merged.

Change subject: Simplify bitvec_write_field()
......................................................................


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(-)

Approvals:
  Neels Hofmeyr: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bitvec.c b/src/bitvec.c
index 24049cd..e86315c 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: merged
Gerrit-Change-Id: I9fe27c06125ac52e02e63dcded056a5f1cf68f41
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Minh-Quang Nguyen <minh-quang.ngu...@nutaq.com>
Gerrit-Reviewer: Neels Hofmeyr <nhofm...@sysmocom.de>

Reply via email to