From 0c4897e677c593cfda9ad0064eb495e638d12048 Mon Sep 17 00:00:00 2001 From: Hanif Koh Date: Mon, 12 Oct 2026 03:17:14 +0800 Subject: [PATCH] Gate PRs on the Quiet bugprone Checks Only Keep the six checks that report almost nothing on correct code and clear their remaining hits: drop redundant branch conditions, forward a forwarding reference, mark deliberate discards with (void), and explain the pointer-ordered sets whose order does not matter. Allow (void) to mark a discarded result. --- .clang-tidy | 19 +++++++------------ src/libslic3r/GCode.cpp | 3 +-- src/libslic3r/Polyline.hpp | 2 +- src/libslic3r/PresetBundle.cpp | 2 ++ src/slic3r/GUI/GUI_App.cpp | 16 +++++----------- tests/libslic3r/test_utils.cpp | 4 ++-- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 5cb3aa3b37..7151de5c61 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,31 +7,26 @@ # they reach every file that includes the header, and a using-declaration also # makes the header look like the one to include for that name. Qualify the name # in the header, and put the using in the source files that want it. -# Likely bugs: a use after std::move, an RAII object or a return value thrown -# away, an integer stored as a character in a string, slicing, and similar -# mistakes these checks rarely report on correct code. +# Likely bugs: an RAII object or a return value thrown away, an integer stored +# as a character in a string, std::move on a forwarding reference, iteration +# whose order depends on pointer values, and a condition already known true. # Every check listed here gates pull requests, so enable a new one only once the # code it flags on touched lines is reasonable to fix in passing. Checks: >- -*, misc-include-cleaner, google-global-names-in-headers, - bugprone-copy-constructor-init, - bugprone-misplaced-widening-cast, bugprone-move-forwarding-reference, bugprone-nondeterministic-pointer-iteration-order, bugprone-redundant-branch-condition, bugprone-string-integer-assignment, - bugprone-suspicious-semicolon, - bugprone-unhandled-self-assignment, - bugprone-unused-local-non-trivial-variable, bugprone-unused-raii, - bugprone-unused-return-value, - bugprone-use-after-move, - cppcoreguidelines-slicing, - misc-redundant-expression + bugprone-unused-return-value WarningsAsErrors: '*' CheckOptions: + # (void) marks a result dropped on purpose, such as a deliberate leak through + # unique_ptr::release(). + bugprone-unused-return-value.AllowCastToVoid: true # The default list without boost::system::error_code: Boost.Asio's overloads # that take an error_code& also return it, and callers check the argument. bugprone-unused-return-value.CheckedReturnTypes: '^::std::error_code$;^::std::error_condition$;^::std::errc$;^::std::expected$' diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index cab75d5034..c4b6d23d28 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -6865,8 +6865,7 @@ LayerResult GCode::process_layer( } #endif - if (support_dontcare) - support_extruder = dontcare_extruder; + support_extruder = dontcare_extruder; } else if (support_dontcare || interface_dontcare) { // Some support will be printed with "don't care" material, preferably non-soluble. diff --git a/src/libslic3r/Polyline.hpp b/src/libslic3r/Polyline.hpp index 29c795db33..d3249c5b6f 100644 --- a/src/libslic3r/Polyline.hpp +++ b/src/libslic3r/Polyline.hpp @@ -248,7 +248,7 @@ inline void polylines_merge(PointsType &dst, bool dst_first, PointsType &&src, b } else if (! src_first) std::reverse(src.begin(), src.end()); // Merge src into dst. - append(dst, std::move(src)); + append(dst, std::forward(src)); } const Point& leftmost_point(const Polylines &polylines); diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 8215cb3aef..f2bc52edea 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -3386,6 +3386,7 @@ void PresetBundle::load_installed_filaments(AppConfig &config) // compatible_filaments.insert(&filament); } // and mark these filaments as installed, therefore this code will not be executed at the next start of the application. + // NOLINTNEXTLINE(bugprone-nondeterministic-pointer-iteration-order) - each is set by name, so only the log order varies for (const auto &filament: compatible_filaments) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": set filament %1% to visible by default")%filament->name; config.set(AppConfig::SECTION_FILAMENTS, filament->name, "true"); @@ -3412,6 +3413,7 @@ void PresetBundle::load_installed_sla_materials(AppConfig &config) comp_sla_materials.insert(&material); } // and mark these SLA materials as installed, therefore this code will not be executed at the next start of the application. + // NOLINTNEXTLINE(bugprone-nondeterministic-pointer-iteration-order) - each is set by name, so the order does not matter for (const auto &material: comp_sla_materials) config.set(AppConfig::SECTION_MATERIALS, material->name, "true"); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 8940e13e6e..2ab4d8b329 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3953,9 +3953,7 @@ bool GUI_App::on_init_network(bool try_backup) if (!bambu_source) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": can not get bambu source module!"; m_networking_compatible = false; - if (should_load_networking_plugin) { - m_networking_need_update = true; - } + m_networking_need_update = true; } } else { if (try_backup) { @@ -3966,9 +3964,7 @@ bool GUI_App::on_init_network(bool try_backup) goto __retry; } BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, version dismatch, need upload network module"; - if (should_load_networking_plugin) { - m_networking_need_update = true; - } + m_networking_need_update = true; } } else { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll failed"; @@ -3986,10 +3982,8 @@ bool GUI_App::on_init_network(bool try_backup) load_agent_dll = Slic3r::NetworkAgent::initialize_network_module(false, config_version); goto __retry; } - if (should_load_networking_plugin) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, need upload network module"; - m_networking_need_update = true; - } + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, need upload network module"; + m_networking_need_update = true; } } @@ -8293,7 +8287,7 @@ bool GUI_App::load_language(wxString language, bool initial) // Release the old locales, create new locales. //FIXME wxWidgets cause havoc if the current locale is deleted. We just forget it causing memory leaks for now. - m_wxLocale.release(); + (void) m_wxLocale.release(); m_wxLocale = Slic3r::make_unique(); m_wxLocale->Init(locale_language_info->Language); // Override language at the active wxTranslations class (which is stored in the active m_wxLocale) diff --git a/tests/libslic3r/test_utils.cpp b/tests/libslic3r/test_utils.cpp index 49161d5d6c..1afcddf80e 100644 --- a/tests/libslic3r/test_utils.cpp +++ b/tests/libslic3r/test_utils.cpp @@ -165,10 +165,10 @@ TEST_CASE("write_file_atomically survives two threads writing one target", "[uti std::thread other([&] { for (int i = 0; i < 50; ++i) - write_file_atomically(target.string(), a); + (void) write_file_atomically(target.string(), a); }); for (int i = 0; i < 50; ++i) - write_file_atomically(target.string(), b); + (void) write_file_atomically(target.string(), b); other.join(); std::string content;