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
Fixed formatting in docs
[apps/agl-service-can-low-level.git]
/
pb_encode.c
diff --git
a/pb_encode.c
b/pb_encode.c
index
804c1a6
..
c6cccf2
100644
(file)
--- a/
pb_encode.c
+++ b/
pb_encode.c
@@
-76,7
+76,7
@@
bool checkreturn pb_write(pb_ostream_t *stream, const uint8_t *buf, size_t count
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field,
const void *pData, size_t count, pb_encoder_t func)
{
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field,
const void *pData, size_t count, pb_encoder_t func)
{
-
in
t i;
+
size_
t i;
const void *p;
size_t size;
const void *p;
size_t size;
@@
-212,7
+212,7
@@
bool checkreturn pb_encode_varint(pb_ostream_t *stream, uint64_t value)
while (value)
{
while (value)
{
- buffer[i] = (
value & 0x7F) | 0x80
;
+ buffer[i] = (
uint8_t)((value & 0x7F) | 0x80)
;
value >>= 7;
i++;
}
value >>= 7;
i++;
}
@@
-236,7
+236,11
@@
bool checkreturn pb_encode_fixed32(pb_ostream_t *stream, const void *value)
{
#ifdef __BIG_ENDIAN__
uint8_t *bytes = value;
{
#ifdef __BIG_ENDIAN__
uint8_t *bytes = value;
- uint8_t lebytes[4] = {bytes[3], bytes[2], bytes[1], bytes[0]};
+ uint8_t lebytes[4];
+ lebytes[0] = bytes[3];
+ lebytes[1] = bytes[2];
+ lebytes[2] = bytes[1];
+ lebytes[3] = bytes[0];
return pb_write(stream, lebytes, 4);
#else
return pb_write(stream, (uint8_t*)value, 4);
return pb_write(stream, lebytes, 4);
#else
return pb_write(stream, (uint8_t*)value, 4);
@@
-247,8
+251,15
@@
bool checkreturn pb_encode_fixed64(pb_ostream_t *stream, const void *value)
{
#ifdef __BIG_ENDIAN__
uint8_t *bytes[8] = value;
{
#ifdef __BIG_ENDIAN__
uint8_t *bytes[8] = value;
- uint8_t lebytes[8] = {bytes[7], bytes[6], bytes[5], bytes[4],
- bytes[3], bytes[2], bytes[1], bytes[0]};
+ uint8_t lebytes[8];
+ lebytes[0] = bytes[7];
+ lebytes[1] = bytes[6];
+ lebytes[2] = bytes[5];
+ lebytes[3] = bytes[4];
+ lebytes[4] = bytes[3];
+ lebytes[5] = bytes[2];
+ lebytes[6] = bytes[1];
+ lebytes[7] = bytes[0];
return pb_write(stream, lebytes, 8);
#else
return pb_write(stream, (uint8_t*)value, 8);
return pb_write(stream, lebytes, 8);
#else
return pb_write(stream, (uint8_t*)value, 8);
@@
-373,22
+384,26
@@
bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, c
bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
+ UNUSED(field);
return pb_encode_fixed64(stream, src);
}
bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
return pb_encode_fixed64(stream, src);
}
bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
+ UNUSED(field);
return pb_encode_fixed32(stream, src);
}
bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
pb_bytes_array_t *bytes = (pb_bytes_array_t*)src;
return pb_encode_fixed32(stream, src);
}
bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
pb_bytes_array_t *bytes = (pb_bytes_array_t*)src;
+ UNUSED(field);
return pb_encode_string(stream, bytes->bytes, bytes->size);
}
bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
return pb_encode_string(stream, bytes->bytes, bytes->size);
}
bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
+ UNUSED(field);
return pb_encode_string(stream, (uint8_t*)src, strlen((char*)src));
}
return pb_encode_string(stream, (uint8_t*)src, strlen((char*)src));
}