aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-28 16:04:35 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-30 21:24:26 +0200
commit686a3145f75c4a153f3d4a0c4951d6543ff8e0af (patch)
treeabf2cc63c56e8304dce37d2d961bb5c4846856be
parent5343e3ae4c0a4a81790935608db95410a932c187 (diff)
bitvector: Address compiler warnings about unsigned/signed
Fixes: bitvector.cpp: In function 'int bitvec_pack(bitvec*, uint8_t*)': bitvector.cpp:53:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'int bitvec_unpack(bitvec*, uint8_t*)': bitvector.cpp:63:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'uint64_t bitvec_read_field(bitvec*, unsigned int&, unsigned int)': bitvector.cpp:91:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'int bitvec_write_field(bitvec*, unsigned int&, uint64_t, unsigned int)': bitvector.cpp:108:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
-rw-r--r--src/bitvector.cpp13
-rw-r--r--src/bitvector.h4
2 files changed, 9 insertions, 8 deletions
diff --git a/src/bitvector.cpp b/src/bitvector.cpp
index 36ef798..43feebc 100644
--- a/src/bitvector.cpp
+++ b/src/bitvector.cpp
@@ -47,9 +47,9 @@ void bitvec_free(struct bitvec *bv)
talloc_free(bv);
}
-int bitvec_pack(struct bitvec *bv, uint8_t *buffer)
+unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer)
{
- int i = 0;
+ unsigned int i = 0;
for (i = 0; i < bv->data_len; i++)
{
buffer[i] = bv->data[i];
@@ -57,9 +57,9 @@ int bitvec_pack(struct bitvec *bv, uint8_t *buffer)
return i;
}
-int bitvec_unpack(struct bitvec *bv, uint8_t *buffer)
+unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer)
{
- int i = 0;
+ unsigned int i = 0;
for (i = 0; i < bv->data_len; i++)
{
bv->data[i] = buffer[i];
@@ -84,7 +84,7 @@ int bitvec_unhex(struct bitvec *bv, const char* src)
uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len)
{
- int i;
+ unsigned int i;
uint64_t ui = 0;
bv->cur_bit = read_index;
@@ -103,7 +103,8 @@ uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len
int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len)
{
- int i, rc;
+ unsigned int i;
+ int rc;
bv->cur_bit = write_index;
for (i = 0; i < len; i++) {
int bit = 0;
diff --git a/src/bitvector.h b/src/bitvector.h
index 7409d55..36bdbab 100644
--- a/src/bitvector.h
+++ b/src/bitvector.h
@@ -35,8 +35,8 @@ extern "C" {
struct bitvec *bitvec_alloc(unsigned size);
void bitvec_free(struct bitvec *bv);
int bitvec_unhex(struct bitvec *bv, const char* src);
-int bitvec_pack(struct bitvec *bv, uint8_t *buffer);
-int bitvec_unpack(struct bitvec *bv, uint8_t *buffer);
+unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer);
+unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer);
uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len);
int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len);