diff --git a/upb/hash/common.c b/upb/hash/common.c index 1e32f36f8a..8bc9087369 100644 --- a/upb/hash/common.c +++ b/upb/hash/common.c @@ -776,7 +776,7 @@ bool upb_inttable_next(const upb_inttable* t, uintptr_t* key, upb_value* val, intptr_t* iter) { intptr_t i = *iter; if ((size_t)(i + 1) <= t->array_size) { - while (++i < t->array_size) { + while ((size_t)++i < t->array_size) { upb_tabval ent = t->array[i]; if (upb_arrhas(ent)) { *key = i; @@ -802,7 +802,7 @@ bool upb_inttable_next(const upb_inttable* t, uintptr_t* key, upb_value* val, void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter) { intptr_t i = *iter; - if (i < t->array_size) { + if ((size_t)i < t->array_size) { t->array_count--; mutable_array(t)[i].val = -1; } else { diff --git a/upb/mini_table/common.c b/upb/mini_table/common.c index 2c4c911963..34c7c91cf1 100644 --- a/upb/mini_table/common.c +++ b/upb/mini_table/common.c @@ -68,7 +68,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber( int hi = t->field_count - 1; while (lo <= hi) { int mid = (lo + hi) / 2; - int num = t->fields[mid].number; + uint32_t num = t->fields[mid].number; if (num < number) { lo = mid + 1; continue; diff --git a/upb/mini_table/decode.c b/upb/mini_table/decode.c index 02d70132cc..976471c0c7 100644 --- a/upb/mini_table/decode.c +++ b/upb/mini_table/decode.c @@ -244,14 +244,14 @@ static void upb_MiniTable_SetField(upb_MtDecoder* d, uint8_t ch, field->offset = kHasbitPresence; if (type == kUpb_EncodedType_Group || type == kUpb_EncodedType_Message) { field->mode |= pointer_rep << kUpb_FieldRep_Shift; - } else if (type >= sizeof(kUpb_EncodedToFieldRep)) { + } else if ((unsigned long)type >= sizeof(kUpb_EncodedToFieldRep)) { upb_MtDecoder_ErrorFormat(d, "Invalid field type: %d", (int)type); UPB_UNREACHABLE(); } else { field->mode |= kUpb_EncodedToFieldRep[type] << kUpb_FieldRep_Shift; } } - if (type >= sizeof(kUpb_EncodedToType)) { + if ((unsigned long)type >= sizeof(kUpb_EncodedToType)) { upb_MtDecoder_ErrorFormat(d, "Invalid field type: %d", (int)type); UPB_UNREACHABLE(); } @@ -667,7 +667,7 @@ static void upb_MtDecoder_AssignOffsets(upb_MtDecoder* d) { static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d, const upb_MiniTableField* f, - int expected_num) { + uint32_t expected_num) { const char* name = expected_num == 1 ? "key" : "val"; if (f->number != expected_num) { upb_MtDecoder_ErrorFormat(d, diff --git a/upb/wire/decode.c b/upb/wire/decode.c index 852052f9cd..fde4e4bbbf 100644 --- a/upb/wire/decode.c +++ b/upb/wire/decode.c @@ -887,7 +887,7 @@ static const upb_MiniTableField* _upb_Decoder_FindField(upb_Decoder* d, if (t->dense_below < t->field_count) { /* Linear search non-dense fields. Resume scanning from last_field_index * since fields are usually in order. */ - int last = *last_field_index; + size_t last = *last_field_index; for (idx = last; idx < t->field_count; idx++) { if (t->fields[idx].number == field_number) { goto found;