From f107f116d93dc9b6f5e3759b093b8f9f7884f03b Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 5 Jul 2018 09:31:40 +0200 Subject: [PATCH] Fix compiler warnings [-Wconditional-uninitialized] clang warnings: src/ccstruct/coutln.cpp:231:15: warning: variable 'destindex' may be uninitialized when used here [-Wconditional-uninitialized] src/wordrec/language_model.cpp:1170:27: warning: variable 'expected_gap' may be uninitialized when used here [-Wconditional-uninitialized] Signed-off-by: Stefan Weil --- src/ccstruct/coutln.cpp | 8 ++++---- src/wordrec/language_model.cpp | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ccstruct/coutln.cpp b/src/ccstruct/coutln.cpp index fb4ccbbc43..a1dea5d06a 100644 --- a/src/ccstruct/coutln.cpp +++ b/src/ccstruct/coutln.cpp @@ -141,14 +141,14 @@ int16_t length //length of loop */ C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(nullptr) { - TBOX new_box; //easy bounding - int16_t stepindex; //index to step - int16_t dirdiff; //direction change + TBOX new_box; //easy bounding + int16_t stepindex; //index to step + int16_t dirdiff; //direction change ICOORD pos; //current position ICOORD prevpos; //previous dest point ICOORD destpos; //destination point - int16_t destindex; //index to step + int16_t destindex = INT16_MAX; //index to step DIR128 dir; //coded direction uint8_t new_step; diff --git a/src/wordrec/language_model.cpp b/src/wordrec/language_model.cpp index b0ee4c3829..2a08e8c6f4 100644 --- a/src/wordrec/language_model.cpp +++ b/src/wordrec/language_model.cpp @@ -1127,7 +1127,7 @@ void LanguageModel::FillConsistencyInfo( } if (!word_res->blob_widths.empty()) { // if we have widths/gaps info bool expected_gap_found = false; - float expected_gap; + float expected_gap = 0.0f; int temp_gap; if (fontinfo_id >= 0) { // found a common font ASSERT_HOST(fontinfo_id < fontinfo_table_->size()); @@ -1140,7 +1140,6 @@ void LanguageModel::FillConsistencyInfo( consistency_info->inconsistent_font = true; // Get an average of the expected gaps in each font int num_addends = 0; - expected_gap = 0; int temp_fid; for (int i = 0; i < 4; ++i) { if (i == 0) { @@ -1159,9 +1158,9 @@ void LanguageModel::FillConsistencyInfo( num_addends++; } } - expected_gap_found = (num_addends > 0); if (num_addends > 0) { expected_gap /= static_cast(num_addends); + expected_gap_found = true; } } if (expected_gap_found) {