Fix warnings with -Wcast-qual. Add test for C++ compile.

Update issue 27
Status: FixedInGit
This commit is contained in:
Petteri Aimonen
2012-08-26 15:21:20 +03:00
parent 160f02e4d0
commit a06dba6e49
3 changed files with 30 additions and 17 deletions

View File

@@ -612,6 +612,7 @@ bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field
{
bool status;
pb_istream_t substream;
const pb_field_t* submsg_fields = (const pb_field_t*)field->ptr;
if (!pb_make_string_substream(stream, &substream))
return false;
@@ -619,7 +620,13 @@ bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field
if (field->ptr == NULL)
PB_RETURN_ERROR(stream, "invalid field descriptor");
status = pb_decode_noinit(&substream, (pb_field_t*)field->ptr, dest);
/* New array entries need to be initialized, while required and optional
* submessages have already been initialized in the top-level pb_decode. */
if (PB_HTYPE(field->type) == PB_HTYPE_ARRAY)
status = pb_decode(&substream, submsg_fields, dest);
else
status = pb_decode_noinit(&substream, submsg_fields, dest);
pb_close_string_substream(stream, &substream);
return status;
}