diff --git a/src/ccstruct/seam.cpp b/src/ccstruct/seam.cpp index 6d7edbe0..431c0bc3 100644 --- a/src/ccstruct/seam.cpp +++ b/src/ccstruct/seam.cpp @@ -61,7 +61,7 @@ bool SEAM::PrepareToInsertSeam(const std::vector &seams, if (!FindBlobWidth(blobs, insert_index, modify)) { return false; } - for (int s = insert_index; s < seams.size(); ++s) { + for (unsigned s = insert_index; s < seams.size(); ++s) { if (!seams[s]->FindBlobWidth(blobs, s + 1, modify)) { return false; } @@ -81,7 +81,7 @@ bool SEAM::FindBlobWidth(const std::vector &blobs, int index, bool modi const SPLIT &split = splits_[s]; bool found_split = split.ContainedByBlob(*blobs[index]); // Look right. - for (int b = index + 1; !found_split && b < blobs.size(); ++b) { + for (unsigned b = index + 1; !found_split && b < blobs.size(); ++b) { found_split = split.ContainedByBlob(*blobs[b]); if (found_split && b - index > widthp_ && modify) { widthp_ = b - index; @@ -158,8 +158,8 @@ void SEAM::Print(const char *label) const { void SEAM::PrintSeams(const char *label, const std::vector &seams) { if (!seams.empty()) { tprintf("%s\n", label); - for (int x = 0; x < seams.size(); ++x) { - tprintf("%2d: ", x); + for (unsigned x = 0; x < seams.size(); ++x) { + tprintf("%2u: ", x); seams[x]->Print(""); } tprintf("\n"); diff --git a/unittest/lang_model_test.cc b/unittest/lang_model_test.cc index e3c3796b..e0d96abc 100644 --- a/unittest/lang_model_test.cc +++ b/unittest/lang_model_test.cc @@ -101,7 +101,7 @@ TEST(LangModelTest, AddACharacter) { int null2 = trainer2.null_char(); EXPECT_EQ(null1 + 1, null2); std::vector labels1_v(labels1.size()); - for (int i = 0; i < labels1.size(); ++i) { + for (unsigned i = 0; i < labels1.size(); ++i) { if (labels1[i] == null1) { labels1_v[i] = null2; } else { @@ -186,7 +186,7 @@ TEST(LangModelTest, AddACharacterHindi) { int null2 = trainer2.null_char(); EXPECT_EQ(null1 + 1, null2); std::vector labels1_v(labels1.size()); - for (int i = 0; i < labels1.size(); ++i) { + for (unsigned i = 0; i < labels1.size(); ++i) { if (labels1[i] == null1) { labels1_v[i] = null2; } else { diff --git a/unittest/lstmtrainer_test.cc b/unittest/lstmtrainer_test.cc index 6b9bbd7b..c9709437 100644 --- a/unittest/lstmtrainer_test.cc +++ b/unittest/lstmtrainer_test.cc @@ -48,7 +48,7 @@ TEST_F(LSTMTrainerTest, MapCoder) { std::vector mapping = fra_trainer.MapRecoder(deu_trainer.GetUnicharset(), deu_trainer.GetRecoder()); std::vector mapped_fra_labels(fra_labels.size(), -1); - for (int i = 0; i < fra_labels.size(); ++i) { + for (unsigned i = 0; i < fra_labels.size(); ++i) { mapped_fra_labels[i] = mapping[fra_labels[i]]; EXPECT_NE(-1, mapped_fra_labels[i]) << "i=" << i << ", ch=" << kTestStr[i]; EXPECT_EQ(mapped_fra_labels[i], deu_labels[i]) diff --git a/unittest/recodebeam_test.cc b/unittest/recodebeam_test.cc index 6027821c..cda970b4 100644 --- a/unittest/recodebeam_test.cc +++ b/unittest/recodebeam_test.cc @@ -126,9 +126,9 @@ protected: // Now decode using recoder_. std::string decoded; int end = 1; - for (int start = 0; start < labels.size(); start = end) { + for (unsigned start = 0; start < labels.size(); start = end) { RecodedCharID code; - int index = start; + unsigned index = start; int uni_id = INVALID_UNICHAR_ID; do { code.Set(code.length(), labels[index++]); @@ -153,7 +153,7 @@ protected: &ratings, &xcoords); std::string u_decoded; float total_rating = 0.0f; - for (int u = 0; u < unichar_ids.size(); ++u) { + for (unsigned u = 0; u < unichar_ids.size(); ++u) { // To the extent of truth_utf8, we expect decoded to match, but if // transcription is shorter, that is OK too, as we may just be testing // that we get a valid sequence when padded with random data. diff --git a/unittest/tablerecog_test.cc b/unittest/tablerecog_test.cc index 2364e884..3556f9bc 100644 --- a/unittest/tablerecog_test.cc +++ b/unittest/tablerecog_test.cc @@ -51,14 +51,14 @@ public: EXPECT_EQ(3 + (almost_done - second) / add, cell_x_.size()); EXPECT_EQ(x_min, cell_x_.at(0)); EXPECT_EQ(x_max, cell_x_.at(cell_x_.size() - 1)); - for (int i = 1; i < cell_x_.size() - 1; ++i) { + for (unsigned i = 1; i < cell_x_.size() - 1; ++i) { EXPECT_EQ(second + add * (i - 1), cell_x_.at(i)); } } void ExpectSortedX() { EXPECT_GT(cell_x_.size(), 0); - for (int i = 1; i < cell_x_.size(); ++i) { + for (unsigned i = 1; i < cell_x_.size(); ++i) { EXPECT_LT(cell_x_.at(i - 1), cell_x_.at(i)); } } diff --git a/unittest/tfile_test.cc b/unittest/tfile_test.cc index 162d0b46..aeb77744 100644 --- a/unittest/tfile_test.cc +++ b/unittest/tfile_test.cc @@ -44,11 +44,11 @@ protected: void ExpectEq(const MathData &other) { // Check the data. EXPECT_EQ(num_squares_, other.num_squares_); - for (int s = 0; s < squares_.size(); ++s) { + for (unsigned s = 0; s < squares_.size(); ++s) { EXPECT_EQ(squares_[s], other.squares_[s]); } EXPECT_EQ(num_triangles_, other.num_triangles_); - for (int s = 0; s < triangles_.size(); ++s) { + for (unsigned s = 0; s < triangles_.size(); ++s) { EXPECT_EQ(triangles_[s], other.triangles_[s]); } }