From 24dd72603b2a3635e75a51830bf5f5830dbd34ad Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 12 May 2024 18:31:00 +0200 Subject: [PATCH] Fix compiler warnings [-Wunreachable-code-return] Signed-off-by: Stefan Weil --- src/training/common/networkbuilder.cpp | 1 - src/wordrec/chopper.cpp | 2 +- unittest/applybox_test.cc | 1 - unittest/baseapi_test.cc | 5 ----- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/training/common/networkbuilder.cpp b/src/training/common/networkbuilder.cpp index 5c381ca9..5a0d9171 100644 --- a/src/training/common/networkbuilder.cpp +++ b/src/training/common/networkbuilder.cpp @@ -114,7 +114,6 @@ Network *NetworkBuilder::BuildFromString(const StaticShape &input_shape, const c return ParseOutput(input_shape, str); default: tprintf("Invalid network spec:%s\n", *str); - return nullptr; } return nullptr; } diff --git a/src/wordrec/chopper.cpp b/src/wordrec/chopper.cpp index 195af68e..09a2333e 100644 --- a/src/wordrec/chopper.cpp +++ b/src/wordrec/chopper.cpp @@ -344,7 +344,7 @@ SEAM *Wordrec::improve_one_blob(const std::vector &blob_choices, // TODO(rays) it may eventually help to allow italic_blob to be true, seam = chop_numbered_blob(word->chopped_word, *blob_number, italic_blob, word->seam_array); if (seam != nullptr) { - return seam; // Success! + break; // Success! } if (blob_choices[*blob_number] == nullptr) { return nullptr; diff --git a/unittest/applybox_test.cc b/unittest/applybox_test.cc index cf745667..80d80470 100644 --- a/unittest/applybox_test.cc +++ b/unittest/applybox_test.cc @@ -64,7 +64,6 @@ protected: if (!SetImage(imagefile)) { // eng.traineddata not found or other problem during Init. GTEST_SKIP(); - return; } if (line_mode) { api_.SetVariable("tessedit_resegment_from_line_boxes", "1"); diff --git a/unittest/baseapi_test.cc b/unittest/baseapi_test.cc index 7c70b13d..4808fb3b 100644 --- a/unittest/baseapi_test.cc +++ b/unittest/baseapi_test.cc @@ -124,7 +124,6 @@ TEST_F(TesseractTest, HOCRWorksWithoutSetInputName) { if (api.Init(TessdataPath().c_str(), "eng", tesseract::OEM_TESSERACT_ONLY) == -1) { // eng.traineddata not found. GTEST_SKIP(); - return; } Image src_pix = pixRead(TestDataNameToPath("HelloGoogle.tif").c_str()); CHECK(src_pix); @@ -143,7 +142,6 @@ TEST_F(TesseractTest, HOCRContainsBaseline) { if (api.Init(TessdataPath().c_str(), "eng", tesseract::OEM_TESSERACT_ONLY) == -1) { // eng.traineddata not found. GTEST_SKIP(); - return; } Image src_pix = pixRead(TestDataNameToPath("HelloGoogle.tif").c_str()); CHECK(src_pix); @@ -179,7 +177,6 @@ TEST_F(TesseractTest, AdaptToWordStrTest) { if (api.Init(TessdataPath().c_str(), "eng", tesseract::OEM_TESSERACT_ONLY) == -1) { // eng.traineddata not found. GTEST_SKIP(); - return; } api.SetVariable("matcher_sufficient_examples_for_prototyping", "1"); api.SetVariable("classify_class_pruner_threshold", "220"); @@ -215,7 +212,6 @@ TEST_F(TesseractTest, BasicLSTMTest) { if (api.Init(TessdataPath().c_str(), "eng", tesseract::OEM_LSTM_ONLY) == -1) { // eng.traineddata not found. GTEST_SKIP(); - return; } Image src_pix = pixRead(TestDataNameToPath("phototest_2.tif").c_str()); CHECK(src_pix); @@ -239,7 +235,6 @@ TEST_F(TesseractTest, LSTMGeometryTest) { if (api.Init(TessdataPath().c_str(), "eng", tesseract::OEM_LSTM_ONLY) == -1) { // eng.traineddata not found. GTEST_SKIP(); - return; } api.SetImage(src_pix); ASSERT_EQ(api.Recognize(nullptr), 0);