|
|
|
@ -74,7 +74,7 @@ static bool upb_decode_varint32(const char **ptr, const char *limit, |
|
|
|
|
uint32_t *val) { |
|
|
|
|
uint64_t u64; |
|
|
|
|
CHK(upb_decode_varint(ptr, limit, &u64) && u64 <= UINT32_MAX); |
|
|
|
|
*val = u64; |
|
|
|
|
*val = (uint32_t)u64; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -336,7 +336,7 @@ static bool upb_decode_varintfield(upb_decstate *d, upb_decframe *frame, |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_INT32: |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_UINT32: |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_ENUM: { |
|
|
|
|
uint32_t val32 = val; |
|
|
|
|
uint32_t val32 = (uint32_t)val; |
|
|
|
|
CHK(upb_decode_addval(frame, field, &val32, sizeof(val32))); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -346,7 +346,7 @@ static bool upb_decode_varintfield(upb_decstate *d, upb_decframe *frame, |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_SINT32: { |
|
|
|
|
int32_t decoded = upb_zzdecode_32(val); |
|
|
|
|
int32_t decoded = upb_zzdecode_32((uint32_t)val); |
|
|
|
|
CHK(upb_decode_addval(frame, field, &decoded, sizeof(decoded))); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -425,7 +425,10 @@ static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame, |
|
|
|
|
upb_array *arr = upb_getorcreatearr(frame, field); |
|
|
|
|
CHK(arr); |
|
|
|
|
|
|
|
|
|
#define VARINT_CASE(ctype, decode) \ |
|
|
|
|
#define VARINT_CASE(ctype, decode) \ |
|
|
|
|
VARINT_CASE_EX(ctype, decode, decode) |
|
|
|
|
|
|
|
|
|
#define VARINT_CASE_EX(ctype, decode, dtype) \ |
|
|
|
|
{ \
|
|
|
|
|
const char *ptr = d->ptr; \
|
|
|
|
|
const char *limit = ptr + len; \
|
|
|
|
@ -433,7 +436,7 @@ static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame, |
|
|
|
|
uint64_t val; \
|
|
|
|
|
ctype decoded; \
|
|
|
|
|
CHK(upb_decode_varint(&ptr, limit, &val)); \
|
|
|
|
|
decoded = (decode)(val); \
|
|
|
|
|
decoded = (decode)((dtype)val); \
|
|
|
|
|
CHK(upb_array_add(arr, 1, sizeof(decoded), &decoded, d->arena)); \
|
|
|
|
|
} \
|
|
|
|
|
d->ptr = ptr; \
|
|
|
|
@ -464,9 +467,9 @@ static bool upb_decode_toarray(upb_decstate *d, upb_decframe *frame, |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_BOOL: |
|
|
|
|
VARINT_CASE(bool, bool); |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_SINT32: |
|
|
|
|
VARINT_CASE(int32_t, upb_zzdecode_32); |
|
|
|
|
VARINT_CASE_EX(int32_t, upb_zzdecode_32, uint32_t); |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_SINT64: |
|
|
|
|
VARINT_CASE(int64_t, upb_zzdecode_64); |
|
|
|
|
VARINT_CASE_EX(int64_t, upb_zzdecode_64, uint64_t); |
|
|
|
|
case UPB_DESCRIPTOR_TYPE_MESSAGE: { |
|
|
|
|
const upb_msglayout *subm; |
|
|
|
|
upb_msg *submsg = upb_addmsg(frame, field, &subm); |
|
|
|
|