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* iter) {
intptr_t i = *iter; intptr_t i = *iter;
if ((size_t)(i + 1) <= t->array_size) { 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]; upb_tabval ent = t->array[i];
if (upb_arrhas(ent)) { if (upb_arrhas(ent)) {
*key = i; *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) { void upb_inttable_removeiter(upb_inttable* t, intptr_t* iter) {
intptr_t i = *iter; intptr_t i = *iter;
if (i < t->array_size) { if ((size_t)i < t->array_size) {
t->array_count--; t->array_count--;
mutable_array(t)[i].val = -1; mutable_array(t)[i].val = -1;
} else { } else {

@ -68,7 +68,7 @@ const upb_MiniTableField* upb_MiniTable_FindFieldByNumber(
int hi = t->field_count - 1; int hi = t->field_count - 1;
while (lo <= hi) { while (lo <= hi) {
int mid = (lo + hi) / 2; int mid = (lo + hi) / 2;
int num = t->fields[mid].number; uint32_t num = t->fields[mid].number;
if (num < number) { if (num < number) {
lo = mid + 1; lo = mid + 1;
continue; continue;

@ -244,14 +244,14 @@ static void upb_MiniTable_SetField(upb_MtDecoder* d, uint8_t ch,
field->offset = kHasbitPresence; field->offset = kHasbitPresence;
if (type == kUpb_EncodedType_Group || type == kUpb_EncodedType_Message) { if (type == kUpb_EncodedType_Group || type == kUpb_EncodedType_Message) {
field->mode |= pointer_rep << kUpb_FieldRep_Shift; 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_MtDecoder_ErrorFormat(d, "Invalid field type: %d", (int)type);
UPB_UNREACHABLE(); UPB_UNREACHABLE();
} else { } else {
field->mode |= kUpb_EncodedToFieldRep[type] << kUpb_FieldRep_Shift; 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_MtDecoder_ErrorFormat(d, "Invalid field type: %d", (int)type);
UPB_UNREACHABLE(); UPB_UNREACHABLE();
} }
@ -667,7 +667,7 @@ static void upb_MtDecoder_AssignOffsets(upb_MtDecoder* d) {
static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d, static void upb_MtDecoder_ValidateEntryField(upb_MtDecoder* d,
const upb_MiniTableField* f, const upb_MiniTableField* f,
int expected_num) { uint32_t expected_num) {
const char* name = expected_num == 1 ? "key" : "val"; const char* name = expected_num == 1 ? "key" : "val";
if (f->number != expected_num) { if (f->number != expected_num) {
upb_MtDecoder_ErrorFormat(d, 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) { if (t->dense_below < t->field_count) {
/* Linear search non-dense fields. Resume scanning from last_field_index /* Linear search non-dense fields. Resume scanning from last_field_index
* since fields are usually in order. */ * 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++) { for (idx = last; idx < t->field_count; idx++) {
if (t->fields[idx].number == field_number) { if (t->fields[idx].number == field_number) {
goto found; goto found;

Loading…
Cancel
Save