fix some warnings when the compiler is being strict

PiperOrigin-RevId: 476384407
pull/13171/head
Eric Salo 2 years ago committed by Copybara-Service
parent 4241cab125
commit c7187301d3
  1. 2
      upb/io/string.h
  2. 12
      upb/io/tokenizer_test.cc
  3. 4
      upb/mini_table_test.cc

@ -62,9 +62,9 @@ UPB_INLINE bool upb_String_Init(upb_String* s, upb_Arena* a) {
s->size_ = 0;
s->capacity_ = kDefaultCapacity;
s->data_ = (char*)upb_Arena_Malloc(a, kDefaultCapacity);
s->arena_ = a;
if (!s->data_) return false;
s->data_[0] = '\0';
s->arena_ = a;
return true;
}

@ -81,7 +81,7 @@ static bool StringEquals(const char* a, const char* b) {
}; \
\
TEST_F(FIXTURE##_##NAME##_DD, NAME) { \
for (int i = 0; i < arraysize(CASES); i++) { \
for (size_t i = 0; i < arraysize(CASES); i++) { \
SCOPED_TRACE(testing::Message() \
<< #CASES " case #" << i << ": " << CASES[i]); \
DoSingleCase(CASES[i]); \
@ -100,8 +100,8 @@ static bool StringEquals(const char* a, const char* b) {
}; \
\
TEST_F(FIXTURE##_##NAME##_DD, NAME) { \
for (int i = 0; i < arraysize(CASES1); i++) { \
for (int j = 0; j < arraysize(CASES2); j++) { \
for (size_t i = 0; i < arraysize(CASES1); i++) { \
for (size_t j = 0; j < arraysize(CASES2); j++) { \
SCOPED_TRACE(testing::Message() \
<< #CASES1 " case #" << i << ": " << CASES1[i] << ", " \
<< #CASES2 " case #" << j << ": " << CASES2[j]); \
@ -571,7 +571,7 @@ TEST_1D(TokenizerTest, ShCommentStyle, kBlockSizes) {
auto t = upb_Tokenizer_New(NULL, 0, input, options, arena.ptr());
// Advance through tokens and check that they are parsed as expected.
for (int i = 0; i < arraysize(kTokens); i++) {
for (size_t i = 0; i < arraysize(kTokens); i++) {
EXPECT_TRUE(upb_Tokenizer_Next(t, NULL));
EXPECT_TRUE(StringEquals(upb_Tokenizer_TextData(t), kTokens[i]));
}
@ -1000,7 +1000,7 @@ TEST_F(TokenizerTest, ParseString) {
upb::Arena arena;
for (int i = 0; i < sizeof(inputs) / sizeof(inputs[0]); i++) {
for (size_t i = 0; i < sizeof(inputs) / sizeof(inputs[0]); i++) {
auto sv = upb_Parse_String(inputs[i].data(), arena.ptr());
EXPECT_TRUE(StringEquals(sv.data, outputs[i].data()));
}
@ -1202,7 +1202,7 @@ static std::string StandardUTF8(uint32_t code_point) {
static std::string DisplayHex(const std::string& data) {
std::string output;
for (int i = 0; i < data.size(); ++i) {
for (size_t i = 0; i < data.size(); ++i) {
absl::StrAppendFormat(&output, "%02x ", data[i]);
}
return output;

@ -178,7 +178,7 @@ TEST_P(MiniTableTest, SizeOverflow) {
// A bit under max_double_fields is ok.
ASSERT_TRUE(e.StartMessage(0));
for (int i = 1; i < max_double_fields; i++) {
for (size_t i = 1; i < max_double_fields; i++) {
ASSERT_TRUE(e.PutField(kUpb_FieldType_Double, i, 0));
}
upb::Status status;
@ -188,7 +188,7 @@ TEST_P(MiniTableTest, SizeOverflow) {
// A bit over max_double_fields fails.
ASSERT_TRUE(e.StartMessage(0));
for (int i = 1; i < max_double_fields + 2; i++) {
for (size_t i = 1; i < max_double_fields + 2; i++) {
ASSERT_TRUE(e.PutField(kUpb_FieldType_Double, i, 0));
}
upb_MiniTable* table2 = upb_MiniTable_Build(

Loading…
Cancel
Save