From 327e904dbc924e452ffa1220f979c28d003b85a1 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 4 Mar 2022 20:52:39 +0100 Subject: [PATCH] sys: Fixed many clang tidy warnings and typos --- README.md | 10 +++++----- lib/libimhex/include/hex/api/localization.hpp | 4 ++-- lib/libimhex/include/hex/data_processor/node.hpp | 2 +- lib/libimhex/include/hex/helpers/disassembler.hpp | 4 ++-- lib/libimhex/include/hex/helpers/fs.hpp | 2 +- lib/libimhex/include/hex/helpers/socket.hpp | 6 +++--- lib/libimhex/include/hex/helpers/utils.hpp | 6 +++--- .../ast/ast_node_array_variable_decl.hpp | 2 +- .../hex/pattern_language/ast/ast_node_bitfield.hpp | 2 +- .../ast/ast_node_control_flow_statement.hpp | 4 ---- .../hex/pattern_language/ast/ast_node_union.hpp | 1 - .../include/hex/pattern_language/evaluator.hpp | 10 +++++----- .../hex/pattern_language/patterns/pattern.hpp | 2 +- .../hex/pattern_language/patterns/pattern_enum.hpp | 4 ---- .../include/hex/pattern_language/preprocessor.hpp | 2 +- lib/libimhex/include/hex/providers/overlay.hpp | 2 +- lib/libimhex/source/api/content_registry.cpp | 2 +- lib/libimhex/source/api/imhex_api.cpp | 2 +- lib/libimhex/source/api/localization.cpp | 4 ++-- lib/libimhex/source/data_processor/node.cpp | 2 +- lib/libimhex/source/helpers/fs.cpp | 2 +- .../source/helpers/loader_script_handler.cpp | 2 +- lib/libimhex/source/helpers/patches.cpp | 4 ++-- lib/libimhex/source/helpers/socket.cpp | 2 +- lib/libimhex/source/helpers/utils.cpp | 6 +++--- .../source/pattern_language/preprocessor.cpp | 6 ++++-- lib/libimhex/source/ui/view.cpp | 2 +- main/include/init/splash_window.hpp | 2 +- main/source/window/win_window.cpp | 2 ++ main/source/window/window.cpp | 2 +- .../include/content/providers/disk_provider.hpp | 6 +++--- .../include/content/providers/gdb_provider.hpp | 4 ++-- plugins/builtin/include/content/views/view_about.hpp | 12 ++++-------- .../include/content/views/view_command_palette.hpp | 5 +++-- .../builtin/include/content/views/view_constants.hpp | 5 +++-- .../include/content/views/view_data_inspector.hpp | 4 ---- .../include/content/views/view_data_processor.hpp | 4 ---- plugins/builtin/include/content/views/view_diff.hpp | 4 ---- .../include/content/views/view_disassembler.hpp | 4 ---- .../builtin/include/content/views/view_hashes.hpp | 7 ++----- .../include/content/views/view_hex_editor.hpp | 2 +- .../include/content/views/view_information.hpp | 4 ---- .../builtin/include/content/views/view_patches.hpp | 6 +----- plugins/builtin/include/content/views/view_store.hpp | 2 +- .../builtin/include/content/views/view_strings.hpp | 4 ---- plugins/builtin/include/content/views/view_tools.hpp | 6 +----- .../builtin/source/content/data_processor_nodes.cpp | 6 +++--- plugins/builtin/source/content/settings_entries.cpp | 2 +- .../source/content/views/view_command_palette.cpp | 3 --- .../builtin/source/content/views/view_constants.cpp | 3 --- .../source/content/views/view_data_inspector.cpp | 2 -- .../source/content/views/view_disassembler.cpp | 2 +- .../source/content/views/view_pattern_editor.cpp | 2 +- .../builtin/source/content/views/view_settings.cpp | 2 +- plugins/builtin/source/content/views/view_store.cpp | 2 -- .../builtin/source/content/views/view_strings.cpp | 2 +- plugins/builtin/source/content/views/view_tools.cpp | 2 -- plugins/builtin/source/content/views/view_yara.cpp | 8 ++++---- plugins/builtin/source/math_evaluator.cpp | 4 ++-- plugins/windows/include/views/view_tty_console.hpp | 6 +----- plugins/windows/source/views/view_tty_console.cpp | 5 +---- tests/common/include/hex/test/test_provider.hpp | 6 +++--- tests/common/include/hex/test/tests.hpp | 2 +- tests/pattern_language/include/test_provider.hpp | 2 +- 64 files changed, 91 insertions(+), 152 deletions(-) diff --git a/README.md b/README.md index 1ca1db605..281588ed9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ If you like my work, please consider supporting me on GitHub Sponsors, Patreon o - Hex string - C, C++, C#, Rust, Python, Java & JavaScript array - ASCII-Art hex view - - HTML self contained div + - HTML self-contained div - String and hex search - Colorful highlighting - Goto from start, end and current cursor position @@ -84,7 +84,7 @@ If you like my work, please consider supporting me on GitHub Sponsors, Patreon o - Built-in Content Store - Download all files found in the database directly from within ImHex - Yara Rules support - - Quickly scan a file for vulnearabilities with official yara rules + - Quickly scan a file for vulnerabilities with official yara rules - Helpful tools - Itanium and MSVC demangler - ASCII table @@ -98,7 +98,7 @@ If you like my work, please consider supporting me on GitHub Sponsors, Patreon o - File utilities - File splitter - File combiner - - File shredderer + - File shredder - Built-in cheat sheet for pattern language and Math evaluator - Doesn't burn out your retinas when used in late-night sessions @@ -108,7 +108,7 @@ The custom C-like Pattern Language developed and used by ImHex is easy to read, ## Plugin development -To develop plugins for ImHex, use one of the following two templates projects to get startet. You then have access to the entirety of libimhex as well as the ImHex API and the Content Registry to interact with ImHex or to add new content. +To develop plugins for ImHex, use one of the following two templates projects to get started. You then have access to the entirety of libimhex as well as the ImHex API and the Content Registry to interact with ImHex or to add new content. - [C++ Plugin Template](https://github.com/WerWolv/ImHex-Cpp-Plugin-Template) - [Rust Plugin Template](https://github.com/WerWolv/ImHex-Rust-Plugin-Template) @@ -230,7 +230,7 @@ with the environment variables `XDG_CONFIG_HOME`, `XDG_CONFIG_DIRS`, - [Mary](https://github.com/Thog) for her immense help porting ImHex to MacOS and help during development - [Roblabla](https://github.com/Roblabla) for adding MSI Installer support to ImHex - [jam1garner](https://github.com/jam1garner) and [raytwo](https://github.com/raytwo) for their help with adding Rust support to plugins -- All other people that have been reporting issues on Discord or GitHub that I had great conversations with :) +- Everybody else who has reported issues on Discord or GitHub that I had great conversations with :) ### Libraries diff --git a/lib/libimhex/include/hex/api/localization.hpp b/lib/libimhex/include/hex/api/localization.hpp index e88ca75f8..150838cdc 100644 --- a/lib/libimhex/include/hex/api/localization.hpp +++ b/lib/libimhex/include/hex/api/localization.hpp @@ -11,7 +11,7 @@ namespace hex { public: LanguageDefinition(std::initializer_list> entries); - const std::map &getEntries() const; + [[nodiscard]] const std::map &getEntries() const; private: std::map m_entries; @@ -20,7 +20,7 @@ namespace hex { class LangEntry { public: explicit LangEntry(const char *unlocalizedString); - explicit LangEntry(const std::string &unlocalizedString); + explicit LangEntry(std::string unlocalizedString); explicit LangEntry(std::string_view unlocalizedString); operator std::string() const; diff --git a/lib/libimhex/include/hex/data_processor/node.hpp b/lib/libimhex/include/hex/data_processor/node.hpp index 672ca33e7..c2e87c451 100644 --- a/lib/libimhex/include/hex/data_processor/node.hpp +++ b/lib/libimhex/include/hex/data_processor/node.hpp @@ -93,7 +93,7 @@ namespace hex::dp { u64 getIntegerOnInput(u32 index); float getFloatOnInput(u32 index); - void setBufferOnOutput(u32 index, std::vector data); + void setBufferOnOutput(u32 index, const std::vector &data); void setIntegerOnOutput(u32 index, u64 integer); void setFloatOnOutput(u32 index, float floatingPoint); diff --git a/lib/libimhex/include/hex/helpers/disassembler.hpp b/lib/libimhex/include/hex/helpers/disassembler.hpp index 4e160f4a8..27208e1d7 100644 --- a/lib/libimhex/include/hex/helpers/disassembler.hpp +++ b/lib/libimhex/include/hex/helpers/disassembler.hpp @@ -31,12 +31,12 @@ namespace hex { class Disassembler { public: - static constexpr cs_arch toCapstoneArchictecture(Architecture architecture) { + static constexpr cs_arch toCapstoneArchitecture(Architecture architecture) { return static_cast(architecture); } static inline bool isSupported(Architecture architecture) { - return cs_support(toCapstoneArchictecture(architecture)); + return cs_support(toCapstoneArchitecture(architecture)); } constexpr static const char *const ArchitectureNames[] = { "ARM32", "ARM64", "MIPS", "x86", "PowerPC", "Sparc", "SystemZ", "XCore", "68K", "TMS320C64x", "680X", "Ethereum", "MOS65XX", "WebAssembly", "Berkeley Packet Filter", "RISC-V" }; diff --git a/lib/libimhex/include/hex/helpers/fs.hpp b/lib/libimhex/include/hex/helpers/fs.hpp index 00557d356..d4f5ad669 100644 --- a/lib/libimhex/include/hex/helpers/fs.hpp +++ b/lib/libimhex/include/hex/helpers/fs.hpp @@ -51,7 +51,7 @@ namespace hex::fs { else return size; } - bool isPathWritable(std::fs::path path); + bool isPathWritable(const std::fs::path &path); enum class DialogMode { diff --git a/lib/libimhex/include/hex/helpers/socket.hpp b/lib/libimhex/include/hex/helpers/socket.hpp index 890828aed..9c1cc63fa 100644 --- a/lib/libimhex/include/hex/helpers/socket.hpp +++ b/lib/libimhex/include/hex/helpers/socket.hpp @@ -26,7 +26,7 @@ namespace hex { public: Socket() = default; Socket(const Socket &) = delete; - Socket(Socket &&other); + Socket(Socket &&other) noexcept; Socket(const std::string &address, u16 port); ~Socket(); @@ -36,8 +36,8 @@ namespace hex { [[nodiscard]] bool isConnected() const; - std::string readString(size_t size = 0x1000) const; - std::vector readBytes(size_t size = 0x1000) const; + [[nodiscard]] std::string readString(size_t size = 0x1000) const; + [[nodiscard]] std::vector readBytes(size_t size = 0x1000) const; void writeString(const std::string &string) const; void writeBytes(const std::vector &bytes) const; diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index 5046d8627..4e2205333 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -303,7 +303,7 @@ namespace hex { bool m_active; public: - constexpr ScopeGuard(F func) : m_func(std::move(func)), m_active(true) { } + explicit constexpr ScopeGuard(F func) : m_func(std::move(func)), m_active(true) { } ~ScopeGuard() { if (this->m_active) { this->m_func(); } } @@ -334,7 +334,7 @@ namespace hex { template class FirstTimeExecute { public: - constexpr FirstTimeExecute(F func) { func(); } + explicit constexpr FirstTimeExecute(F func) { func(); } FirstTimeExecute &operator=(FirstTimeExecute &&) = delete; }; @@ -359,7 +359,7 @@ namespace hex { F m_func; public: - constexpr FinalCleanupExecute(F func) : m_func(func) { } + explicit constexpr FinalCleanupExecute(F func) : m_func(func) { } constexpr ~FinalCleanupExecute() { this->m_func(); } FinalCleanupExecute &operator=(FinalCleanupExecute &&) = delete; diff --git a/lib/libimhex/include/hex/pattern_language/ast/ast_node_array_variable_decl.hpp b/lib/libimhex/include/hex/pattern_language/ast/ast_node_array_variable_decl.hpp index 0466c16e0..8c2c6c398 100644 --- a/lib/libimhex/include/hex/pattern_language/ast/ast_node_array_variable_decl.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast/ast_node_array_variable_decl.hpp @@ -298,11 +298,11 @@ namespace hex::pl { } } - arrayPattern->setEntries(std::move(entries)); if (auto &arrayEntries = arrayPattern->getEntries(); !entries.empty()) arrayPattern->setTypeName(arrayEntries.front()->getTypeName()); + arrayPattern->setEntries(std::move(entries)); arrayPattern->setSize(size); return std::move(arrayPattern); diff --git a/lib/libimhex/include/hex/pattern_language/ast/ast_node_bitfield.hpp b/lib/libimhex/include/hex/pattern_language/ast/ast_node_bitfield.hpp index 413ce4e11..c8acddd8a 100644 --- a/lib/libimhex/include/hex/pattern_language/ast/ast_node_bitfield.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast/ast_node_bitfield.hpp @@ -38,7 +38,7 @@ namespace hex::pl { std::vector> entries; for (const auto &[name, entry] : this->m_entries) - entries.push_back({ name, entry.get() }); + entries.emplace_back(name, entry.get()); if (order == BitfieldOrder::LeftToRight) std::reverse(entries.begin(), entries.end()); diff --git a/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp b/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp index 0b16559d5..bc774e490 100644 --- a/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast/ast_node_control_flow_statement.hpp @@ -22,10 +22,6 @@ namespace hex::pl { return std::unique_ptr(new ASTNodeControlFlowStatement(*this)); } - [[nodiscard]] const std::unique_ptr &getReturnValue() const { - return this->m_rvalue; - } - [[nodiscard]] std::vector> createPatterns(Evaluator *evaluator) const override { this->execute(evaluator); diff --git a/lib/libimhex/include/hex/pattern_language/ast/ast_node_union.hpp b/lib/libimhex/include/hex/pattern_language/ast/ast_node_union.hpp index 736cf89e8..4d5cd3e7c 100644 --- a/lib/libimhex/include/hex/pattern_language/ast/ast_node_union.hpp +++ b/lib/libimhex/include/hex/pattern_language/ast/ast_node_union.hpp @@ -52,7 +52,6 @@ namespace hex::pl { } [[nodiscard]] const std::vector> &getMembers() const { return this->m_members; } - void addMember(std::shared_ptr &&node) { this->m_members.push_back(std::move(node)); } private: std::vector> m_members; diff --git a/lib/libimhex/include/hex/pattern_language/evaluator.hpp b/lib/libimhex/include/hex/pattern_language/evaluator.hpp index 0103c944a..59e628fb6 100644 --- a/lib/libimhex/include/hex/pattern_language/evaluator.hpp +++ b/lib/libimhex/include/hex/pattern_language/evaluator.hpp @@ -77,11 +77,11 @@ namespace hex::pl { this->m_scopes.pop_back(); } - Scope &getScope(i32 index) { + [[nodiscard]] Scope &getScope(i32 index) { return this->m_scopes[this->m_scopes.size() - 1 + index]; } - const Scope &getScope(i32 index) const { + [[nodiscard]] const Scope &getScope(i32 index) const { return this->m_scopes[this->m_scopes.size() - 1 + index]; } @@ -151,11 +151,11 @@ namespace hex::pl { this->m_patternLimit = limit; } - [[nodiscard]] u64 getPatternLimit() { + [[nodiscard]] u64 getPatternLimit() const { return this->m_patternLimit; } - [[nodiscard]] u64 getPatternCount() { + [[nodiscard]] u64 getPatternCount() const { return this->m_currPatternCount; } @@ -163,7 +163,7 @@ namespace hex::pl { this->m_loopLimit = limit; } - [[nodiscard]] u64 getLoopLimit() { + [[nodiscard]] u64 getLoopLimit() const { return this->m_loopLimit; } diff --git a/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp b/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp index 5f28792a8..c63c4a179 100644 --- a/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp +++ b/lib/libimhex/include/hex/pattern_language/patterns/pattern.hpp @@ -258,7 +258,7 @@ namespace hex::pl { ImGui::TableNextColumn(); ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", this->getTypeName().empty() ? this->getFormattedName() : this->getTypeName()); ImGui::TableNextColumn(); - ImGui::TextFormatted("{}", formatDisplayValue(value, std::move(literal))); + ImGui::TextFormatted("{}", formatDisplayValue(value, literal)); } void drawCommentTooltip() const { diff --git a/lib/libimhex/include/hex/pattern_language/patterns/pattern_enum.hpp b/lib/libimhex/include/hex/pattern_language/patterns/pattern_enum.hpp index 115b1d8b3..1a0dfe343 100644 --- a/lib/libimhex/include/hex/pattern_language/patterns/pattern_enum.hpp +++ b/lib/libimhex/include/hex/pattern_language/patterns/pattern_enum.hpp @@ -70,10 +70,6 @@ namespace hex::pl { return "enum " + Pattern::getTypeName(); } - [[nodiscard]] const auto &getEnumValues() const { - return this->m_enumValues; - } - void setEnumValues(const std::vector> &enumValues) { this->m_enumValues = enumValues; } diff --git a/lib/libimhex/include/hex/pattern_language/preprocessor.hpp b/lib/libimhex/include/hex/pattern_language/preprocessor.hpp index 7786fabdf..57928ed44 100644 --- a/lib/libimhex/include/hex/pattern_language/preprocessor.hpp +++ b/lib/libimhex/include/hex/pattern_language/preprocessor.hpp @@ -27,7 +27,7 @@ namespace hex::pl { const std::optional &getError() { return this->m_error; } - bool shouldOnlyIncludeOnce() { + [[nodiscard]] bool shouldOnlyIncludeOnce() const { return this->m_onlyIncludeOnce; } diff --git a/lib/libimhex/include/hex/providers/overlay.hpp b/lib/libimhex/include/hex/providers/overlay.hpp index 02c40bda7..1fd8a52b2 100644 --- a/lib/libimhex/include/hex/providers/overlay.hpp +++ b/lib/libimhex/include/hex/providers/overlay.hpp @@ -8,7 +8,7 @@ namespace hex::prv { class Overlay { public: - Overlay() { } + Overlay() = default; void setAddress(u64 address) { this->m_address = address; } [[nodiscard]] u64 getAddress() const { return this->m_address; } diff --git a/lib/libimhex/source/api/content_registry.cpp b/lib/libimhex/source/api/content_registry.cpp index 1d63773a9..993880427 100644 --- a/lib/libimhex/source/api/content_registry.cpp +++ b/lib/libimhex/source/api/content_registry.cpp @@ -57,7 +57,7 @@ namespace hex { void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue, const Callback &callback, bool requiresRestart) { log::info("Registered new integer setting: [{}]: {}", unlocalizedCategory, unlocalizedName); - getCategoryEntry(unlocalizedCategory)->second.emplace_back(Entry { unlocalizedName.c_str(), requiresRestart, callback }); + getCategoryEntry(unlocalizedCategory)->second.emplace_back(Entry { unlocalizedName, requiresRestart, callback }); auto &json = getSettingsData(); diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index d5fa6b314..e5071e477 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -169,7 +169,7 @@ namespace hex { namespace ImHexApi::Tasks { Task createTask(const std::string &unlocalizedName, u64 maxValue) { - return Task(unlocalizedName, maxValue); + return { unlocalizedName, maxValue }; } diff --git a/lib/libimhex/source/api/localization.cpp b/lib/libimhex/source/api/localization.cpp index 363dba82d..17fdbd5fd 100644 --- a/lib/libimhex/source/api/localization.cpp +++ b/lib/libimhex/source/api/localization.cpp @@ -8,7 +8,7 @@ namespace hex { std::map LangEntry::s_currStrings; LanguageDefinition::LanguageDefinition(std::initializer_list> entries) { - for (auto pair : entries) + for (const auto &pair : entries) this->m_entries.insert(pair); } @@ -17,7 +17,7 @@ namespace hex { } LangEntry::LangEntry(const char *unlocalizedString) : m_unlocalizedString(unlocalizedString) { } - LangEntry::LangEntry(const std::string &unlocalizedString) : m_unlocalizedString(unlocalizedString) { } + LangEntry::LangEntry(std::string unlocalizedString) : m_unlocalizedString(std::move(unlocalizedString)) { } LangEntry::LangEntry(std::string_view unlocalizedString) : m_unlocalizedString(unlocalizedString) { } LangEntry::operator std::string() const { diff --git a/lib/libimhex/source/data_processor/node.cpp b/lib/libimhex/source/data_processor/node.cpp index 5d5571256..ca0619c60 100644 --- a/lib/libimhex/source/data_processor/node.cpp +++ b/lib/libimhex/source/data_processor/node.cpp @@ -80,7 +80,7 @@ namespace hex::dp { return *reinterpret_cast(outputData->data()); } - void Node::setBufferOnOutput(u32 index, std::vector data) { + void Node::setBufferOnOutput(u32 index, const std::vector &data) { if (index >= this->getAttributes().size()) throw std::runtime_error("Attribute index out of bounds!"); diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index cc46d439c..ba2835e0e 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -38,7 +38,7 @@ namespace hex::fs { } - bool isPathWritable(std::fs::path path) { + bool isPathWritable(const std::fs::path &path) { constexpr static auto TestFileName = "__imhex__tmp__"; { File file(path / TestFileName, File::Mode::Read); diff --git a/lib/libimhex/source/helpers/loader_script_handler.cpp b/lib/libimhex/source/helpers/loader_script_handler.cpp index 9d58ed2a7..afdc4d521 100644 --- a/lib/libimhex/source/helpers/loader_script_handler.cpp +++ b/lib/libimhex/source/helpers/loader_script_handler.cpp @@ -68,7 +68,7 @@ namespace hex { Py_RETURN_NONE; } - static PyObject *createStructureType(std::string keyword, PyObject *args) { + static PyObject *createStructureType(const std::string &keyword, PyObject *args) { auto type = PyTuple_GetItem(args, 0); if (type == nullptr) { PyErr_BadArgument(); diff --git a/lib/libimhex/source/helpers/patches.cpp b/lib/libimhex/source/helpers/patches.cpp index 49887b601..853dfe596 100644 --- a/lib/libimhex/source/helpers/patches.cpp +++ b/lib/libimhex/source/helpers/patches.cpp @@ -156,7 +156,7 @@ namespace hex { ipsOffset += 1; } - if (std::memcmp(ipsPatch.data(), "EOF", 3)) + if (std::memcmp(ipsPatch.data(), "EOF", 3) == 0) foundEOF = true; } @@ -207,7 +207,7 @@ namespace hex { ipsOffset += 1; } - if (std::memcmp(ipsPatch.data(), "EEOF", 4)) + if (std::memcmp(ipsPatch.data(), "EEOF", 4) == 0) foundEEOF = true; } diff --git a/lib/libimhex/source/helpers/socket.cpp b/lib/libimhex/source/helpers/socket.cpp index ba332ffc0..8c93a9108 100644 --- a/lib/libimhex/source/helpers/socket.cpp +++ b/lib/libimhex/source/helpers/socket.cpp @@ -20,7 +20,7 @@ namespace hex { this->connect(address, port); } - Socket::Socket(Socket &&other) { + Socket::Socket(Socket &&other) noexcept { this->m_socket = other.m_socket; this->m_connected = other.m_connected; diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 57272a74a..22dc8b0d8 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -49,7 +49,7 @@ namespace hex { index--; } - return std::string(data + index + 1); + return { data + index + 1 }; } std::string to_string(i128 value) { @@ -66,9 +66,9 @@ namespace hex { if (value < 0) { data[index] = '-'; - return std::string(data + index); + return { data + index }; } else - return std::string(data + index + 1); + return { data + index + 1 }; } std::string toByteString(u64 bytes) { diff --git a/lib/libimhex/source/pattern_language/preprocessor.cpp b/lib/libimhex/source/pattern_language/preprocessor.cpp index d374ff784..e52dad59e 100644 --- a/lib/libimhex/source/pattern_language/preprocessor.cpp +++ b/lib/libimhex/source/pattern_language/preprocessor.cpp @@ -90,8 +90,10 @@ namespace hex::pl { auto preprocessedInclude = preprocessor.preprocess(file.readString(), /*initialRun =*/false); - if (!preprocessedInclude.has_value()) - throw *preprocessor.m_error; + if (!preprocessedInclude.has_value()) { + auto error = *preprocessor.m_error; + throw error; + } if (preprocessor.shouldOnlyIncludeOnce()) { auto [iter, added] = this->m_onceIncludedFiles.insert(includePath); diff --git a/lib/libimhex/source/ui/view.cpp b/lib/libimhex/source/ui/view.cpp index 8897ec8c9..5cff78b1e 100644 --- a/lib/libimhex/source/ui/view.cpp +++ b/lib/libimhex/source/ui/view.cpp @@ -20,7 +20,7 @@ namespace hex { ImFontAtlas *View::s_fontAtlas; ImFontConfig View::s_fontConfig; - View::View(std::string unlocalizedName) : m_unlocalizedViewName(unlocalizedName) { } + View::View(std::string unlocalizedName) : m_unlocalizedViewName(std::move(unlocalizedName)) { } bool View::isAvailable() const { return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable(); diff --git a/main/include/init/splash_window.hpp b/main/include/init/splash_window.hpp index 2143f6260..fe7ff8ac8 100644 --- a/main/include/init/splash_window.hpp +++ b/main/include/init/splash_window.hpp @@ -23,7 +23,7 @@ namespace hex::init { this->m_tasks.emplace_back(taskName, task); } - const std::string &getGPUVendor() const { return this->m_gpuVendor; } + [[nodiscard]] const std::string &getGPUVendor() const { return this->m_gpuVendor; } private: GLFWwindow *m_window; diff --git a/main/source/window/win_window.cpp b/main/source/window/win_window.cpp index f154b4c8a..c8e0a114f 100644 --- a/main/source/window/win_window.cpp +++ b/main/source/window/win_window.cpp @@ -81,6 +81,8 @@ namespace hex { case HTCLIENT: g_mouseCursorIcon = ImGuiMouseCursor_None; break; + default: + break; } return TRUE; diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index 3948289d8..7c535a1bd 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include diff --git a/plugins/builtin/include/content/providers/disk_provider.hpp b/plugins/builtin/include/content/providers/disk_provider.hpp index a587ab143..1a7e98ea1 100644 --- a/plugins/builtin/include/content/providers/disk_provider.hpp +++ b/plugins/builtin/include/content/providers/disk_provider.hpp @@ -51,10 +51,10 @@ namespace hex::plugin::builtin::prv { int m_diskHandle = -1; #endif - size_t m_diskSize; - size_t m_sectorSize; + size_t m_diskSize = 0; + size_t m_sectorSize = 0; - u64 m_sectorBufferAddress; + u64 m_sectorBufferAddress = 0; std::vector m_sectorBuffer; bool m_readable = false; diff --git a/plugins/builtin/include/content/providers/gdb_provider.hpp b/plugins/builtin/include/content/providers/gdb_provider.hpp index 667def707..7c042bac1 100644 --- a/plugins/builtin/include/content/providers/gdb_provider.hpp +++ b/plugins/builtin/include/content/providers/gdb_provider.hpp @@ -46,9 +46,9 @@ namespace hex::plugin::builtin::prv { hex::Socket m_socket; std::string m_ipAddress; - int m_port; + int m_port = 0; - u64 m_size; + u64 m_size = 0; constexpr static size_t CacheLineSize = 0x1000; diff --git a/plugins/builtin/include/content/views/view_about.hpp b/plugins/builtin/include/content/views/view_about.hpp index 8d7d7b0e1..86d973d60 100644 --- a/plugins/builtin/include/content/views/view_about.hpp +++ b/plugins/builtin/include/content/views/view_about.hpp @@ -11,10 +11,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewAbout : public View { public: ViewAbout(); @@ -22,11 +18,11 @@ namespace hex::plugin::builtin { void drawContent() override; - bool isAvailable() const override { return true; } - bool hasViewMenuItemEntry() const override { return false; } + [[nodiscard]] bool isAvailable() const override { return true; } + [[nodiscard]] bool hasViewMenuItemEntry() const override { return false; } - ImVec2 getMinSize() const override { - return ImVec2(400, 300); + [[nodiscard]] ImVec2 getMinSize() const override { + return { 400, 300 }; } private: diff --git a/plugins/builtin/include/content/views/view_command_palette.hpp b/plugins/builtin/include/content/views/view_command_palette.hpp index a2b33f725..dea5f7fa2 100644 --- a/plugins/builtin/include/content/views/view_command_palette.hpp +++ b/plugins/builtin/include/content/views/view_command_palette.hpp @@ -14,7 +14,7 @@ namespace hex::plugin::builtin { class ViewCommandPalette : public View { public: ViewCommandPalette(); - ~ViewCommandPalette() override; + ~ViewCommandPalette() override = default; void drawContent() override; @@ -26,7 +26,8 @@ namespace hex::plugin::builtin { [[nodiscard]] ImVec2 getMaxSize() const override { return { 400, 100 }; } private: - enum class MatchType { + enum class MatchType + { NoMatch, InfoMatch, PartialMatch, diff --git a/plugins/builtin/include/content/views/view_constants.hpp b/plugins/builtin/include/content/views/view_constants.hpp index c502755d1..b02f3376e 100644 --- a/plugins/builtin/include/content/views/view_constants.hpp +++ b/plugins/builtin/include/content/views/view_constants.hpp @@ -7,7 +7,8 @@ namespace hex::plugin::builtin { - enum class ConstantType { + enum class ConstantType + { Int10, Int16BigEndian, Int16LittleEndian @@ -23,7 +24,7 @@ namespace hex::plugin::builtin { class ViewConstants : public View { public: explicit ViewConstants(); - ~ViewConstants() override; + ~ViewConstants() override = default; void drawContent() override; diff --git a/plugins/builtin/include/content/views/view_data_inspector.hpp b/plugins/builtin/include/content/views/view_data_inspector.hpp index 81402b6cb..8f43d296c 100644 --- a/plugins/builtin/include/content/views/view_data_inspector.hpp +++ b/plugins/builtin/include/content/views/view_data_inspector.hpp @@ -10,10 +10,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewDataInspector : public View { public: explicit ViewDataInspector(); diff --git a/plugins/builtin/include/content/views/view_data_processor.hpp b/plugins/builtin/include/content/views/view_data_processor.hpp index ae15e615f..422db0765 100644 --- a/plugins/builtin/include/content/views/view_data_processor.hpp +++ b/plugins/builtin/include/content/views/view_data_processor.hpp @@ -12,10 +12,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewDataProcessor : public View { public: ViewDataProcessor(); diff --git a/plugins/builtin/include/content/views/view_diff.hpp b/plugins/builtin/include/content/views/view_diff.hpp index 7ade7e72b..c18456c10 100644 --- a/plugins/builtin/include/content/views/view_diff.hpp +++ b/plugins/builtin/include/content/views/view_diff.hpp @@ -11,10 +11,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewDiff : public View { public: ViewDiff(); diff --git a/plugins/builtin/include/content/views/view_disassembler.hpp b/plugins/builtin/include/content/views/view_disassembler.hpp index d45731dbc..208d1585d 100644 --- a/plugins/builtin/include/content/views/view_disassembler.hpp +++ b/plugins/builtin/include/content/views/view_disassembler.hpp @@ -10,10 +10,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - struct Disassembly { u64 address; u64 offset; diff --git a/plugins/builtin/include/content/views/view_hashes.hpp b/plugins/builtin/include/content/views/view_hashes.hpp index 2e74bdf98..fda7b6f2c 100644 --- a/plugins/builtin/include/content/views/view_hashes.hpp +++ b/plugins/builtin/include/content/views/view_hashes.hpp @@ -8,10 +8,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewHashes : public View { public: explicit ViewHashes(); @@ -20,7 +16,8 @@ namespace hex::plugin::builtin { void drawContent() override; private: - enum class HashFunctions { + enum class HashFunctions + { Crc8, Crc16, Crc32, diff --git a/plugins/builtin/include/content/views/view_hex_editor.hpp b/plugins/builtin/include/content/views/view_hex_editor.hpp index 2e2c2f32b..044f0c4b0 100644 --- a/plugins/builtin/include/content/views/view_hex_editor.hpp +++ b/plugins/builtin/include/content/views/view_hex_editor.hpp @@ -26,7 +26,7 @@ namespace hex::plugin::builtin { constexpr static size_t Size = 0x2000; - u64 base; + u64 base = 0x00; std::array highlight; }; diff --git a/plugins/builtin/include/content/views/view_information.hpp b/plugins/builtin/include/content/views/view_information.hpp index b94c6ec26..b8a7096e3 100644 --- a/plugins/builtin/include/content/views/view_information.hpp +++ b/plugins/builtin/include/content/views/view_information.hpp @@ -10,10 +10,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewInformation : public View { public: explicit ViewInformation(); diff --git a/plugins/builtin/include/content/views/view_patches.hpp b/plugins/builtin/include/content/views/view_patches.hpp index 08ed9db8d..ec782dd7f 100644 --- a/plugins/builtin/include/content/views/view_patches.hpp +++ b/plugins/builtin/include/content/views/view_patches.hpp @@ -9,10 +9,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewPatches : public View { public: explicit ViewPatches(); @@ -21,7 +17,7 @@ namespace hex::plugin::builtin { void drawContent() override; private: - u64 m_selectedPatch; + u64 m_selectedPatch = 0x00; }; } \ No newline at end of file diff --git a/plugins/builtin/include/content/views/view_store.hpp b/plugins/builtin/include/content/views/view_store.hpp index faf07a029..ffc4b8be5 100644 --- a/plugins/builtin/include/content/views/view_store.hpp +++ b/plugins/builtin/include/content/views/view_store.hpp @@ -30,7 +30,7 @@ namespace hex::plugin::builtin { class ViewStore : public View { public: ViewStore(); - ~ViewStore() override; + ~ViewStore() override = default; void drawContent() override; diff --git a/plugins/builtin/include/content/views/view_strings.hpp b/plugins/builtin/include/content/views/view_strings.hpp index 4464c8004..ad94f34f9 100644 --- a/plugins/builtin/include/content/views/view_strings.hpp +++ b/plugins/builtin/include/content/views/view_strings.hpp @@ -7,10 +7,6 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - struct FoundString { u64 offset; size_t size; diff --git a/plugins/builtin/include/content/views/view_tools.hpp b/plugins/builtin/include/content/views/view_tools.hpp index abeda3916..cb3dea9b4 100644 --- a/plugins/builtin/include/content/views/view_tools.hpp +++ b/plugins/builtin/include/content/views/view_tools.hpp @@ -10,14 +10,10 @@ namespace hex::plugin::builtin { - namespace prv { - class Provider; - } - class ViewTools : public View { public: ViewTools(); - ~ViewTools() override; + ~ViewTools() override = default; void drawContent() override; }; diff --git a/plugins/builtin/source/content/data_processor_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes.cpp index 763d10172..0c7c28c8f 100644 --- a/plugins/builtin/source/content/data_processor_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes.cpp @@ -420,7 +420,7 @@ namespace hex::plugin::builtin { void process() override { auto input = this->getBufferOnInput(0); - if (input.size() == 0 || input.size() > sizeof(u64)) + if (input.empty() || input.size() > sizeof(u64)) throwNodeError("Buffer is empty or bigger than 64 bits"); u64 output = 0; @@ -785,7 +785,7 @@ namespace hex::plugin::builtin { float xStep = (viewSize.x * 0.95F) / 0xFF; float yStep = (viewSize.y * 0.95F) / 0xFF; - for (size_t i = 0; i < ((this->m_buffer.size() == 0) ? 0 : this->m_buffer.size() - 1); i++) { + for (size_t i = 0; i < (this->m_buffer.empty() ? 0 : this->m_buffer.size() - 1); i++) { const auto &[x, y] = std::pair { this->m_buffer[i] * xStep, this->m_buffer[i + 1] * yStep }; auto color = ImLerp(ImColor(0xFF, 0x6D, 0x01).Value, ImColor(0x01, 0x93, 0xFF).Value, float(i) / this->m_buffer.size()); @@ -868,7 +868,7 @@ namespace hex::plugin::builtin { float xStep = (viewSize.x * 0.95F) / 0xFF; float yStep = (viewSize.y * 0.95F) / 0xFF; - for (size_t i = 0; i < ((this->m_buffer.size() == 0) ? 0 : this->m_buffer.size()); i++) { + for (size_t i = 0; i < (this->m_buffer.empty() ? 0 : this->m_buffer.size()); i++) { const auto &[x, y] = std::pair { this->m_buffer[i] * xStep, yStep * ((float(i) / this->m_buffer.size()) * 0xFF) }; auto color = ImLerp(ImColor(0xFF, 0x6D, 0x01).Value, ImColor(0x01, 0x93, 0xFF).Value, float(i) / this->m_buffer.size()); diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index afce09630..6b12b4394 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -294,7 +294,7 @@ namespace hex::plugin::builtin { ImGui::BeginGroup(); if (ImGui::IconButton(ICON_VS_NEW_FOLDER, ImGui::GetCustomColorVec4(ImGuiCustomCol_DescButton), ImVec2(30, 30))) { - fs::openFileBrowser("Select include folder", fs::DialogMode::Folder, {}, [&](std::fs::path path) { + fs::openFileBrowser("Select include folder", fs::DialogMode::Folder, {}, [&](const std::fs::path &path) { auto pathStr = path.string(); if (std::find(folders.begin(), folders.end(), pathStr) == folders.end()) { diff --git a/plugins/builtin/source/content/views/view_command_palette.cpp b/plugins/builtin/source/content/views/view_command_palette.cpp index c268d6035..c376faabf 100644 --- a/plugins/builtin/source/content/views/view_command_palette.cpp +++ b/plugins/builtin/source/content/views/view_command_palette.cpp @@ -16,9 +16,6 @@ namespace hex::plugin::builtin { }); } - ViewCommandPalette::~ViewCommandPalette() { - } - void ViewCommandPalette::drawContent() { if (!this->m_commandPaletteOpen) return; diff --git a/plugins/builtin/source/content/views/view_constants.cpp b/plugins/builtin/source/content/views/view_constants.cpp index 91a138578..b97d722d0 100644 --- a/plugins/builtin/source/content/views/view_constants.cpp +++ b/plugins/builtin/source/content/views/view_constants.cpp @@ -17,9 +17,6 @@ namespace hex::plugin::builtin { std::memset(this->m_filter.data(), 0x00, this->m_filter.capacity()); } - ViewConstants::~ViewConstants() { - } - void ViewConstants::reloadConstants() { this->m_constants.clear(); this->m_filterIndices.clear(); diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index 54e77d61c..0f6ac4d89 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -6,8 +6,6 @@ #include -extern int ImTextCharFromUtf8(unsigned int *out_char, const char *in_text, const char *in_text_end); - namespace hex::plugin::builtin { using NumberDisplayStyle = ContentRegistry::DataInspector::NumberDisplayStyle; diff --git a/plugins/builtin/source/content/views/view_disassembler.cpp b/plugins/builtin/source/content/views/view_disassembler.cpp index 0e29f1833..48488b422 100644 --- a/plugins/builtin/source/content/views/view_disassembler.cpp +++ b/plugins/builtin/source/content/views/view_disassembler.cpp @@ -47,7 +47,7 @@ namespace hex::plugin::builtin { cs_mode mode = this->m_mode; - if (cs_open(Disassembler::toCapstoneArchictecture(this->m_architecture), mode, &capstoneHandle) == CS_ERR_OK) { + if (cs_open(Disassembler::toCapstoneArchitecture(this->m_architecture), mode, &capstoneHandle) == CS_ERR_OK) { cs_option(capstoneHandle, CS_OPT_SKIPDATA, CS_OPT_ON); diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 3d8bddd95..53f507594 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -94,7 +94,7 @@ namespace hex::plugin::builtin { this->evaluatePattern(this->m_textEditor.GetText()); }); - EventManager::subscribe(this, [this](std::string code) { + EventManager::subscribe(this, [this](const std::string &code) { this->m_textEditor.SelectAll(); this->m_textEditor.Delete(); this->m_textEditor.InsertText(code); diff --git a/plugins/builtin/source/content/views/view_settings.cpp b/plugins/builtin/source/content/views/view_settings.cpp index 3a3108ea2..74f65f3b9 100644 --- a/plugins/builtin/source/content/views/view_settings.cpp +++ b/plugins/builtin/source/content/views/view_settings.cpp @@ -37,7 +37,7 @@ namespace hex::plugin::builtin { std::vector::const_iterator> sortedCategories; for (auto it = entries.cbegin(); it != entries.cend(); it++) { - sortedCategories.emplace_back(std::move(it)); + sortedCategories.emplace_back(it); } std::sort(sortedCategories.begin(), sortedCategories.end(), [](auto &item0, auto &item1) { diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index 9f3455779..75c3c795c 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -35,8 +35,6 @@ namespace hex::plugin::builtin { }); } - ViewStore::~ViewStore() { } - void ViewStore::drawStore() { ImGui::Header("hex.builtin.view.store.desc"_lang, true); diff --git a/plugins/builtin/source/content/views/view_strings.cpp b/plugins/builtin/source/content/views/view_strings.cpp index 9726f8bbd..c7aff0165 100644 --- a/plugins/builtin/source/content/views/view_strings.cpp +++ b/plugins/builtin/source/content/views/view_strings.cpp @@ -147,7 +147,7 @@ namespace hex::plugin::builtin { if (this->m_searching) { ImGui::SameLine(); ImGui::TextSpinner("hex.builtin.view.strings.searching"_lang); - } else if (this->m_foundStrings.size() > 0) { + } else if (!this->m_foundStrings.empty()) { ImGui::SameLine(); ImGui::TextFormatted("hex.builtin.view.strings.results"_lang, this->m_filterIndices.size()); } diff --git a/plugins/builtin/source/content/views/view_tools.cpp b/plugins/builtin/source/content/views/view_tools.cpp index ebfb1007e..a78006db4 100644 --- a/plugins/builtin/source/content/views/view_tools.cpp +++ b/plugins/builtin/source/content/views/view_tools.cpp @@ -6,8 +6,6 @@ namespace hex::plugin::builtin { ViewTools::ViewTools() : View("hex.builtin.view.tools.name") { } - ViewTools::~ViewTools() { } - void ViewTools::drawContent() { if (ImGui::Begin(View::toWindowName("hex.builtin.view.tools.name").c_str(), &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) { for (const auto &[name, function] : ContentRegistry::Tools::getEntries()) { diff --git a/plugins/builtin/source/content/views/view_yara.cpp b/plugins/builtin/source/content/views/view_yara.cpp index ad4f124be..fb0848b98 100644 --- a/plugins/builtin/source/content/views/view_yara.cpp +++ b/plugins/builtin/source/content/views/view_yara.cpp @@ -133,14 +133,14 @@ namespace hex::plugin::builtin { void ViewYara::reloadRules() { this->m_rules.clear(); - for (const auto path : fs::getDefaultPaths(fs::ImHexPath::Yara)) { + for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Yara)) { if (!fs::exists(path)) continue; std::error_code error; for (const auto &entry : std::fs::recursive_directory_iterator(path, error)) { if (entry.is_regular_file() && entry.path().extension() == ".yar") { - this->m_rules.push_back({ std::fs::relative(entry.path(), std::fs::path(path)).string(), entry.path().string() }); + this->m_rules.emplace_back(std::fs::relative(entry.path(), std::fs::path(path)).string(), entry.path().string()); } } } @@ -207,9 +207,9 @@ namespace hex::plugin::builtin { YR_MEMORY_BLOCK_ITERATOR iterator; struct ScanContext { - Task *task; + Task *task = nullptr; std::vector buffer; - YR_MEMORY_BLOCK currBlock; + YR_MEMORY_BLOCK currBlock = {}; }; ScanContext context; diff --git a/plugins/builtin/source/math_evaluator.cpp b/plugins/builtin/source/math_evaluator.cpp index feea48184..8817d6f6d 100644 --- a/plugins/builtin/source/math_evaluator.cpp +++ b/plugins/builtin/source/math_evaluator.cpp @@ -164,7 +164,7 @@ namespace hex { else if (expression.empty()) break; - auto newInputQueue = parseInput(expression.c_str()); + auto newInputQueue = parseInput(expression); auto postfixTokens = toPostfix(newInputQueue); auto result = evaluate(postfixTokens); @@ -321,7 +321,7 @@ namespace hex { std::optional MathEvaluator::evaluate(const std::string &input) { - auto inputQueue = parseInput(input.c_str()); + auto inputQueue = parseInput(input); std::string resultVariable = "ans"; diff --git a/plugins/windows/include/views/view_tty_console.hpp b/plugins/windows/include/views/view_tty_console.hpp index ecf05dad2..5305660d9 100644 --- a/plugins/windows/include/views/view_tty_console.hpp +++ b/plugins/windows/include/views/view_tty_console.hpp @@ -10,14 +10,10 @@ namespace hex::plugin::windows { - namespace prv { - class Provider; - } - class ViewTTYConsole : public View { public: ViewTTYConsole(); - ~ViewTTYConsole() override; + ~ViewTTYConsole() override = default; void drawContent() override; diff --git a/plugins/windows/source/views/view_tty_console.cpp b/plugins/windows/source/views/view_tty_console.cpp index 2aa1bbcc5..350b82b1b 100644 --- a/plugins/windows/source/views/view_tty_console.cpp +++ b/plugins/windows/source/views/view_tty_console.cpp @@ -13,9 +13,6 @@ namespace hex::plugin::windows { this->m_receiveDataBuffer.push_back(0x00); } - ViewTTYConsole::~ViewTTYConsole() { - } - void ViewTTYConsole::drawContent() { if (ImGui::Begin(View::toWindowName("hex.windows.view.tty_console.name").c_str(), &this->getWindowOpenState())) { @@ -185,7 +182,7 @@ namespace hex::plugin::windows { } bool ViewTTYConsole::connect() { - if (this->m_comPorts.size() == 0 || this->m_selectedPort >= this->m_comPorts.size()) { + if (this->m_comPorts.empty() || this->m_selectedPort >= this->m_comPorts.size()) { View::showErrorPopup("hex.windows.view.tty_console.no_available_port"_lang); return true; // If false, connect_error error popup will override this error popup } diff --git a/tests/common/include/hex/test/test_provider.hpp b/tests/common/include/hex/test/test_provider.hpp index 8f3afc454..90ab152b8 100644 --- a/tests/common/include/hex/test/test_provider.hpp +++ b/tests/common/include/hex/test/test_provider.hpp @@ -9,7 +9,7 @@ namespace hex::test { class TestProvider : public prv::Provider { public: - TestProvider(std::vector *data) : Provider() { + explicit TestProvider(std::vector *data) : Provider() { this->setData(data); } ~TestProvider() override = default; @@ -44,7 +44,7 @@ namespace hex::test { std::memcpy(m_data->data() + offset, buffer, size); } - size_t getActualSize() const override { + [[nodiscard]] size_t getActualSize() const override { return this->m_data->size(); } @@ -52,7 +52,7 @@ namespace hex::test { void close() override { } private: - std::vector *m_data; + std::vector *m_data = nullptr; }; } diff --git a/tests/common/include/hex/test/tests.hpp b/tests/common/include/hex/test/tests.hpp index a5ffc72b5..8b4910031 100644 --- a/tests/common/include/hex/test/tests.hpp +++ b/tests/common/include/hex/test/tests.hpp @@ -80,7 +80,7 @@ namespace hex::test { template - TestSequence operator+(TestSequenceExecutor executor, F &&f) noexcept { + TestSequence operator+(const TestSequenceExecutor &executor, F &&f) noexcept { return TestSequence(executor.getName(), std::forward(f), executor.shouldFail()); } diff --git a/tests/pattern_language/include/test_provider.hpp b/tests/pattern_language/include/test_provider.hpp index 1827ae617..a64ca1366 100644 --- a/tests/pattern_language/include/test_provider.hpp +++ b/tests/pattern_language/include/test_provider.hpp @@ -41,7 +41,7 @@ namespace hex::test { this->m_testFile.write(static_cast(buffer), size); } - size_t getActualSize() const override { + [[nodiscard]] size_t getActualSize() const override { return this->m_testFile.getSize(); }