aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-01-22 16:46:56 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-22 23:22:48 +0100
commite49af08f5b89b3f922948570eab161763f339185 (patch)
tree0ea6e8d63146ec23ff7984bf176658149d9347b1
parent08621a8ebb163aed6ba96e52ad283b91c04501a0 (diff)
bitvec: Fix interface to consistently use unsigned int
Use unsigned int for the length throughout the interface. We will never have a a negative length. Sponsored-by: On-Waves ehf
-rw-r--r--include/osmocom/core/bitvec.h10
-rw-r--r--src/bitvec.c14
2 files changed, 12 insertions, 12 deletions
diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
index 89eb7848..2415a814 100644
--- a/include/osmocom/core/bitvec.h
+++ b/include/osmocom/core/bitvec.h
@@ -66,12 +66,12 @@ int bitvec_set_bit_pos(struct bitvec *bv, unsigned int bitnum,
enum bit_value bit);
int bitvec_set_bit(struct bitvec *bv, enum bit_value bit);
int bitvec_get_bit_high(struct bitvec *bv);
-int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count);
-int bitvec_set_uint(struct bitvec *bv, unsigned int in, int count);
-int bitvec_get_uint(struct bitvec *bv, int num_bits);
+int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, unsigned int count);
+int bitvec_set_uint(struct bitvec *bv, uint32_t in, unsigned int count);
+int bitvec_get_uint(struct bitvec *bv, unsigned int num_bits);
int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val);
int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit);
-int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, int count);
-int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, int count);
+int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, unsigned int count);
+int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, unsigned int count);
/*! @} */
diff --git a/src/bitvec.c b/src/bitvec.c
index 726a7681..8596d510 100644
--- a/src/bitvec.c
+++ b/src/bitvec.c
@@ -190,7 +190,7 @@ int bitvec_get_bit_high(struct bitvec *bv)
* \param[in] bits array of \ref bit_value
* \param[in] count number of bits to set
*/
-int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count)
+int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, unsigned int count)
{
int i, rc;
@@ -204,10 +204,10 @@ int bitvec_set_bits(struct bitvec *bv, enum bit_value *bits, int count)
}
/*! \brief set multiple bits (based on numeric value) at current pos */
-int bitvec_set_uint(struct bitvec *bv, unsigned int ui, int num_bits)
+int bitvec_set_uint(struct bitvec *bv, unsigned int ui, unsigned int num_bits)
{
- int i, rc;
-
+ int rc;
+ unsigned i;
for (i = 0; i < num_bits; i++) {
int bit = 0;
if (ui & (1 << (num_bits - i - 1)))
@@ -221,7 +221,7 @@ int bitvec_set_uint(struct bitvec *bv, unsigned int ui, int num_bits)
}
/*! \brief get multiple bits (based on numeric value) from current pos */
-int bitvec_get_uint(struct bitvec *bv, int num_bits)
+int bitvec_get_uint(struct bitvec *bv, unsigned int num_bits)
{
int i;
unsigned int ui = 0;
@@ -269,7 +269,7 @@ int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n,
* \param[in] bytes array
* \param[in] count number of bytes to copy
*/
-int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, int count)
+int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, unsigned int count)
{
int byte_offs = bytenum_from_bitnum(bv->cur_bit);
int bit_offs = bv->cur_bit % 8;
@@ -304,7 +304,7 @@ int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, int count)
* \param[in] bytes array
* \param[in] count number of bytes to copy
*/
-int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, int count)
+int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, unsigned int count)
{
int byte_offs = bytenum_from_bitnum(bv->cur_bit);
int bit_offs = bv->cur_bit % 8;