From bb872be0c0e40a25b7529bce98643688a85b612e Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Fri, 9 Sep 2016 14:23:16 -0700 Subject: Addressed CR comments: simplify slightly. --- upb/descriptor/reader.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'upb') diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c index be3eed8..4164bc7 100644 --- a/upb/descriptor/reader.c +++ b/upb/descriptor/reader.c @@ -570,10 +570,9 @@ static size_t field_ondefaultval(void *closure, const void *hd, const char *buf, static bool field_ononeofindex(void *closure, const void *hd, int32_t index) { upb_descreader *r = closure; upb_oneofdef *o = upb_descreader_getoneof(r, index); - bool ok; + bool ok = upb_oneofdef_addfield(o, r->f, NULL, NULL); UPB_UNUSED(hd); - ok = upb_oneofdef_addfield(o, r->f, NULL, NULL); UPB_ASSERT(ok); return true; } @@ -585,12 +584,11 @@ static size_t oneof_name(void *closure, const void *hd, const char *buf, upb_descreader *r = closure; upb_descreader_frame *f = &r->stack[r->stack_len-1]; upb_oneofdef *o = upb_descreader_getoneof(r, f->oneof_index++); - bool ok; char *name_null_terminated = upb_strndup(buf, n); + bool ok = upb_oneofdef_setname(o, name_null_terminated, NULL); UPB_UNUSED(hd); UPB_UNUSED(handle); - ok = upb_oneofdef_setname(o, name_null_terminated, NULL); UPB_ASSERT(ok); free(name_null_terminated); return n; -- cgit v1.2.3