Skip to content

Commit

Permalink
Fixed protobuf enum printing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shvedko authored and michaelstorm committed Apr 26, 2014
1 parent 3a2025e commit 91cd5b1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/message_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ required_field_print(const ProtobufCFieldDescriptor *field,
break;
case PROTOBUF_C_TYPE_ENUM:
{
uint32_t value = *(const uint32_t *)member;
const ProtobufCEnumDescriptor *desc = field->descriptor;
fprintf(out, "%u", value);
if (value < desc->n_values)
fprintf(out, " (%s)", desc->values[value].name);
int32_t value = *(const int32_t *) member;
const ProtobufCEnumValue *evalue = protobuf_c_enum_descriptor_get_value(field->descriptor, value);
fprintf(out, "%d (%s)", evalue->value, evalue->name);
break;
}
}
Expand Down

0 comments on commit 91cd5b1

Please sign in to comment.