Code Review
/
apps
/
agl-service-can-low-level.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
travis-ci: Build C/C++/Python matrix
[apps/agl-service-can-low-level.git]
/
pb_encode.c
diff --git
a/pb_encode.c
b/pb_encode.c
index
5318361
..
cc372b8
100644
(file)
--- a/
pb_encode.c
+++ b/
pb_encode.c
@@
-250,6
+250,17
@@
static bool checkreturn encode_basic_field(pb_ostream_t *stream,
return false;
break;
return false;
break;
+ case PB_HTYPE_ONEOF:
+ if (*(const pb_size_t*)pSize == field->tag)
+ {
+ if (!pb_encode_tag_for_field(stream, field))
+ return false;
+
+ if (!func(stream, field, pData))
+ return false;
+ }
+ break;
+
default:
PB_RETURN_ERROR(stream, "invalid field type");
}
default:
PB_RETURN_ERROR(stream, "invalid field type");
}
@@
-567,7
+578,7
@@
static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *fi
int64_t value = 0;
/* Cases 1 and 2 are for compilers that have smaller types for bool
int64_t value = 0;
/* Cases 1 and 2 are for compilers that have smaller types for bool
- * or enums. */
+ * or enums
, and for int_size option
. */
switch (field->data_size)
{
case 1: value = *(const int8_t*)src; break;
switch (field->data_size)
{
case 1: value = *(const int8_t*)src; break;
@@
-586,6
+597,8
@@
static bool checkreturn pb_enc_uvarint(pb_ostream_t *stream, const pb_field_t *f
switch (field->data_size)
{
switch (field->data_size)
{
+ case 1: value = *(const uint8_t*)src; break;
+ case 2: value = *(const uint16_t*)src; break;
case 4: value = *(const uint32_t*)src; break;
case 8: value = *(const uint64_t*)src; break;
default: PB_RETURN_ERROR(stream, "invalid data_size");
case 4: value = *(const uint32_t*)src; break;
case 8: value = *(const uint64_t*)src; break;
default: PB_RETURN_ERROR(stream, "invalid data_size");
@@
-600,6
+613,8
@@
static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *f
switch (field->data_size)
{
switch (field->data_size)
{
+ case 1: value = *(const int8_t*)src; break;
+ case 2: value = *(const int16_t*)src; break;
case 4: value = *(const int32_t*)src; break;
case 8: value = *(const int64_t*)src; break;
default: PB_RETURN_ERROR(stream, "invalid data_size");
case 4: value = *(const int32_t*)src; break;
case 8: value = *(const int64_t*)src; break;
default: PB_RETURN_ERROR(stream, "invalid data_size");