aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pb_decode.c11
-rw-r--r--pb_encode.c5
2 files changed, 8 insertions, 8 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 453b1cc9..baa622d3 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -122,7 +122,7 @@ bool checkreturn pb_skip_string(pb_istream_t *stream)
* to just assume the correct type and fail safely on corrupt message.
*/
-static bool checkreturn skip(pb_istream_t *stream, int wire_type)
+static bool checkreturn skip(pb_istream_t *stream, pb_wire_type_t wire_type)
{
switch (wire_type)
{
@@ -197,7 +197,7 @@ static void pb_field_init(pb_field_iterator_t *iter, const pb_field_t *fields, v
{
iter->start = iter->current = fields;
iter->field_index = 0;
- iter->pData = dest_struct + iter->current->data_offset;
+ iter->pData = (char*)dest_struct + iter->current->data_offset;
iter->pSize = (char*)iter->pData + iter->current->size_offset;
iter->dest_struct = dest_struct;
}
@@ -243,7 +243,7 @@ static bool checkreturn pb_field_find(pb_field_iterator_t *iter, int tag)
* Decode a single field *
*************************/
-static bool checkreturn decode_field(pb_istream_t *stream, int wire_type, pb_field_iterator_t *iter)
+static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_type, pb_field_iterator_t *iter)
{
pb_decoder_t func = PB_DECODERS[PB_LTYPE(iter->current->type)];
@@ -393,7 +393,8 @@ bool checkreturn pb_decode(pb_istream_t *stream, const pb_field_t fields[], void
while (stream->bytes_left)
{
uint32_t temp;
- int tag, wire_type;
+ int tag;
+ pb_wire_type_t wire_type;
if (!pb_decode_varint32(stream, &temp))
{
if (stream->bytes_left == 0)
@@ -406,7 +407,7 @@ bool checkreturn pb_decode(pb_istream_t *stream, const pb_field_t fields[], void
break; /* Special feature: allow 0-terminated messages. */
tag = temp >> 3;
- wire_type = temp & 7;
+ wire_type = (pb_wire_type_t)(temp & 7);
if (!pb_field_find(&iter, tag))
{
diff --git a/pb_encode.c b/pb_encode.c
index 58e03a68..317e31ef 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -149,15 +149,14 @@ bool checkreturn pb_encode(pb_ostream_t *stream, const pb_field_t fields[], cons
while (field->tag != 0)
{
+ pb_encoder_t func = PB_ENCODERS[PB_LTYPE(field->type)];
pData = (const char*)pData + prev_size + field->data_offset;
pSize = (const char*)pData + field->size_offset;
prev_size = field->data_size;
if (PB_HTYPE(field->type) == PB_HTYPE_ARRAY)
prev_size *= field->array_size;
-
- pb_encoder_t func = PB_ENCODERS[PB_LTYPE(field->type)];
-
+
switch (PB_HTYPE(field->type))
{
case PB_HTYPE_REQUIRED: