From 673a2bdac8e9874f3fbec15d2568b5cf69018c45 Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Wed, 25 Aug 2021 18:25:37 +0200 Subject: [PATCH] Fix: ../src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp:109:23: warning: comparison of integer expressions of different signedness: 'std::basic_string::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare] ../src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp:132:17: warning: format string is not a string literal (potentially insecure) [-Wformat-security] ../src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp:171:17: warning: format string is not a string literal (potentially insecure) [-Wformat-security] Severity Code Description Project File Line Suppression State Warning C26451 Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). libslic3r_gui C:\GIT\slic3r\src\slic3r\GUI\Gizmos\GLGizmoSimplify.cpp 143 --- src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp | 22 +++++++++++----------- src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index 3530b4240..5ce0064db 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -129,7 +129,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi } ImGui::SameLine(); m_imgui->disabled_begin(m_configuration.use_count); - ImGui::Text(tr_detail_level.c_str()); + ImGui::Text("%s", tr_detail_level.c_str()); std::vector reduce_captions = { static_cast(_u8L("Extra high")), static_cast(_u8L("High")), @@ -139,17 +139,17 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi }; ImGui::SameLine(m_gui_cfg->bottom_left_width); ImGui::SetNextItemWidth(m_gui_cfg->input_width); - static int reduction = 3; - if(ImGui::SliderInt("##ReductionLevel", &reduction, 1, 5, reduce_captions[reduction-1].c_str())) { + static int reduction = 2; + if(ImGui::SliderInt("##ReductionLevel", &reduction, 0, 4, reduce_captions[reduction].c_str())) { m_is_valid_result = false; - if (reduction < 1) reduction = 1; - if (reduction > 5) reduction = 5; + if (reduction < 0) reduction = 0; + if (reduction > 4) reduction = 4; switch (reduction) { - case 1: m_configuration.max_error = 1e-3f; break; - case 2: m_configuration.max_error = 1e-2f; break; - case 3: m_configuration.max_error = 0.1f; break; - case 4: m_configuration.max_error = 0.5f; break; - case 5: m_configuration.max_error = 1.f; break; + case 0: m_configuration.max_error = 1e-3f; break; + case 1: m_configuration.max_error = 1e-2f; break; + case 2: m_configuration.max_error = 0.1f; break; + case 3: m_configuration.max_error = 0.5f; break; + case 4: m_configuration.max_error = 1.f; break; } } m_imgui->disabled_end(); // !use_count @@ -168,7 +168,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi } m_imgui->disabled_begin(!m_configuration.use_count); - ImGui::Text(tr_decimate_ratio.c_str()); + ImGui::Text("%s", tr_decimate_ratio.c_str()); ImGui::SameLine(m_gui_cfg->bottom_left_width); ImGui::SetNextItemWidth(m_gui_cfg->input_width); const char * format = (m_configuration.decimate_ratio > 10)? "%.0f %%": diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp index 9af6686bd..04d4b99ab 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp @@ -87,7 +87,7 @@ private: int window_padding = 0; // trunc model name when longer - int max_char_in_name = 30; + size_t max_char_in_name = 30; }; std::optional m_gui_cfg;