[PATCH 1/4] Improve code style and readability

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/OpenBSC@lists.osmocom.org/.

suraev at alumni.ntnu.no suraev at alumni.ntnu.no
Thu Jan 28 11:28:28 UTC 2016


From: Max <msuraev at sysmocom.de>

---
 src/bitvec.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/bitvec.c b/src/bitvec.c
index f9341b7..7254674 100644
--- a/src/bitvec.c
+++ b/src/bitvec.c
@@ -383,14 +383,12 @@ unsigned int bitvec_unpack(struct bitvec *bv, const uint8_t *buffer)
 
 int bitvec_unhex(struct bitvec *bv, const char *src)
 {
-	unsigned val;
-	unsigned write_index = 0;
-	unsigned digits = bv->data_len * 2;
-	for (unsigned i = 0; i < digits; i++) {
-		if (sscanf(src + i, "%1x", &val) < 1) {
+	unsigned val, i, write_index = 0;
+	for (i = 0; i < bv->data_len * 2; i++) {
+		if (sscanf(src + i, "%1x", &val) < 1)
 			return 1;
-		}
-		bitvec_write_field(bv, write_index,val, 4);
+
+		bitvec_write_field(bv, write_index, val, 4);
 	}
 	return 0;
 }
-- 
2.5.0




More information about the OpenBSC mailing list