diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 7cd84babe07..13e20d15745 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -5770,7 +5770,7 @@ int CLI::run(int argc, char **argv) gcode_viewer.render_calibration_thumbnail(*calibration_data, cali_thumbnail_width, cali_thumbnail_height, calibration_params, partplate_list, opengl_mgr); //generate_calibration_thumbnail(*calibration_data, thumbnail_width, thumbnail_height, calibration_params); - //*plate_bboxes[index] = p->generate_first_layer_bbox(); + //plate_bboxes[index] = p->generate_first_layer_bbox(); calibration_thumbnails.push_back(calibration_data);*/ PlateBBoxData* plate_bbox = new PlateBBoxData(); diff --git a/src/admesh/stlinit.cpp b/src/admesh/stlinit.cpp index 8196bf10cbc..b7df2815d66 100644 --- a/src/admesh/stlinit.cpp +++ b/src/admesh/stlinit.cpp @@ -65,7 +65,7 @@ static FILE *stl_open_count_facets(stl_file *stl, const char *file, unsigned int unsigned char chtest[128]; if (! fread(chtest, sizeof(chtest), 1, fp)) { BOOST_LOG_TRIVIAL(error) << "stl_open_count_facets: The input is an empty file: " << file; - fclose(fp); + [[maybe_unused]] int ret = fclose(fp); return nullptr; } stl->stats.type = ascii; @@ -85,7 +85,7 @@ static FILE *stl_open_count_facets(stl_file *stl, const char *file, unsigned int // Test if the STL file has the right size. if (((file_size - header_size) % SIZEOF_STL_FACET != 0) || (file_size < STL_MIN_FILE_SIZE)) { BOOST_LOG_TRIVIAL(error) << "stl_open_count_facets: The file " << file << " has the wrong size."; - fclose(fp); + [[maybe_unused]] int ret = fclose(fp); return nullptr; } num_facets = (file_size - header_size) / SIZEOF_STL_FACET; @@ -115,7 +115,6 @@ static FILE *stl_open_count_facets(stl_file *stl, const char *file, unsigned int // do another null check to be safe if (fp == nullptr) { BOOST_LOG_TRIVIAL(error) << "stl_open_count_facets: Couldn't open " << file << " for reading"; - fclose(fp); return nullptr; } @@ -225,32 +224,35 @@ static bool stl_read(stl_file *stl, FILE *fp, int first_facet, bool first, Impor stl_internal_reverse_quads((char*)&facet, 48); #endif /* BOOST_ENDIAN_BIG_BYTE */ } else { + int ret = 0; + char *cret = nullptr; + // Read a single facet from an ASCII .STL file // skip solid/endsolid // (in this order, otherwise it won't work when they are paired in the middle of a file) - fscanf(fp, " endsolid%*[^\n]\n"); - fscanf(fp, " solid%*[^\n]\n"); // name might contain spaces so %*s doesn't work and it also can be empty (just "solid") + ret = fscanf(fp, " endsolid%*[^\n]\n"); + ret = fscanf(fp, " solid%*[^\n]\n"); // name might contain spaces so %*s doesn't work and it also can be empty (just "solid") // Leading space in the fscanf format skips all leading white spaces including numerous new lines and tabs. - int res_normal = fscanf(fp, " facet normal %31s %31s %31s", normal_buf[0], normal_buf[1], normal_buf[2]); + [[maybe_unused]] int res_normal = fscanf(fp, " facet normal %31s %31s %31s", normal_buf[0], normal_buf[1], normal_buf[2]); assert(res_normal == 3); - int res_outer_loop = fscanf(fp, " outer loop"); + [[maybe_unused]]int res_outer_loop = fscanf(fp, " outer loop"); assert(res_outer_loop == 0); - int res_vertex1 = fscanf(fp, " vertex %f %f %f", &facet.vertex[0](0), &facet.vertex[0](1), &facet.vertex[0](2)); + [[maybe_unused]] int res_vertex1 = fscanf(fp, " vertex %f %f %f", &facet.vertex[0](0), &facet.vertex[0](1), &facet.vertex[0](2)); assert(res_vertex1 == 3); - int res_vertex2 = fscanf(fp, " vertex %f %f %f", &facet.vertex[1](0), &facet.vertex[1](1), &facet.vertex[1](2)); + [[maybe_unused]] int res_vertex2 = fscanf(fp, " vertex %f %f %f", &facet.vertex[1](0), &facet.vertex[1](1), &facet.vertex[1](2)); assert(res_vertex2 == 3); // Trailing whitespace is there to eat all whitespaces and empty lines up to the next non-whitespace. - int res_vertex3 = fscanf(fp, " vertex %f %f %f ", &facet.vertex[2](0), &facet.vertex[2](1), &facet.vertex[2](2)); + [[maybe_unused]] int res_vertex3 = fscanf(fp, " vertex %f %f %f ", &facet.vertex[2](0), &facet.vertex[2](1), &facet.vertex[2](2)); assert(res_vertex3 == 3); // Some G-code generators tend to produce text after "endloop" and "endfacet". Just ignore it. char buf[2048]; - fgets(buf, 2047, fp); - bool endloop_ok = strncmp(buf, "endloop", 7) == 0 && (buf[7] == '\r' || buf[7] == '\n' || buf[7] == ' ' || buf[7] == '\t'); + cret = fgets(buf, 2047, fp); + [[maybe_unused]] bool endloop_ok = strncmp(buf, "endloop", 7) == 0 && (buf[7] == '\r' || buf[7] == '\n' || buf[7] == ' ' || buf[7] == '\t'); assert(endloop_ok); // Skip the trailing whitespaces and empty lines. - fscanf(fp, " "); - fgets(buf, 2047, fp); - bool endfacet_ok = strncmp(buf, "endfacet", 8) == 0 && (buf[8] == '\r' || buf[8] == '\n' || buf[8] == ' ' || buf[8] == '\t'); + ret = fscanf(fp, " "); + cret = fgets(buf, 2047, fp); + [[maybe_unused]] bool endfacet_ok = strncmp(buf, "endfacet", 8) == 0 && (buf[8] == '\r' || buf[8] == '\n' || buf[8] == ' ' || buf[8] == '\t'); assert(endfacet_ok); if (res_normal != 3 || res_outer_loop != 0 || res_vertex1 != 3 || res_vertex2 != 3 || res_vertex3 != 3 || ! endloop_ok || ! endfacet_ok) { BOOST_LOG_TRIVIAL(error) << "Something is syntactically very wrong with this ASCII STL! "; @@ -314,8 +316,8 @@ bool stl_open(stl_file *stl, const char *file, ImportstlProgressFn stlFn, int cu if (fp == nullptr) return false; stl_allocate(stl); - bool result = stl_read(stl, fp, 0, true, stlFn, custom_header_length); - fclose(fp); + bool result = stl_read(stl, fp, 0, true, stlFn, custom_header_length); + [[maybe_unused]] int ret = fclose(fp); return result; } diff --git a/src/imgui/imgui_widgets.cpp b/src/imgui/imgui_widgets.cpp index 79d0638c1c2..dfd110b9358 100644 --- a/src/imgui/imgui_widgets.cpp +++ b/src/imgui/imgui_widgets.cpp @@ -268,7 +268,7 @@ void ImGui::Text(const char* fmt, ...) void ImGui::TextCentered(const char* text, ...) { va_list vaList; - va_start(vaList,&text); + va_start(vaList,text); float font_size = ImGui::GetFontSize() * strlen(text) / 2; ImGui::SameLine(ImGui::GetCursorPos().x / 2 - font_size + (font_size / 2)); @@ -6298,9 +6298,9 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl RenderFrameBorder(bb.Min, bb.Max, rounding); else #ifdef __APPLE__ - window->DrawList->AddRect(bb.Min - ImVec2(3, 3), bb.Max + ImVec2(3, 3), GetColorU32(ImGuiCol_FrameBg), rounding * 2,NULL,4.0f);; // Color button are often in need of some sort of border + window->DrawList->AddRect(bb.Min - ImVec2(3, 3), bb.Max + ImVec2(3, 3), GetColorU32(ImGuiCol_FrameBg), rounding * 2,0,4.0f);; // Color button are often in need of some sort of border #else - window->DrawList->AddRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2), GetColorU32(ImGuiCol_FrameBg), rounding * 2,NULL,3.0f); // Color button are often in need of some sort of border + window->DrawList->AddRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2), GetColorU32(ImGuiCol_FrameBg), rounding * 2,0,3.0f); // Color button are often in need of some sort of border #endif } diff --git a/src/imgui/imstb_truetype.h b/src/imgui/imstb_truetype.h index 17cbcbcfd5f..3e66d178e57 100644 --- a/src/imgui/imstb_truetype.h +++ b/src/imgui/imstb_truetype.h @@ -4528,7 +4528,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc float ax = x1-x0, ay = y1-y0; float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; float mx = x0 - sx, my = y0 - sy; - float res[3],px,py,t,it; + float res[3] = {},px,py,t,it; float a_inv = precompute[i]; if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula float a = 3*(ax*bx + ay*by); diff --git a/src/libslic3r/Algorithm/LineSplit.cpp b/src/libslic3r/Algorithm/LineSplit.cpp index 53ef00e0a50..d2e2ff53fd4 100644 --- a/src/libslic3r/Algorithm/LineSplit.cpp +++ b/src/libslic3r/Algorithm/LineSplit.cpp @@ -200,7 +200,7 @@ SplittedLine do_split_line(const ClipperZUtils::ZPath& path, const ExPolygons& c // Chain segment back to the original path ClipperZUtils::ZPoint& front = segment.front(); - const ClipperZUtils::ZPoint* previous_src_point; + const ClipperZUtils::ZPoint* previous_src_point = nullptr; if (is_src(front)) { // The segment starts with a point from src path, which means apart from the last point, // all other points on this segment should come from the src path or the clip polygon diff --git a/src/libslic3r/Brim.cpp b/src/libslic3r/Brim.cpp index e9fdd7921bd..e29f87cdaef 100644 --- a/src/libslic3r/Brim.cpp +++ b/src/libslic3r/Brim.cpp @@ -589,7 +589,7 @@ double getadhesionCoeff(const PrintObject* printObject) for (const ModelVolume* modelVolume : objectVolumes) { for (auto iter = extrudersFirstLayer.begin(); iter != extrudersFirstLayer.end(); iter++) if (modelVolume->extruder_id() == *iter) { - if (Model::extruderParamsMap.find(modelVolume->extruder_id()) != Model::extruderParamsMap.end()) + if (Model::extruderParamsMap.find(modelVolume->extruder_id()) != Model::extruderParamsMap.end()) { if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PETG" || Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PCTG") { adhesionCoeff = 2; @@ -597,6 +597,7 @@ double getadhesionCoeff(const PrintObject* printObject) else if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "TPU") { adhesionCoeff = 0.5; } + } } } diff --git a/src/libslic3r/ClipperUtils.cpp b/src/libslic3r/ClipperUtils.cpp index 7d893a3bf22..b67a023e43c 100644 --- a/src/libslic3r/ClipperUtils.cpp +++ b/src/libslic3r/ClipperUtils.cpp @@ -94,7 +94,7 @@ template inline void clip_clipper_polygon_with_subject_bbox_ } // Never produce just a single point output polygon. - if (!out.empty()) + if (!out.empty()) { if(get_entire_polygons){ out=src; }else{ @@ -106,6 +106,7 @@ template inline void clip_clipper_polygon_with_subject_bbox_ (sides_prev & sides_this & sides_next) == 0) out.emplace_back(src.back()); } + } } diff --git a/src/libslic3r/Color.cpp b/src/libslic3r/Color.cpp index 2f593538ac5..3178f857c47 100644 --- a/src/libslic3r/Color.cpp +++ b/src/libslic3r/Color.cpp @@ -257,7 +257,7 @@ ColorRGBA complementary(const ColorRGBA& color) ColorRGB saturate(const ColorRGB& color, float factor) { - float h, s, v; + float h = 0.0, s = 0.0, v = 0.0; RGBtoHSV(color.r(), color.g(), color.b(), h, s, v); s = std::clamp(s * factor, 0.0f, 1.0f); float r, g, b; diff --git a/src/libslic3r/Fill/FillConcentric.cpp b/src/libslic3r/Fill/FillConcentric.cpp index b5a0c738c9a..5399ccb9483 100644 --- a/src/libslic3r/Fill/FillConcentric.cpp +++ b/src/libslic3r/Fill/FillConcentric.cpp @@ -18,7 +18,8 @@ int stagger_seam_index(int ind, LINE_T line, double shift, bool dir) if (dir) ind = (ind + 1) % line.points.size(); else - ind = ind > 0 ? --ind : line.points.size() - 1; + ind = (ind > 0) ? (ind - 1) : (line.points.size() - 1); + Point const &next = line.points[ind]; dist += point->distance_to(next); point = &next; @@ -61,8 +62,8 @@ void FillConcentric::_fill_surface_single( size_t iPathFirst = polylines_out.size(); Point last_pos(0, 0); - double min_nozzle_diameter; - bool dir; + double min_nozzle_diameter = 0.0; + bool dir = false; if (this->print_config != nullptr && params.density >= STAGGER_SEAM_THRESHOLD) { min_nozzle_diameter = *std::min_element(print_config->nozzle_diameter.values.begin(), print_config->nozzle_diameter.values.end()); dir = rand() % 2; diff --git a/src/libslic3r/TriangleMeshSlicer.cpp b/src/libslic3r/TriangleMeshSlicer.cpp index c9a59e5b2ff..00b37ebdd5b 100644 --- a/src/libslic3r/TriangleMeshSlicer.cpp +++ b/src/libslic3r/TriangleMeshSlicer.cpp @@ -2474,7 +2474,7 @@ void cut_mesh(const indexed_triangle_set& mesh, float z, indexed_triangle_set* u // intersect v0-v1 and v2-v0 with cutting plane and make new vertices auto new_vertex = [upper, lower, &upper_slice_vertices, &lower_slice_vertices](const Vec3f &a, const int ia, const Vec3f &b, const int ib, const Vec3f &c, const int ic, const Vec3f &new_pt, bool &is_new_vertex) { - int iupper, ilower; + int iupper = 0, ilower = 0; is_new_vertex = false; if (is_equal(new_pt, a)) iupper = ilower = ia; diff --git a/src/mcut/source/shewchuk.c b/src/mcut/source/shewchuk.c index 3143e402343..a6c92218e1c 100644 --- a/src/mcut/source/shewchuk.c +++ b/src/mcut/source/shewchuk.c @@ -2770,7 +2770,7 @@ REAL permanent; REAL cxtaa[8], cxtbb[8], cytaa[8], cytbb[8]; int cxtaalen, cxtbblen, cytaalen, cytbblen; REAL axtbc[8], aytbc[8], bxtca[8], bytca[8], cxtab[8], cytab[8]; - int axtbclen, aytbclen, bxtcalen, bytcalen, cxtablen, cytablen; + int axtbclen = 0, aytbclen = 0, bxtcalen = 0, bytcalen = 0, cxtablen = 0, cytablen = 0; REAL axtbct[16], aytbct[16], bxtcat[16], bytcat[16], cxtabt[16], cytabt[16]; int axtbctlen, aytbctlen, bxtcatlen, bytcatlen, cxtabtlen, cytabtlen; REAL axtbctt[8], aytbctt[8], bxtcatt[8]; diff --git a/src/slic3r/GUI/ConnectPrinter.cpp b/src/slic3r/GUI/ConnectPrinter.cpp index 932c60bfd5a..93609ae9afd 100644 --- a/src/slic3r/GUI/ConnectPrinter.cpp +++ b/src/slic3r/GUI/ConnectPrinter.cpp @@ -160,7 +160,8 @@ void ConnectPrinterDialog::on_button_confirm(wxCommandEvent &event) { wxString code = m_textCtrl_code->GetTextCtrl()->GetValue(); for (char c : code) { - if (!('0' <= c && c <= '9' || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z')) { + //if (!((('0' <= c) && (c <= '9')) || (('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z')))) { + if(isalnum(c) == 0) { show_error(this, _L("Invalid input.")); return; } diff --git a/src/slic3r/GUI/EditGCodeDialog.cpp b/src/slic3r/GUI/EditGCodeDialog.cpp index 3e8548decde..e0927808ef2 100644 --- a/src/slic3r/GUI/EditGCodeDialog.cpp +++ b/src/slic3r/GUI/EditGCodeDialog.cpp @@ -254,9 +254,9 @@ wxDataViewItem EditGCodeDialog::add_presets_placeholders() const auto& full_config = wxGetApp().preset_bundle->full_config(); const auto& tab_list = wxGetApp().tabs_list; - Tab* tab_print; - Tab* tab_filament; - Tab* tab_printer; + Tab* tab_print = nullptr; + Tab* tab_filament = nullptr; + Tab* tab_printer = nullptr; for (const auto tab : tab_list) { if (tab->m_type == Preset::TYPE_PRINT) tab_print = tab; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index 5ee7bab7c84..487b3bd606f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -198,8 +198,8 @@ bool GLGizmoBrimEars::unproject_on_mesh2(const Vec2d &mouse_pos, std::pairobject_clipper()->get_position(); const ClippingPlane *clp = m_c->object_clipper()->get_clipping_plane(); bool mouse_on_object = false; - Vec3f position_on_model; - Vec3f normal_on_model; + Vec3f position_on_model {}; + Vec3f normal_on_model {}; double closest_hit_distance = std::numeric_limits::max(); for (auto item : m_mesh_raycaster_map) { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 68fc3deeeff..17ae75ee1a0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -1817,7 +1817,7 @@ void GLGizmoMeasure::show_selection_ui() return text; }; - float selection_cap_length; + float selection_cap_length = 0.0; if (m_measure_mode == EMeasureMode::ONLY_ASSEMBLY) { if (m_assembly_mode == AssemblyMode::FACE_FACE) { selection_cap_length = ImGui::CalcTextSize((_u8L("Selection") + " 1" + _u8L(" (Moving)")).c_str()).x * 1.2; diff --git a/src/slic3r/GUI/ObjColorDialog.cpp b/src/slic3r/GUI/ObjColorDialog.cpp index bf05b43195e..42381a669ac 100644 --- a/src/slic3r/GUI/ObjColorDialog.cpp +++ b/src/slic3r/GUI/ObjColorDialog.cpp @@ -640,7 +640,7 @@ void ObjColorPanel::draw_table() m_color_cluster_icon_list.clear(); m_extruder_icon_list.clear(); - float row_height ; + float row_height = 0.0; for (size_t ii = 0; ii < row; ii++) { wxPanel *row_panel = new wxPanel(m_scrolledWindow); row_panel->SetBackgroundColour(ii % 2 == 0 ? *wxWHITE : wxColour(238, 238, 238)); diff --git a/src/slic3r/GUI/PlateSettingsDialog.cpp b/src/slic3r/GUI/PlateSettingsDialog.cpp index 88f93917736..986b5dea170 100644 --- a/src/slic3r/GUI/PlateSettingsDialog.cpp +++ b/src/slic3r/GUI/PlateSettingsDialog.cpp @@ -54,8 +54,8 @@ LayerNumberTextInput::LayerNumberTextInput(wxWindow* parent, int layer_number, w // value should not be less than MIN_LAYER_VALUE, and should not be greater than MAX_LAYER_VALUE gui_value = std::clamp(gui_value, MIN_LAYER_VALUE, MAX_LAYER_VALUE); - int begin_value; - int end_value; + int begin_value = 0; + int end_value = 0; LayerNumberTextInput* end_layer_input = nullptr; if (this->m_type == Type::Begin) { begin_value = gui_value; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 5a68b1a45a5..041fcf1ab3e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3639,7 +3639,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ bool dlg_cont = true; bool is_user_cancel = false; bool translate_old = false; - int current_width, current_depth, current_height; + int current_width = 0, current_depth = 0, current_height = 0; if (input_files.empty()) { return std::vector(); } diff --git a/src/slic3r/GUI/calib_dlg.cpp b/src/slic3r/GUI/calib_dlg.cpp index 9dcd5ee7c84..a797e4246b0 100644 --- a/src/slic3r/GUI/calib_dlg.cpp +++ b/src/slic3r/GUI/calib_dlg.cpp @@ -374,7 +374,7 @@ void Temp_Calibration_Dlg::on_start(wxCommandEvent& event) { void Temp_Calibration_Dlg::on_filament_type_changed(wxCommandEvent& event) { int selection = event.GetSelection(); - unsigned long start,end; + unsigned long start = 0, end = 0; switch(selection) { case tABS_ASA: