This should help avoid issue 33 in the future.
/* Number of declared LTYPES */
PB_LTYPES_COUNT = 7,
/* Number of declared LTYPES */
PB_LTYPES_COUNT = 7,
/******************
* Modifier flags *
/******************
* Modifier flags *
* data_offset points to pb_callback_t structure.
* LTYPE should be 0 (it is ignored, but sometimes
* used to speculatively index an array). */
* data_offset points to pb_callback_t structure.
* LTYPE should be 0 (it is ignored, but sometimes
* used to speculatively index an array). */
- PB_HTYPE_CALLBACK = 0x30
+ PB_HTYPE_CALLBACK = 0x30,
+
+ PB_HTYPE_MASK = 0xF0
-#define PB_HTYPE(x) ((x) & 0xF0)
-#define PB_LTYPE(x) ((x) & 0x0F)
+#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
+#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
/* This structure is used in auto-generated constants
* to specify struct fields.
/* This structure is used in auto-generated constants
* to specify struct fields.
bool checkreturn pb_decode_varint(pb_istream_t *stream, uint64_t *dest)
{
uint8_t byte;
bool checkreturn pb_decode_varint(pb_istream_t *stream, uint64_t *dest)
{
uint8_t byte;
*dest = 0;
while (bitpos < 64 && pb_read(stream, &byte, 1))
*dest = 0;
while (bitpos < 64 && pb_read(stream, &byte, 1))
if (PB_HTYPE(iter.current->type) == PB_HTYPE_REQUIRED
&& iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
{
if (PB_HTYPE(iter.current->type) == PB_HTYPE_REQUIRED
&& iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
{
- fields_seen[iter.required_field_index >> 3] |= 1 << (iter.required_field_index & 7);
+ fields_seen[iter.required_field_index >> 3] |= (uint8_t)(1 << (iter.required_field_index & 7));
}
if (!decode_field(stream, wire_type, &iter))
}
if (!decode_field(stream, wire_type, &iter))
return false;
if (value & 1)
return false;
if (value & 1)
+ *dest = (int64_t)(~(value >> 1));
+ *dest = (int64_t)(value >> 1);
bool checkreturn pb_encode_varint(pb_ostream_t *stream, uint64_t value)
{
uint8_t buffer[10];
bool checkreturn pb_encode_varint(pb_ostream_t *stream, uint64_t value)
{
uint8_t buffer[10];
if (value == 0)
return pb_write(stream, (uint8_t*)&value, 1);
if (value == 0)
return pb_write(stream, (uint8_t*)&value, 1);
{
uint64_t zigzagged;
if (value < 0)
{
uint64_t zigzagged;
if (value < 0)
- zigzagged = ~(value << 1);
+ zigzagged = (uint64_t)(~(value << 1));
- zigzagged = value << 1;
+ zigzagged = (uint64_t)(value << 1);
return pb_encode_varint(stream, zigzagged);
}
return pb_encode_varint(stream, zigzagged);
}
-bool checkreturn pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, int field_number)
+bool checkreturn pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number)
{
uint64_t tag = wiretype | (field_number << 3);
return pb_encode_varint(stream, tag);
{
uint64_t tag = wiretype | (field_number << 3);
return pb_encode_varint(stream, tag);
bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src)
{
switch (field->data_size)
{
switch (field->data_size)
{
/* Encode field header by manually specifing wire type. You need to use this if
* you want to write out packed arrays from a callback field. */
/* Encode field header by manually specifing wire type. You need to use this if
* you want to write out packed arrays from a callback field. */
-bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, int field_number);
+bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number);
/* Encode an integer in the varint format.
* This works for bool, enum, int32, int64, uint32 and uint64 field types. */
/* Encode an integer in the varint format.
* This works for bool, enum, int32, int64, uint32 and uint64 field types. */
TESTS=test_decode1 test_encode1 decode_unittests encode_unittests test_no_messages
# More strict checks for the core part of nanopb
TESTS=test_decode1 test_encode1 decode_unittests encode_unittests test_no_messages
# More strict checks for the core part of nanopb
-CFLAGS_CORE=-pedantic -Wextra -Wcast-qual -Wlogical-op
+CFLAGS_CORE=-pedantic -Wextra -Wcast-qual -Wlogical-op -Wconversion
all: breakpoints $(TESTS) run_unittests
all: breakpoints $(TESTS) run_unittests