From ae93b65b1f189a6084c3496db8e370a8e9888fb3 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 8 Oct 2018 13:47:16 +0200 Subject: [PATCH 1/6] Plumbing: Remove comparison which is always false Warning from LGTM: Comparison is always false because index >= 0. Signed-off-by: Stefan Weil --- src/lstm/plumbing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lstm/plumbing.cpp b/src/lstm/plumbing.cpp index be716aa0a..7fbf802f8 100644 --- a/src/lstm/plumbing.cpp +++ b/src/lstm/plumbing.cpp @@ -174,7 +174,7 @@ float* Plumbing::LayerLearningRatePtr(const char* id) const { ASSERT_HOST(*next_id == ':'); return plumbing->LayerLearningRatePtr(next_id + 1); } - if (index < 0 || index >= learning_rates_.size()) return nullptr; + if (index >= learning_rates_.size()) return nullptr; return &learning_rates_[index]; } From 7b5955920dcf10d5ea18074530e545e4b0382a3d Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 8 Oct 2018 13:49:59 +0200 Subject: [PATCH 2/6] pgedit: remove unused declaration of display_bln_lines This fixes a warning from LGTM: This parameter of type ScrollView is 144 bytes - consider passing a pointer/reference instead. Signed-off-by: Stefan Weil --- src/ccmain/pgedit.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/ccmain/pgedit.h b/src/ccmain/pgedit.h index 987eebe9e..6a8f48f7f 100644 --- a/src/ccmain/pgedit.h +++ b/src/ccmain/pgedit.h @@ -69,13 +69,6 @@ extern double_VAR_H (editor_smd_scale_factor, 1.0, "Scaling for smd image"); ScrollView* bln_word_window_handle(); //return handle void build_image_window(int width, int height); -void display_bln_lines(ScrollView window, - ScrollView::Color colour, - float scale_factor, - float y_offset, - float minx, - float maxx); - //function to call void pgeditor_msg( //message display const char *msg); void pgeditor_show_point( //display coords From 3ae765ecca6bc4f5c97901002952efc9c80bce9c Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 8 Oct 2018 13:53:09 +0200 Subject: [PATCH 3/6] svpaint: Change a variable from global to local This fixes a warning from LGTM: Poor global variable name 'rgb'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). Signed-off-by: Stefan Weil --- src/viewer/svpaint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/viewer/svpaint.cpp b/src/viewer/svpaint.cpp index 5ae6ea841..515ebf990 100644 --- a/src/viewer/svpaint.cpp +++ b/src/viewer/svpaint.cpp @@ -32,7 +32,7 @@ #include // The current color values we use, initially white (== ScrollView::WHITE). -int rgb[3] = { 255, 255, 255 }; +static int rgb[3] = { 255, 255, 255 }; class SVPaint : public SVEventHandler { public: From 30b75cfc0580286eef628812bdd4f5b217278eaa Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 8 Oct 2018 14:15:17 +0200 Subject: [PATCH 4/6] UNICHARMAP: Remove comparison which is always false Warning from LGTM: Comparison is always false because index <= 0 and 1 <= length. Signed-off-by: Stefan Weil --- src/ccutil/unicharmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ccutil/unicharmap.cpp b/src/ccutil/unicharmap.cpp index 236f6b72e..4f7b266f4 100644 --- a/src/ccutil/unicharmap.cpp +++ b/src/ccutil/unicharmap.cpp @@ -83,7 +83,7 @@ bool UNICHARMAP::contains(const char* const unichar_repr, if (unichar_repr == nullptr || *unichar_repr == '\0') return false; if (length <= 0 || length > UNICHAR_LEN) return false; int index = 0; - if (index >= length || unichar_repr[index] == '\0') return false; + if (unichar_repr[index] == '\0') return false; UNICHARMAP_NODE* current_nodes = nodes; while (current_nodes != nullptr && index + 1 < length && From 9c857ab96287bf26f997373a781a5a0f4b0a7d94 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 8 Oct 2018 14:22:31 +0200 Subject: [PATCH 5/6] Classify: Don't hide debug parameter Fix a warning from LGTM: Local variable 'debug' hides a parameter of the same name. Signed-off-by: Stefan Weil --- src/classify/adaptmatch.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classify/adaptmatch.cpp b/src/classify/adaptmatch.cpp index 5c78baf23..9794289c2 100644 --- a/src/classify/adaptmatch.cpp +++ b/src/classify/adaptmatch.cpp @@ -1115,8 +1115,8 @@ void Classify::MasterMatcher(INT_TEMPLATES templates, num_features, features, &int_result, classify_adapt_feature_threshold, debug, matcher_debug_separate_windows); - bool debug = matcher_debug_level >= 2 || classify_debug_level > 1; - ExpandShapesAndApplyCorrections(classes, debug, class_id, bottom, top, + bool is_debug = matcher_debug_level >= 2 || classify_debug_level > 1; + ExpandShapesAndApplyCorrections(classes, is_debug, class_id, bottom, top, results[c].Rating, final_results->BlobLength, matcher_multiplier, norm_factors, From 1eeca175f785139db31ecccb604f3279e232261f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 8 Oct 2018 14:25:05 +0200 Subject: [PATCH 6/6] SVPaint: Remove empty block This fixes a warning from LGTM: Empty block without comment Signed-off-by: Stefan Weil --- src/viewer/svpaint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/viewer/svpaint.cpp b/src/viewer/svpaint.cpp index 515ebf990..105f6114a 100644 --- a/src/viewer/svpaint.cpp +++ b/src/viewer/svpaint.cpp @@ -171,7 +171,7 @@ void SVPaint::Notify(const SVEvent* sv_event) { else if (sv_event->type == SVET_SELECTION) { SelectionHandler(sv_event); } else if (sv_event->type == SVET_MENU) { MenuBarHandler(sv_event); } else if (sv_event->type == SVET_POPUP) { PopupHandler(sv_event); } - else {} //throw other events away + //throw other events away } // Builds a new window, initializes the variables and event handler and builds