Skip to content

Commit f107f11

Browse files
committed
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 <[email protected]>
1 parent a74d467 commit f107f11

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/ccstruct/coutln.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ int16_t length //length of loop
141141
*/
142142

143143
C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(nullptr) {
144-
TBOX new_box; //easy bounding
145-
int16_t stepindex; //index to step
146-
int16_t dirdiff; //direction change
144+
TBOX new_box; //easy bounding
145+
int16_t stepindex; //index to step
146+
int16_t dirdiff; //direction change
147147
ICOORD pos; //current position
148148
ICOORD prevpos; //previous dest point
149149

150150
ICOORD destpos; //destination point
151-
int16_t destindex; //index to step
151+
int16_t destindex = INT16_MAX; //index to step
152152
DIR128 dir; //coded direction
153153
uint8_t new_step;
154154

src/wordrec/language_model.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ void LanguageModel::FillConsistencyInfo(
11271127
}
11281128
if (!word_res->blob_widths.empty()) { // if we have widths/gaps info
11291129
bool expected_gap_found = false;
1130-
float expected_gap;
1130+
float expected_gap = 0.0f;
11311131
int temp_gap;
11321132
if (fontinfo_id >= 0) { // found a common font
11331133
ASSERT_HOST(fontinfo_id < fontinfo_table_->size());
@@ -1140,7 +1140,6 @@ void LanguageModel::FillConsistencyInfo(
11401140
consistency_info->inconsistent_font = true;
11411141
// Get an average of the expected gaps in each font
11421142
int num_addends = 0;
1143-
expected_gap = 0;
11441143
int temp_fid;
11451144
for (int i = 0; i < 4; ++i) {
11461145
if (i == 0) {
@@ -1159,9 +1158,9 @@ void LanguageModel::FillConsistencyInfo(
11591158
num_addends++;
11601159
}
11611160
}
1162-
expected_gap_found = (num_addends > 0);
11631161
if (num_addends > 0) {
11641162
expected_gap /= static_cast<float>(num_addends);
1163+
expected_gap_found = true;
11651164
}
11661165
}
11671166
if (expected_gap_found) {

0 commit comments

Comments
 (0)