diff --git a/.clang-tidy b/.clang-tidy index 3c2eb1ea2..8622375dc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,6 +3,7 @@ # Or at least an empty comment # to show they were put here explicitely, # and not as part of the historical CLion-generated rules # Note: `- -X` means disable X +# CLI usage: go to the build directory and run: `run-clang-tidy -allow-no-checks -source-filter ".*/lib/.*" -fix -j` Checks: - -* @@ -18,24 +19,25 @@ Checks: - -bugprone-unhandled-exception-at-new - -bugprone-infinite-loop - -bugprone-easily-swappable-parameters +- -bugprone-float-loop-counter # +- -bugprone-unchecked-string-to-number-conversion # Unfortunately no alternative +- -bugprone-branch-clone # Mostly warns about one-line duplicates - cert-err52-cpp - cert-err60-cpp -- cert-err34-c - cert-str34-c - cert-dcl21-cpp - cert-msc50-cpp - cert-msc51-cpp - cert-dcl58-cpp -- cert-flp30-c - cppcoreguidelines-avoid-const-or-ref-data-members - cppcoreguidelines-pro-type-member-init # We want to use default member initializers - cppcoreguidelines-slicing - cppcoreguidelines-interfaces-global-init - -cppcoreguidelines-pro-type-static-cast-downcast # dynamic_cast has a runtime overhead - -cppcoreguidelines-narrowing-conversions # -- google-default-arguments - google-runtime-operator - google-explicit-constructor +- -google-default-arguments # Provider and ViewProvider read() is a good example of why this is useful - hicpp-multiway-paths-covered - hicpp-exception-baseclass - misc-* @@ -51,9 +53,11 @@ Checks: - -misc-const-correctness - -misc-use-internal-linkage # False positives if header where function is defined is not included - -misc-include-cleaner # Allow indirect includes +- -misc-non-private-member-variables-in-classes # - modernize-* - -modernize-use-trailing-return-type - -modernize-use-std-print # We want to use fmt::print instead +- -modernize-use-integer-sign-comparison # Too much occurrences to change - openmp-use-default-none - performance-* - -performance-no-int-to-ptr @@ -82,20 +86,12 @@ Checks: - -readability-uppercase-literal-suffix # Not important enough - -readability-redundant-string-cstr # Sometimes used to stop at first null byte - -readability-static-accessed-through-instance # +- -readability-ambiguous-smartptr-reset-call # Fix is hard to read -# Will check later if useful or not -- -readability-make-member-function-const # to make functions const. Seems to not catch everything ? -- -misc-unconventional-assign-operator -- -bugprone-unchecked-optional-access +# Will fix later - -modernize-avoid-c-arrays -- -misc-non-private-member-variables-in-classes -- -performance-move-const-arg -- -bugprone-suspicious-stringview-data-usage -- -cert-err34-c -- -hicpp-exception-baseclass -- -modernize-use-integer-sign-comparison -- -performance-for-range-copy -- -performance-unnecessary-value-param -- -bugprone-empty-catch -- -bugprone-multi-level-implicit-pointer-conversion -- -modernize-pass-by-value \ No newline at end of file +- -readability-make-member-function-const # idk + lots of occurences +- -readability-misleading-indentation # We need to handle cases with #if defined() +- -bugprone-unchecked-optional-access +- -performance-unnecessary-value-param # idk +- -readability-avoid-nested-conditional-operator diff --git a/lib/libimhex/include/hex/api/task_manager.hpp b/lib/libimhex/include/hex/api/task_manager.hpp index 4d0f75487..763c02829 100644 --- a/lib/libimhex/include/hex/api/task_manager.hpp +++ b/lib/libimhex/include/hex/api/task_manager.hpp @@ -23,7 +23,7 @@ EXPORT_MODULE namespace hex { class Task { public: Task() = default; - Task(const UnlocalizedString &unlocalizedName, u64 maxValue, bool background, bool blocking, std::function function); + Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, bool blocking, std::function function); Task(const Task&) = delete; Task(Task &&other) noexcept; @@ -95,11 +95,15 @@ EXPORT_MODULE namespace hex { std::atomic_flag m_hadException; std::string m_exceptionMessage; - struct TaskInterruptor { + struct TaskInterruptor: public std::exception { TaskInterruptor() { trace::disableExceptionCaptureForCurrentThread(); } virtual ~TaskInterruptor() = default; + + [[nodiscard]] const char* what() const noexcept override { + return "Task Interrupted"; + } }; friend class TaskHolder; diff --git a/lib/libimhex/include/hex/data_processor/node.hpp b/lib/libimhex/include/hex/data_processor/node.hpp index 6a869cedb..cdf0651e1 100644 --- a/lib/libimhex/include/hex/data_processor/node.hpp +++ b/lib/libimhex/include/hex/data_processor/node.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -49,9 +50,15 @@ namespace hex::dp { virtual void store(nlohmann::json &j) const { std::ignore = j; } virtual void load(const nlohmann::json &j) { std::ignore = j; } - struct NodeError { + struct NodeError: public std::exception { Node *node; std::string message; + + NodeError(Node *node, std::string message) : node(node), message(std::move(message)) {} + + [[nodiscard]] const char* what() const noexcept override { + return this->message.c_str(); + } }; void resetOutputData() { @@ -102,7 +109,7 @@ namespace hex::dp { void unmarkInputProcessed(u32 index); protected: - [[noreturn]] void throwNodeError(const std::string &message); + [[noreturn]] void throwNodeError(const std::string &msg); void setOverlayData(u64 address, const std::vector &data); void setAttributes(std::vector attributes); diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 5adabc2dc..279aec95c 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -1336,7 +1336,7 @@ namespace hex { class Service { public: - Service(const UnlocalizedString &unlocalizedName, std::jthread thread) : m_unlocalizedName(std::move(unlocalizedName)), m_thread(std::move(thread)) { } + Service(UnlocalizedString unlocalizedName, std::jthread thread) : m_unlocalizedName(std::move(unlocalizedName)), m_thread(std::move(thread)) { } Service(const Service&) = delete; Service(Service &&) = default; ~Service() { diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index d303a61ec..e420094ac 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -245,7 +245,7 @@ namespace hex { } std::optional getSelection() { - return impl::s_currentSelection; + return { impl::s_currentSelection }; } void clearSelection() { diff --git a/lib/libimhex/source/api/project_file_manager.cpp b/lib/libimhex/source/api/project_file_manager.cpp index 6ef6c2bae..cb02c29ac 100644 --- a/lib/libimhex/source/api/project_file_manager.cpp +++ b/lib/libimhex/source/api/project_file_manager.cpp @@ -44,7 +44,7 @@ namespace hex { } std::fs::path ProjectFile::getPath() { - return s_currProjectPath; + return { s_currProjectPath }; } void ProjectFile::setPath(const std::fs::path &path) { diff --git a/lib/libimhex/source/api/task_manager.cpp b/lib/libimhex/source/api/task_manager.cpp index 7c0056822..30e1daf60 100644 --- a/lib/libimhex/source/api/task_manager.cpp +++ b/lib/libimhex/source/api/task_manager.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #if defined(OS_WINDOWS) #include @@ -66,8 +67,8 @@ namespace hex { } - Task::Task(const UnlocalizedString &unlocalizedName, u64 maxValue, bool background, bool blocking, std::function function) - : m_unlocalizedName(unlocalizedName), + Task::Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, bool blocking, std::function function) + : m_unlocalizedName(std::move(unlocalizedName)), m_maxValue(maxValue), m_function(std::move(function)), m_background(background), m_blocking(blocking) { } diff --git a/lib/libimhex/source/api/tutorial_manager.cpp b/lib/libimhex/source/api/tutorial_manager.cpp index 970290081..847ee8701 100644 --- a/lib/libimhex/source/api/tutorial_manager.cpp +++ b/lib/libimhex/source/api/tutorial_manager.cpp @@ -57,7 +57,7 @@ namespace hex { void add(const void *pointer) { const ImGuiID seed = idStack.back(); - const ImGuiID id = ImHashData(&pointer, sizeof(pointer), seed); + const ImGuiID id = ImHashData((const void*) &pointer, sizeof(pointer), seed); idStack.push_back(id); } diff --git a/lib/libimhex/source/data_processor/node.cpp b/lib/libimhex/source/data_processor/node.cpp index abdbd6454..c84e91324 100644 --- a/lib/libimhex/source/data_processor/node.cpp +++ b/lib/libimhex/source/data_processor/node.cpp @@ -151,8 +151,8 @@ namespace hex::dp { m_overlay->getData() = data; } - [[noreturn]] void Node::throwNodeError(const std::string &message) { - throw NodeError { .node=this, .message=message }; + [[noreturn]] void Node::throwNodeError(const std::string &msg) { + throw NodeError(this, msg); } void Node::setAttributes(std::vector attributes) { diff --git a/lib/libimhex/source/helpers/encoding_file.cpp b/lib/libimhex/source/helpers/encoding_file.cpp index df777801c..45b0a9cb6 100644 --- a/lib/libimhex/source/helpers/encoding_file.cpp +++ b/lib/libimhex/source/helpers/encoding_file.cpp @@ -66,6 +66,9 @@ namespace hex { EncodingFile &EncodingFile::operator=(const hex::EncodingFile &other) { + if(this == &other) { + return *this; + } m_mapping = std::make_unique, std::string>>>(*other.m_mapping); m_tableContent = other.m_tableContent; m_longestSequence = other.m_longestSequence; @@ -90,7 +93,7 @@ namespace hex { std::pair EncodingFile::getEncodingFor(std::span buffer) const { - for (auto [size, mapping] : std::ranges::reverse_view(*m_mapping)) { + for (const auto &[size, mapping] : std::ranges::reverse_view(*m_mapping)) { if (size > buffer.size()) continue; std::vector key(buffer.begin(), buffer.begin() + size); @@ -102,7 +105,7 @@ namespace hex { } u64 EncodingFile::getEncodingLengthFor(std::span buffer) const { - for (auto [size, mapping] : std::ranges::reverse_view(*m_mapping)) { + for (const auto& [size, mapping] : std::ranges::reverse_view(*m_mapping)) { if (size > buffer.size()) continue; std::vector key(buffer.begin(), buffer.begin() + size); diff --git a/lib/libimhex/source/helpers/logger.cpp b/lib/libimhex/source/helpers/logger.cpp index a6677827d..d050eabde 100644 --- a/lib/libimhex/source/helpers/logger.cpp +++ b/lib/libimhex/source/helpers/logger.cpp @@ -118,8 +118,8 @@ namespace hex::log { void addLogEntry(std::string_view project, std::string_view level, std::string message) { s_logEntries->emplace_back( - std::move(project), - std::move(level), + project, + level, std::move(message) ); } diff --git a/lib/libimhex/source/helpers/opengl.cpp b/lib/libimhex/source/helpers/opengl.cpp index 4e03b59d9..b92afcb4c 100644 --- a/lib/libimhex/source/helpers/opengl.cpp +++ b/lib/libimhex/source/helpers/opengl.cpp @@ -138,17 +138,18 @@ namespace hex::gl { GLint Shader::getUniformLocation(std::string_view name) { - auto uniform = m_uniforms.find(name.data()); + auto nameStr = std::string(name); + auto uniform = m_uniforms.find(nameStr); if (uniform == m_uniforms.end()) { - auto location = glGetUniformLocation(m_program, name.data()); + auto location = glGetUniformLocation(m_program, nameStr.data()); if (location == -1) { log::warn("Uniform '{}' not found in shader", name); - m_uniforms[name.data()] = -1; + m_uniforms[nameStr] = -1; return -1; } - m_uniforms[name.data()] = location; - uniform = m_uniforms.find(name.data()); + m_uniforms[nameStr] = location; + uniform = m_uniforms.find(nameStr); } return uniform->second; diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 261dc219e..e8e30e1ed 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -508,7 +508,7 @@ namespace hex { if (ch <= 0x7F) { unicode = ch; unicodeSize = 0; - } else if (ch <= 0xBF) { + } else if (ch <= 0xBF) { //NOLINT(bugprone-branch-clone) return { }; } else if (ch <= 0xDF) { unicode = ch&0x1F; @@ -569,7 +569,7 @@ namespace hex { index += 1; if (wch < 0xD800 || wch > 0xDFFF) { - unicode = static_cast(wch); + unicode = static_cast(wch); // NOLINT(cert-str34-c) } else if (wch >= 0xD800 && wch <= 0xDBFF) { if (index == utf16.size()) return ""; @@ -830,7 +830,7 @@ namespace hex { input.imbue(std::locale(std::setlocale(LC_ALL, nullptr))); tm time = {}; - input >> std::get_time(&time, format.data()); + input >> std::get_time(&time, std::string(format).data()); if (input.fail()) { return std::nullopt; } diff --git a/lib/libimhex/source/mcp/client.cpp b/lib/libimhex/source/mcp/client.cpp index 7df8d839e..41c34fcaf 100644 --- a/lib/libimhex/source/mcp/client.cpp +++ b/lib/libimhex/source/mcp/client.cpp @@ -30,7 +30,7 @@ namespace hex::mcp { client.writeString(request); auto response = client.readString(); if (!response.empty() && response.front() != 0x00) - output << response << std::endl; + output << response << '\n'; } return EXIT_SUCCESS; diff --git a/lib/libimhex/source/mcp/server.cpp b/lib/libimhex/source/mcp/server.cpp index b99ab72a3..8d9a0e0da 100644 --- a/lib/libimhex/source/mcp/server.cpp +++ b/lib/libimhex/source/mcp/server.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -13,7 +14,7 @@ namespace hex::mcp { class JsonRpc { public: - explicit JsonRpc(const std::string &request) : m_request(request) { } + explicit JsonRpc(std::string request) : m_request(std::move(request)) { } struct MethodNotFoundException : std::exception {}; struct InvalidParametersException : std::exception {}; @@ -77,7 +78,7 @@ namespace hex::mcp { return responses.dump(); } - enum class ErrorCode { + enum class ErrorCode: i16 { ParseError = -32700, InvalidRequest = -32600, MethodNotFound = -32601, diff --git a/main/gui/source/init/splash_window.cpp b/main/gui/source/init/splash_window.cpp index 9788e728b..519257e00 100644 --- a/main/gui/source/init/splash_window.cpp +++ b/main/gui/source/init/splash_window.cpp @@ -589,8 +589,8 @@ namespace hex::init { for (auto &highlight : m_highlights) { u32 newPos = lastPos + lastCount + (rng() % 35); u32 newCount = (rng() % 7) + 3; - highlight.start.x = float(newPos % 13); - highlight.start.y = float(newPos / 13); + highlight.start.x = newPos % 13; + highlight.start.y = int(newPos / 13); highlight.count = newCount; highlight.color = getHighlightColor(index); diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index a93c6afc5..86f78b058 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -110,7 +110,7 @@ namespace hex { LayoutManager::registerLoadCallback([this](std::string_view line) { int width = 0, height = 0; - sscanf(line.data(), "MainWindowSize=%d,%d", &width, &height); + sscanf(std::string(line).data(), "MainWindowSize=%d,%d", &width, &height); if (width > 0 && height > 0) { TaskManager::doLater([width, height, this]{ @@ -1011,7 +1011,7 @@ namespace hex { try { log::error("GLFW Error [0x{:05X}] : {}", error, desc); - } catch (const std::system_error &) { + } catch (const std::system_error &) { //NOLINT(bugprone-empty-catch): we can't log it // Catch and ignore system error that might be thrown when too many errors are being logged to a file } }); diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp index 7ceadfa46..37290c42d 100644 --- a/plugins/builtin/source/content/command_palette_commands.cpp +++ b/plugins/builtin/source/content/command_palette_commands.cpp @@ -23,7 +23,7 @@ namespace hex::plugin::builtin { class Value { public: - enum class Unit { + enum class Unit: u8 { Unitless, Decimal, Hexadecimal, diff --git a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp index 626927a5b..d1dc206df 100644 --- a/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes/other_nodes.cpp @@ -388,7 +388,7 @@ namespace hex::plugin::builtin { static auto x = [] { std::array result { 0 }; - std::iota(result.begin(), result.end(), 0); + std::iota(result.begin(), result.end(), 0); // NOLINT: std::ranges::iota not available on some platforms return result; }(); diff --git a/plugins/builtin/source/content/out_of_box_experience.cpp b/plugins/builtin/source/content/out_of_box_experience.cpp index b7841ed22..06e7e4794 100644 --- a/plugins/builtin/source/content/out_of_box_experience.cpp +++ b/plugins/builtin/source/content/out_of_box_experience.cpp @@ -39,7 +39,7 @@ namespace hex::plugin::builtin { public: Blend(float start, float end) : m_start(start), m_end(end) {} - [[nodiscard]] operator float() { + [[nodiscard]] operator float() { // NOLINT: This class is a used as a float m_time += ImGui::GetIO().DeltaTime; float t = m_time; diff --git a/plugins/builtin/source/content/providers/command_provider.cpp b/plugins/builtin/source/content/providers/command_provider.cpp index 1c6beda9c..1260ed124 100644 --- a/plugins/builtin/source/content/providers/command_provider.cpp +++ b/plugins/builtin/source/content/providers/command_provider.cpp @@ -193,7 +193,7 @@ namespace hex::plugin::builtin { static std::string executeCommandString(const std::string &command) { auto output = executeCommand(command); - return std::string(output.begin(), output.end()); + return { output.begin(), output.end() }; } void CommandProvider::readFromSource(u64 offset, void *buffer, size_t size) { diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index 05b509004..89f7c5764 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -204,7 +204,7 @@ namespace hex::plugin::builtin { } prv::Provider::OpenResult FileProvider::open() { - const size_t maxMemoryFileSize = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.max_mem_file_size", 128_MiB); + const auto maxMemoryFileSize = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.max_mem_file_size", 128_MiB); size_t fileSize = 0x00; { diff --git a/plugins/builtin/source/content/providers/intel_hex_provider.cpp b/plugins/builtin/source/content/providers/intel_hex_provider.cpp index 0f610ff95..110e83c67 100644 --- a/plugins/builtin/source/content/providers/intel_hex_provider.cpp +++ b/plugins/builtin/source/content/providers/intel_hex_provider.cpp @@ -43,7 +43,7 @@ namespace hex::plugin::builtin { u16 address = 0x0000; std::vector data; - enum class RecordType { + enum class RecordType: u8 { Data = 0x00, EndOfFile = 0x01, ExtendedSegmentAddress = 0x02, @@ -348,7 +348,7 @@ namespace hex::plugin::builtin { ImGui::TableHeadersRow(); for (const auto &memoryRegion : filtered) { - ImGui::PushID(&memoryRegion); + ImGui::PushID((const void*) &memoryRegion); ImGui::TableNextRow(); ImGui::TableNextColumn(); diff --git a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp index 2b3aacb0b..d68b22a7d 100644 --- a/plugins/builtin/source/content/providers/motorola_srec_provider.cpp +++ b/plugins/builtin/source/content/providers/motorola_srec_provider.cpp @@ -57,7 +57,7 @@ namespace hex::plugin::builtin { }; try { - enum class RecordType { + enum class RecordType: u8 { Header = 0x00, Data16 = 0x01, Data24 = 0x02, @@ -147,7 +147,6 @@ namespace hex::plugin::builtin { break; case RecordType::Header: case RecordType::Reserved: - break; case RecordType::Count16: case RecordType::Count24: break; diff --git a/plugins/builtin/source/content/providers/process_memory_provider.cpp b/plugins/builtin/source/content/providers/process_memory_provider.cpp index ae8faa07a..3e54e6979 100644 --- a/plugins/builtin/source/content/providers/process_memory_provider.cpp +++ b/plugins/builtin/source/content/providers/process_memory_provider.cpp @@ -419,7 +419,7 @@ namespace hex::plugin::builtin { ImGui::TableHeadersRow(); for (const auto &memoryRegion : filtered) { - ImGui::PushID(&memoryRegion); + ImGui::PushID((const void*) &memoryRegion); ImGui::TableNextRow(); ImGui::TableNextColumn(); diff --git a/plugins/builtin/source/content/text_highlighting/pattern_language.cpp b/plugins/builtin/source/content/text_highlighting/pattern_language.cpp index 851098926..65ea32cf8 100644 --- a/plugins/builtin/source/content/text_highlighting/pattern_language.cpp +++ b/plugins/builtin/source/content/text_highlighting/pattern_language.cpp @@ -126,32 +126,32 @@ namespace hex::plugin::builtin { } } bool found = true; - for (auto name : vectorString) { + for (const auto &name : vectorString) { found = found || std::ranges::find(m_nameSpaces, name) != m_nameSpaces.end(); } if (found) { if (!shortName.empty()) - identifierName = identifierName + "::" + shortName; + identifierName = fmt::format("{}::{}", identifierName, shortName); return true; } if (useDefinitions) { if (m_functionDefinitions.contains(identifierName) || m_UDTDefinitions.contains(identifierName)) { if (!shortName.empty()) - identifierName = identifierName + "::" + shortName; + identifierName = fmt::format("{}::{}", identifierName, shortName); return true; } std::string nameSpace; - for (auto [name, definition]: m_UDTDefinitions) { + for (const auto &[name, definition]: m_UDTDefinitions) { findNamespace(nameSpace, definition.tokenIndex); if (!nameSpace.empty() && !identifierName.contains(nameSpace)) { - qualifiedName = nameSpace + "::" + identifierName; + qualifiedName = fmt::format("{}::{}", nameSpace, identifierName); if (name == qualifiedName) { identifierName = qualifiedName; if (!shortName.empty()) - identifierName = identifierName + "::" + shortName; + identifierName = fmt::format("{}::{}", identifierName, shortName); return true; } } @@ -159,7 +159,7 @@ namespace hex::plugin::builtin { if (name == identifierName) { identifierName = name; if (!shortName.empty()) - identifierName = identifierName + "::" + shortName; + identifierName = fmt::format("{}::{}", identifierName, shortName); return true; } } @@ -192,7 +192,7 @@ namespace hex::plugin::builtin { std::string nameSpace; findNamespace(nameSpace, getTokenId(m_curr->location)); if (!nameSpace.empty()) - name = nameSpace + "::" + name; + name = fmt::format("{}::{}", nameSpace, name); } i32 tokenCount = m_tokens.size(); @@ -217,7 +217,7 @@ namespace hex::plugin::builtin { next(-1); i32 index1 = getTokenId(m_curr->location); bool result = true; - for (auto keyword: keywords) + for (const auto &keyword: keywords) result = result && !peek(keyword); if (result) return false; @@ -468,10 +468,10 @@ namespace hex::plugin::builtin { variableParentType = currentName; if (!nameSpace.empty() && !variableParentType.contains(nameSpace)) - variableParentType = nameSpace + variableParentType; + variableParentType.insert(0, nameSpace); else if (findNamespace(nameSpace) && !variableParentType.contains(nameSpace)) - variableParentType = nameSpace + "::" + variableParentType; + variableParentType = fmt::format("{}::{}", nameSpace, variableParentType); currentName = vectorString[index]; @@ -566,7 +566,7 @@ namespace hex::plugin::builtin { break; } } - for (auto definition : definitions) { + for (const auto &definition : definitions) { for (auto block = blocksIterBegin; block != blocksIterEnd; block++) { if (definition.tokenIndex > block->start && definition.tokenIndex < block->end) { @@ -600,7 +600,7 @@ namespace hex::plugin::builtin { } } for (auto block = blocksIterBegin; block != blocksIterEnd; block++) { - for (auto definition: definitions) { + for (const auto &definition: definitions) { if (definition.tokenIndex > block->start && definition.tokenIndex < block->end) { result = definition; @@ -761,7 +761,7 @@ namespace hex::plugin::builtin { setIdentifierColor(-1, IdentifierType::NameSpace); nameSpace += name + "::"; } else if (m_UDTDefinitions.contains(nameSpace+name)) { - name = nameSpace + name; + name.insert(0, nameSpace); auto udtDefinition = m_UDTDefinitions[name]; auto definitionIndex = udtDefinition.tokenIndex-1; if (auto *keyword = std::get_if(&m_tokens[definitionIndex].value); keyword != nullptr) { @@ -839,7 +839,7 @@ namespace hex::plugin::builtin { bool TextHighlighter::findScope(std::string &name, const UnorderedBlocks &map, i32 optionalTokenId) { auto tokenId = optionalTokenId ==-1 ? getTokenId(m_curr->location) : optionalTokenId; - for (auto [scopeName, range]: map) { + for (const auto &[scopeName, range]: map) { if (range.contains(tokenId)) { name = scopeName; @@ -861,7 +861,7 @@ namespace hex::plugin::builtin { if (nameSpace.empty()) nameSpace = name; else - nameSpace = name + "::" + nameSpace; + nameSpace = fmt::format("{}::{}", name, nameSpace); } } @@ -916,12 +916,12 @@ namespace hex::plugin::builtin { std::string namespaceName; if (findNamespace(namespaceName)) - functionName = namespaceName + "::" + functionName; + functionName = fmt::format("{}::{}", namespaceName, functionName); } else { auto vectorString = wolv::util::splitString(functionName, "::"); vectorString.pop_back(); - for (auto nameSpace: vectorString) { + for (const auto &nameSpace: vectorString) { if (std::ranges::find(m_nameSpaces, nameSpace) == m_nameSpaces.end()) m_nameSpaces.push_back(nameSpace); @@ -965,7 +965,7 @@ namespace hex::plugin::builtin { std::string namespaceName; if (findNamespace(namespaceName)) - UDTName = namespaceName + "::" + UDTName; + UDTName = fmt::format("{}::{}", namespaceName, UDTName); } if (types.contains(UDTName)) m_attributeFunctionArgumentType[functionName] = UDTName; @@ -1002,7 +1002,7 @@ namespace hex::plugin::builtin { identifiers.erase(identifiers.begin()); while (currentName == "Parent" && !nameParts.empty()) { - for (auto parentType: parentTypes) + for (const auto &parentType: parentTypes) findParentTypes(grandpaTypes, parentType); currentName = nameParts[0]; @@ -1038,9 +1038,9 @@ namespace hex::plugin::builtin { bool found = false; if (!isFunction) { - for (auto [name, variables]: m_UDTVariables) { - for (auto [variableName, definitions]: variables) { - for (auto definition: definitions) { + for (const auto &[name, variables]: m_UDTVariables) { + for (const auto &[variableName, definitions]: variables) { + for (const auto &definition: definitions) { if (definition.typeStr == UDTName) { @@ -1054,7 +1054,7 @@ namespace hex::plugin::builtin { } } else { auto curr = m_curr; - for (auto [name, range] : m_UDTTokenRange) { + for (const auto &[name, range] : m_UDTTokenRange) { auto startToken = TokenIter(m_tokens.begin()+range.start,m_tokens.begin()+range.end); auto endToken = TokenIter(m_tokens.begin()+range.end,m_tokens.end()); @@ -1089,7 +1089,7 @@ namespace hex::plugin::builtin { if (m_UDTVariables.contains(UDTName) && m_UDTVariables[UDTName].contains(currentName)) { auto definitions = m_UDTVariables[UDTName][currentName]; - for (auto definition: definitions) { + for (const auto &definition: definitions) { UDTName = definition.typeStr; if (count == 1) { @@ -1151,7 +1151,7 @@ namespace hex::plugin::builtin { return std::nullopt; } - for (auto parentType: parentTypes) { + for (const auto &parentType: parentTypes) { m_curr = curr; while (peek(tkn::Keyword::Parent)) next(2); @@ -1451,7 +1451,7 @@ namespace hex::plugin::builtin { void TextHighlighter::colorRemainingIdentifierTokens() { std::vector taggedIdentifiers; taggedIdentifiers.reserve(m_taggedIdentifiers.size()); -for (auto index: m_taggedIdentifiers) { + for (auto index: m_taggedIdentifiers) { taggedIdentifiers.push_back(index); } m_taggedIdentifiers.clear(); @@ -1603,12 +1603,12 @@ for (auto index: m_taggedIdentifiers) { void TextHighlighter::recurseInheritances(std::string name) { if (m_inheritances.contains(name)) { - for (auto inheritance: m_inheritances[name]) { + for (const auto &inheritance: m_inheritances[name]) { recurseInheritances(inheritance); auto definitions = m_UDTVariables[inheritance]; if (definitions.empty()) definitions = m_ImportedUDTVariables[inheritance]; - for (auto [variableName, variableDefinitions]: definitions) { + for (const auto &[variableName, variableDefinitions]: definitions) { auto tokenRange = m_UDTTokenRange[name]; u32 tokenIndex = tokenRange.start; for (auto token = tokenRange.start; token < tokenRange.end; token++) { @@ -1627,7 +1627,7 @@ for (auto index: m_taggedIdentifiers) { } void TextHighlighter::appendInheritances() { - for (auto [name, inheritances]: m_inheritances) + for (const auto &[name, inheritances]: m_inheritances) recurseInheritances(name); } @@ -1718,7 +1718,8 @@ for (auto index: m_taggedIdentifiers) { std::string nameSpace; while (peek(tkn::Operator::ScopeResolution)) { next(-1); - nameSpace = getValue(0)->get() + "::" + nameSpace; + nameSpace.insert(0, "::" + typeStr); + nameSpace.insert(0, getValue(0)->get()); next(-1); } typeStr = nameSpace + typeStr; @@ -1731,7 +1732,7 @@ for (auto index: m_taggedIdentifiers) { return typeStr; } std::vector candidates; - for (auto name: m_UDTs) { + for (const auto &name: m_UDTs) { auto vectorString = wolv::util::splitString(name, "::"); if (typeStr == vectorString.back()) @@ -1781,7 +1782,7 @@ for (auto index: m_taggedIdentifiers) { void TextHighlighter::loadVariableDefinitions(UnorderedBlocks tokenRangeMap, Token delimiter1, Token delimiter2, std::vector identifierTypes, bool isArgument, VariableMap &variableMap) { - for (auto [name, range]: tokenRangeMap) { + for (const auto &[name, range]: tokenRangeMap) { m_curr = m_startToken; auto endToken = m_startToken; next(range.start); @@ -1851,7 +1852,7 @@ for (auto index: m_taggedIdentifiers) { // Definitions of user defined types and functions. void TextHighlighter::loadTypeDefinitions( UnorderedBlocks tokenRangeMap, std::vector identifierTypes, Definitions &types) { - for (auto [name, range]: tokenRangeMap) { + for (const auto &[name, range]: tokenRangeMap) { m_curr = m_startToken + range.start+1; @@ -2129,9 +2130,9 @@ for (auto index: m_taggedIdentifiers) { // and inverts the result. void TextHighlighter::getGlobalTokenRanges() { std::set ranges; - for (auto [name, range]: m_UDTTokenRange) + for (const auto &[name, range]: m_UDTTokenRange) ranges.insert(range); - for (auto [name, range]: m_functionTokenRange) + for (const auto &[name, range]: m_functionTokenRange) ranges.insert(range); if (ranges.empty()) diff --git a/plugins/builtin/source/content/tools/ascii_table.cpp b/plugins/builtin/source/content/tools/ascii_table.cpp index f3dad37b6..8e23741e5 100644 --- a/plugins/builtin/source/content/tools/ascii_table.cpp +++ b/plugins/builtin/source/content/tools/ascii_table.cpp @@ -122,7 +122,7 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); const auto character = row * 0x10 + column; - for (u8 i = 0; i < HighlightFunctions.size(); i++) { + for (size_t i = 0; i < HighlightFunctions.size(); i++) { if (highlightFunctionEnabled[i] && HighlightFunctions[i](character) != 0) { ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::GetColorU32(ImGuiCustomCol_Highlight)); break; diff --git a/plugins/builtin/source/content/tools/ieee_decoder.cpp b/plugins/builtin/source/content/tools/ieee_decoder.cpp index 065ff538d..68353839d 100644 --- a/plugins/builtin/source/content/tools/ieee_decoder.cpp +++ b/plugins/builtin/source/content/tools/ieee_decoder.cpp @@ -36,7 +36,7 @@ namespace hex::plugin::builtin { static IEEE754STATICS ieee754statics; - enum class NumberType { + enum class NumberType: u8 { Normal, Zero, Denormal, @@ -44,7 +44,7 @@ namespace hex::plugin::builtin { NaN, }; - enum class InputType { + enum class InputType: u8 { Infinity, NotANumber, QuietNotANumber, @@ -53,7 +53,7 @@ namespace hex::plugin::builtin { Invalid }; - enum class ValueType { + enum class ValueType: u8 { Regular, SignalingNaN, QuietNaN, diff --git a/plugins/builtin/source/content/tools/regex_replacer.cpp b/plugins/builtin/source/content/tools/regex_replacer.cpp index 081ac36c5..be2cde93b 100644 --- a/plugins/builtin/source/content/tools/regex_replacer.cpp +++ b/plugins/builtin/source/content/tools/regex_replacer.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -26,7 +27,9 @@ namespace hex::plugin::builtin { try { const auto regex = boost::regex(regexPattern); outputString = boost::regex_replace(inputString, regex, replacePattern); - } catch (boost::regex_error &) { } + } catch (const boost::regex_error &e) { + log::warn("Invalid regex pattern in Regex Replacer tool: {}", e.what()); + } } ImGui::InputTextMultiline("hex.builtin.tools.regex_replacer.output"_lang, outputString, ImVec2(0, 0), ImGuiInputTextFlags_ReadOnly); diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index a31035977..6b32b3e91 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -626,7 +626,9 @@ namespace hex::plugin::builtin { fs::openFileBrowser(fs::DialogMode::Open, { { "Bookmarks File", "hexbm"} }, [&, this](const std::fs::path &path) { try { this->importBookmarks(ImHexApi::Provider::get(), nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString())); - } catch (...) { } + } catch (const std::exception &e) { + log::warn("Failed to import bookmarks: {}", e.what()); + } }); }, ImHexApi::Provider::isValid); diff --git a/plugins/builtin/source/content/views/view_pattern_data.cpp b/plugins/builtin/source/content/views/view_pattern_data.cpp index 1e6b0bd8b..901e4625c 100644 --- a/plugins/builtin/source/content/views/view_pattern_data.cpp +++ b/plugins/builtin/source/content/views/view_pattern_data.cpp @@ -118,7 +118,7 @@ namespace hex::plugin::builtin { const auto &path = file->path; auto currSegment = wolv::io::fs::toNormalizedPathString(*std::next(path.begin(), level)); - if (std::distance(path.begin(), path.end()) == ptrdiff_t(level + 1)) { + if (std::distance(path.begin(), path.end()) == i32(level + 1)) { ImGui::TableNextRow(); ImGui::TableNextColumn(); diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index df8d14830..3debf3a0e 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -1753,7 +1753,7 @@ namespace hex::plugin::builtin { return m_dangerousFunctionsAllowed == DangerousFunctionPerms::Allow; }); - runtime.setLogCallback([this, provider](auto level, auto message) { + runtime.setLogCallback([this, provider](auto level, const auto& message) { std::scoped_lock lock(m_logMutex); auto lines = wolv::util::splitString(message, "\n"); diff --git a/plugins/fonts/source/font_settings.cpp b/plugins/fonts/source/font_settings.cpp index 5a252815c..1bc850dac 100644 --- a/plugins/fonts/source/font_settings.cpp +++ b/plugins/fonts/source/font_settings.cpp @@ -75,7 +75,7 @@ namespace hex::fonts { } } - s_previewFonts = std::move(s_usedFonts); + s_previewFonts = s_usedFonts; s_usedFonts->clear(); } @@ -316,7 +316,7 @@ namespace hex::fonts { ContentRegistry::Settings::Widgets::Widget::Interface& addFontSettingsWidget(UnlocalizedString name) { - return ContentRegistry::Settings::add("hex.fonts.setting.font", "hex.fonts.setting.font.custom_font", std::move(name)); + return ContentRegistry::Settings::add("hex.fonts.setting.font", "hex.fonts.setting.font.custom_font", name); } } diff --git a/plugins/ui/include/ui/markdown.hpp b/plugins/ui/include/ui/markdown.hpp index 4685ad822..77ec74ec6 100644 --- a/plugins/ui/include/ui/markdown.hpp +++ b/plugins/ui/include/ui/markdown.hpp @@ -19,7 +19,7 @@ namespace hex::ui { class Markdown { public: Markdown() = default; - Markdown(const std::string &text); + Markdown(std::string text); Markdown(const Markdown &) = delete; Markdown(Markdown &&other) = default; @@ -40,7 +40,7 @@ namespace hex::ui { private: std::string m_text; bool m_initialized = false; - MD_RENDERER m_mdRenderer; + MD_RENDERER m_mdRenderer = {}; bool m_firstLine = true; u32 m_elementId = 1; std::string m_currentLink; diff --git a/plugins/ui/include/ui/text_editor.hpp b/plugins/ui/include/ui/text_editor.hpp index 733a807a9..e4a4dab98 100644 --- a/plugins/ui/include/ui/text_editor.hpp +++ b/plugins/ui/include/ui/text_editor.hpp @@ -151,11 +151,11 @@ namespace hex::ui { bool m_matchCase; bool m_wholeWord; bool m_findRegEx; - bool m_optionsChanged; + bool m_optionsChanged = false; Matches m_matches; }; - enum class PaletteIndex { + enum class PaletteIndex: u8 { Default, Identifier, Directive, Operator, Separator, BuiltInType, Keyword, NumericLiteral, StringLiteral, CharLiteral, Cursor, Background, LineNumber, Selection, Breakpoint, ErrorMarker, PreprocessorDeactivated, CurrentLineFill, CurrentLineFillInactive, CurrentLineEdge, ErrorText, WarningText, DebugText, DefaultText, Attribute, PatternVariable, LocalVariable, CalculatedPointer, TemplateArgument, Function, View, FunctionVariable, FunctionParameter, UserDefinedType, PlacedVariable, GlobalVariable, NameSpace, TypeDef, UnkIdentifier, DocComment, DocBlockComment, BlockComment, GlobalDocComment, Comment, PreprocIdentifier, Max @@ -228,12 +228,12 @@ namespace hex::ui { class LineIterator { public: friend class hex::ui::TextEditor; - LineIterator(const LineIterator &other) : m_charsIter(other.m_charsIter), m_colorsIter(other.m_colorsIter), m_flagsIter(other.m_flagsIter) {} + LineIterator(const LineIterator &other) = default; LineIterator() = default; char operator*(); LineIterator operator++(); - LineIterator operator=(const LineIterator &other); + LineIterator& operator=(const LineIterator &other); bool operator!=(const LineIterator &other) const; bool operator==(const LineIterator &other) const; LineIterator operator+(i32 n); @@ -265,13 +265,13 @@ namespace hex::ui { }; union Flags { - Flags(char value) : m_value(value) {} - Flags(FlagBits bits) : m_bits(bits) {} + explicit Flags(char value) : m_value(value) {} + explicit Flags(FlagBits bits) : m_bits(bits) {} FlagBits m_bits; char m_value; }; - enum class LinePart { Chars, Utf8, Colors, Flags }; + enum class LinePart: u8 { Chars, Utf8, Colors, Flags }; Line() : m_lineMaxColumn(-1) {} explicit Line(const char *line) : Line(std::string(line)) {} @@ -374,9 +374,9 @@ namespace hex::ui { friend class TextEditor; UndoRecord() = default; ~UndoRecord() {} - UndoRecord( const std::string &added, + UndoRecord( std::string added, Range addedRange, - const std::string &removed, + std::string removed, Range removedRange, EditorState &before, EditorState &after); diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index 725ba1271..bb185e504 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -382,7 +382,7 @@ namespace hex::ui { if (m_editingAddress != address || m_editingCellType != cellType) { if (cellType == CellType::Hex) { - std::array buffer; + std::array buffer = {}; std::memcpy(buffer.data(), data, std::min(size, buffer.size())); if (m_dataVisualizerEndianness != std::endian::native) diff --git a/plugins/ui/source/ui/markdown.cpp b/plugins/ui/source/ui/markdown.cpp index c00a2b403..c980fab60 100644 --- a/plugins/ui/source/ui/markdown.cpp +++ b/plugins/ui/source/ui/markdown.cpp @@ -15,15 +15,15 @@ #include #include +#include #include namespace hex::ui { - Markdown::Markdown(const std::string &text) : m_text(text) { - m_mdRenderer = MD_RENDERER(); + Markdown::Markdown(std::string text) : m_text(std::move(text)) { m_initialized = true; - m_mdRenderer.flags = MD_DIALECT_GITHUB | MD_FLAG_TABLES | MD_FLAG_TASKLISTS; + m_mdRenderer.flags = MD_DIALECT_GITHUB; m_mdRenderer.enter_block = [](MD_BLOCKTYPE type, void *detail, void *userdata) -> int { auto &self = *static_cast(userdata); @@ -60,11 +60,7 @@ namespace hex::ui { self.m_tableVisibleStack.emplace_back(open); break; } - case MD_BLOCK_TD: { - if (self.inTable()) - ImGui::TableNextColumn(); - break; - } + case MD_BLOCK_TD: case MD_BLOCK_TH: { if (self.inTable()) ImGui::TableNextColumn(); @@ -129,11 +125,6 @@ namespace hex::ui { fonts::Default().pop(); break; case MD_BLOCK_CODE: - if (self.inTable()) { - ImGui::EndTable(); - self.m_tableVisibleStack.pop_back(); - } - break; case MD_BLOCK_TABLE: if (self.inTable()) { ImGui::EndTable(); diff --git a/plugins/ui/source/ui/pattern_drawer.cpp b/plugins/ui/source/ui/pattern_drawer.cpp index b6eca778c..ef1b6d094 100644 --- a/plugins/ui/source/ui/pattern_drawer.cpp +++ b/plugins/ui/source/ui/pattern_drawer.cpp @@ -207,7 +207,7 @@ namespace hex::ui { filterString = wolv::util::trim(filterString); if (filterString.empty()) - return std::nullopt; + return std::nullopt; //NOLINT: optimise for empty string else if (filterString.starts_with("===")) { result.operation = std::strong_ordering::equal; result.inverted = false; diff --git a/plugins/ui/source/ui/text_editor/editor.cpp b/plugins/ui/source/ui/text_editor/editor.cpp index 3d7f7e2ae..91647ac87 100644 --- a/plugins/ui/source/ui/text_editor/editor.cpp +++ b/plugins/ui/source/ui/text_editor/editor.cpp @@ -1,9 +1,9 @@ #include #include -#include #include #include #include +#include #include #include #define IMGUI_DEFINE_MATH_OPERATORS @@ -244,7 +244,7 @@ namespace hex::ui { m_lines.clear(); m_lines.resize(lineCount); u64 i = 0; - for (auto line: vectorString) { + for (const auto& line: vectorString) { m_lines[i].setLine(line); m_lines[i].m_colorized = false; m_lines[i].m_lineMaxColumn = -1; @@ -813,12 +813,12 @@ namespace hex::ui { } TextEditor::UndoRecord::UndoRecord( - const std::string &added, + std::string added, const TextEditor::Range addedRange, - const std::string &removed, + std::string removed, const TextEditor::Range removedRange, TextEditor::EditorState &before, - TextEditor::EditorState &after) : m_added(added), m_addedRange(addedRange), m_removed(removed), m_removedRange(removedRange), m_before(before), m_after(after) {} + TextEditor::EditorState &after) : m_added(std::move(added)), m_addedRange(addedRange), m_removed(std::move(removed)), m_removedRange(removedRange), m_before(before), m_after(after) {} void TextEditor::UndoRecord::undo(TextEditor *editor) { if (!m_added.empty()) { diff --git a/plugins/ui/source/ui/text_editor/highlighter.cpp b/plugins/ui/source/ui/text_editor/highlighter.cpp index 4f2e9e5ee..1118ec048 100644 --- a/plugins/ui/source/ui/text_editor/highlighter.cpp +++ b/plugins/ui/source/ui/text_editor/highlighter.cpp @@ -180,7 +180,6 @@ namespace hex::ui { auto currentLine = endLine; auto commentLength = 0; auto matchedBracket = false; - std::string brackets = "()[]{}<>"; std::vector ifDefs; ifDefs.push_back(true); @@ -347,12 +346,7 @@ namespace hex::ui { if (isGlobalDocComment || isBlockDocComment || isBlockComment) { commentStartLine = currentLine; commentStartIndex = currentIndex; - if (currentIndex < line.size() - 4 && isBlockComment && - line.m_chars[currentIndex + 2] == '*' && - line.m_chars[currentIndex + 3] == '/') { - withinBlockComment = true; - commentLength = 2; - } else if (isGlobalDocComment) { + if (isGlobalDocComment) { withinGlobalDocComment = true; commentLength = 3; } else if (isBlockDocComment) { @@ -1191,8 +1185,8 @@ namespace hex::ui { out_begin = in_begin; out_end = in_begin + 1; return true; + default: + return false; } - - return false; } } diff --git a/plugins/ui/source/ui/text_editor/render.cpp b/plugins/ui/source/ui/text_editor/render.cpp index 8a003324e..3489f4a80 100644 --- a/plugins/ui/source/ui/text_editor/render.cpp +++ b/plugins/ui/source/ui/text_editor/render.cpp @@ -500,7 +500,7 @@ namespace hex::ui { if (gotoKey != Invalid) { std::string errorLineColumn; bool found = false; - for (auto text: m_clickableText) { + for (const auto& text: m_clickableText) { if (lineText.starts_with(text)) { errorLineColumn = lineText.substr(text.size()); if (!errorLineColumn.empty()) { diff --git a/plugins/ui/source/ui/text_editor/support.cpp b/plugins/ui/source/ui/text_editor/support.cpp index dade6a59c..928f3ee3a 100644 --- a/plugins/ui/source/ui/text_editor/support.cpp +++ b/plugins/ui/source/ui/text_editor/support.cpp @@ -148,12 +148,7 @@ namespace hex::ui { return iter; } - LineIterator LineIterator::operator=(const LineIterator &other) { - m_charsIter = other.m_charsIter; - m_colorsIter = other.m_colorsIter; - m_flagsIter = other.m_flagsIter; - return *this; - } + LineIterator& LineIterator::operator=(const LineIterator &other) = default; bool LineIterator::operator!=(const LineIterator &other) const { return m_charsIter != other.m_charsIter || m_colorsIter != other.m_colorsIter || @@ -532,7 +527,7 @@ namespace hex::ui { if (m_readOnly) return; - m_undoBuffer.resize((u64) (m_undoIndex + 1)); + m_undoBuffer.resize(m_undoIndex + 1); m_undoBuffer.back() = UndoAction(value); m_undoIndex++; } @@ -933,7 +928,8 @@ namespace hex::ui { while (iter != end) { iter++; - if (((pos = iter->position()) > byteIndex)) + pos = iter->position(); + if (pos > byteIndex) break; } } diff --git a/tests/algorithms/source/endian.cpp b/tests/algorithms/source/endian.cpp index d97fa1f2a..1ab871fb9 100644 --- a/tests/algorithms/source/endian.cpp +++ b/tests/algorithms/source/endian.cpp @@ -15,6 +15,7 @@ TEST_SEQUENCE("64BitFloatEndianSwap") { double swappedFloatValue = hex::changeEndianness(floatValue, std::endian::big); u64 swappedIntegerValue = hex::changeEndianness(integerValue, std::endian::big); + //NOLINTNEXTLINE TEST_ASSERT(std::memcmp(&floatValue, &integerValue, 8) == 0 && std::memcmp(&swappedFloatValue, &swappedIntegerValue, 8) == 0); TEST_SUCCESS();