summaryrefslogtreecommitdiffstats
path: root/pb_decode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-06 22:18:52 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-06 22:18:52 +0200
commitc3729599b0542770eff6259836c840e7a8bb3aab (patch)
tree39ac0c6a38d409f0ec080ec0d45ecef7fde8261b /pb_decode.c
parent4f379364b31fd608f531290e7fb126870769df97 (diff)
Use unsigned datatypes where appropriate.
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 51df32f8..edcbb182 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -120,7 +120,7 @@ static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest)
else
{
/* Multibyte case */
- int bitpos = 7;
+ uint8_t bitpos = 7;
result = byte & 0x7F;
do
@@ -132,7 +132,7 @@ static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest)
return false;
result |= (uint32_t)(byte & 0x7F) << bitpos;
- bitpos += 7;
+ bitpos = (uint8_t)(bitpos + 7);
} while (byte & 0x80);
}
@@ -143,7 +143,7 @@ static bool checkreturn pb_decode_varint32(pb_istream_t *stream, uint32_t *dest)
bool checkreturn pb_decode_varint(pb_istream_t *stream, uint64_t *dest)
{
uint8_t byte;
- int bitpos = 0;
+ uint8_t bitpos = 0;
uint64_t result = 0;
do
@@ -155,7 +155,7 @@ bool checkreturn pb_decode_varint(pb_istream_t *stream, uint64_t *dest)
return false;
result |= (uint64_t)(byte & 0x7F) << bitpos;
- bitpos += 7;
+ bitpos = (uint8_t)(bitpos + 7);
} while (byte & 0x80);
*dest = result;
@@ -281,8 +281,8 @@ void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream)
typedef struct {
const pb_field_t *start; /* Start of the pb_field_t array */
const pb_field_t *current; /* Current position of the iterator */
- int field_index; /* Zero-based index of the field. */
- int required_field_index; /* Zero-based index that counts only the required fields */
+ unsigned field_index; /* Zero-based index of the field. */
+ unsigned required_field_index; /* Zero-based index that counts only the required fields */
void *dest_struct; /* Pointer to the destination structure to decode to */
void *pData; /* Pointer where to store current field value */
void *pSize; /* Pointer where to store the size of current array field */
@@ -328,7 +328,7 @@ static bool pb_field_next(pb_field_iterator_t *iter)
static bool checkreturn pb_field_find(pb_field_iterator_t *iter, uint32_t tag)
{
- int start = iter->field_index;
+ unsigned start = iter->field_index;
do {
if (iter->current->tag == tag)
@@ -528,9 +528,9 @@ bool checkreturn pb_decode_noinit(pb_istream_t *stream, const pb_field_t fields[
* seeking to the end of the field array. Usually we
* are already close to end after decoding.
*/
- int req_field_count;
+ unsigned req_field_count;
uint8_t last_type;
- int i;
+ unsigned i;
do {
req_field_count = iter.required_field_index;
last_type = iter.current->type;