Fix some compiler warnings

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-03-22 09:01:54 +01:00
parent fbaac9dc9d
commit 4530763329
6 changed files with 14 additions and 14 deletions

View File

@ -61,7 +61,7 @@ bool SEAM::PrepareToInsertSeam(const std::vector<SEAM *> &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<TBLOB *> &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<SEAM *> &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");

View File

@ -101,7 +101,7 @@ TEST(LangModelTest, AddACharacter) {
int null2 = trainer2.null_char();
EXPECT_EQ(null1 + 1, null2);
std::vector<int> 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<int> 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 {

View File

@ -48,7 +48,7 @@ TEST_F(LSTMTrainerTest, MapCoder) {
std::vector<int> mapping =
fra_trainer.MapRecoder(deu_trainer.GetUnicharset(), deu_trainer.GetRecoder());
std::vector<int> 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])

View File

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

View File

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

View File

@ -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]);
}
}