Quiet -Wsign-compare errors

PiperOrigin-RevId: 516327145
pull/13171/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent b9fb58bba5
commit fdb45f0da0
  1. 4
      upb/hash/common.c
  2. 2
      upb/mini_table/common.c
  3. 6
      upb/mini_table/decode.c
  4. 2
      upb/wire/decode.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 {

@ -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;

@ -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,

@ -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;

Loading…
Cancel
Save