From ae00ed80130920cc9254f4714b95c977607b1c0f Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 16 Jan 2022 18:54:58 +0000 Subject: [PATCH] Tidying --- src/Application.hpp | 1 - .../VendorSpecific/EDBG/AVR/AvrCommand.hpp | 13 +++++++------ .../VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp | 9 +++++---- src/Helpers/Paths.hpp | 6 +++--- .../TargetRegistersPane/RegisterGroupWidget.cpp | 6 +++--- .../TargetRegistersPaneWidget.cpp | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Application.hpp b/src/Application.hpp index be7da76f..80d01e44 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -209,7 +209,6 @@ namespace Bloom /** * Extracts or generates project settings. - * */ void loadProjectSettings(); diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp index d83dc66a..3deae24f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp" @@ -20,19 +21,19 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr */ [[nodiscard]] std::vector getData() const override; - [[nodiscard]] size_t getFragmentNumber() const { + [[nodiscard]] std::size_t getFragmentNumber() const { return this->fragmentNumber; } - void setFragmentNumber(size_t fragmentNumber) { + void setFragmentNumber(std::size_t fragmentNumber) { this->fragmentNumber = fragmentNumber; } - [[nodiscard]] size_t getFragmentCount() const { + [[nodiscard]] std::size_t getFragmentCount() const { return this->fragmentCount; } - void setFragmentCount(size_t fragmentCount) { + void setFragmentCount(std::size_t fragmentCount) { this->fragmentCount = fragmentCount; } @@ -45,8 +46,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr } private: - size_t fragmentNumber = 1; - size_t fragmentCount = 1; + std::size_t fragmentNumber = 1; + std::size_t fragmentCount = 1; std::vector commandPacket; }; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index 73e95550..ae4c2360 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "src/Exceptions/InvalidConfig.hpp" #include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp" @@ -58,7 +58,7 @@ void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) { if (physicalInterface.empty() || availablePhysicalInterfaces.find(physicalInterface) == availablePhysicalInterfaces.end() ) { - throw InvalidConfig("Invalid physical interface config parameter for AVR8 target."); + throw InvalidConfig("Invalid or missing physical interface config parameter for AVR8 target."); } auto selectedPhysicalInterface = availablePhysicalInterfaces.find(physicalInterface)->second; @@ -535,8 +535,9 @@ void EdbgAvr8Interface::writeRegisters(const Targets::TargetRegisters& registers if (registerValue.size() > registerDescriptor.size) { throw Exception("Register value exceeds size specified by register descriptor."); + } - } else if (registerValue.size() < registerDescriptor.size) { + if (registerValue.size() < registerDescriptor.size) { // Fill the missing most-significant bytes with 0x00 registerValue.insert(registerValue.begin(), registerDescriptor.size - registerValue.size(), 0x00); } @@ -1476,7 +1477,7 @@ void EdbgAvr8Interface::refreshTargetState() { auto avrEvent = this->getAvrEvent(); if (avrEvent != nullptr && avrEvent->getEventId() == AvrEventId::AVR8_BREAK_EVENT) { - auto breakEvent = dynamic_cast(avrEvent.get()); + auto* breakEvent = dynamic_cast(avrEvent.get()); if (breakEvent == nullptr) { throw Exception("Failed to process AVR8 break event"); diff --git a/src/Helpers/Paths.hpp b/src/Helpers/Paths.hpp index 0123455f..a6c9156b 100644 --- a/src/Helpers/Paths.hpp +++ b/src/Helpers/Paths.hpp @@ -39,7 +39,7 @@ namespace Bloom * @return */ static std::string projectConfigPath() { - return std::filesystem::current_path().string() + "/bloom.json"; + return Paths::projectDirPath() + "/bloom.json"; } /** @@ -48,7 +48,7 @@ namespace Bloom * @return */ static std::string projectSettingsDirPath() { - return std::filesystem::current_path().string() + "/.bloom"; + return Paths::projectDirPath() + "/.bloom"; } /** @@ -57,7 +57,7 @@ namespace Bloom * @return */ static std::string projectSettingsPath() { - return std::filesystem::current_path().string() + "/.bloom/settings.json"; + return Paths::projectSettingsDirPath() + "/settings.json"; } /** diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupWidget.cpp index e4bc3eca..e3f1d476 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/RegisterGroupWidget.cpp @@ -54,7 +54,7 @@ RegisterGroupWidget::RegisterGroupWidget( bodyLayout->setContentsMargins(0, 0,0,0); bodyLayout->setSpacing(0); - for (auto& descriptor : registerDescriptors) { + for (const auto& descriptor : registerDescriptors) { if (!descriptor.name.has_value()) { continue; } @@ -117,14 +117,14 @@ void RegisterGroupWidget::expand() { } void RegisterGroupWidget::setAllRegistersVisible(bool visible) { - for (auto& registerWidget : this->registerWidgets) { + for (const auto& registerWidget : this->registerWidgets) { registerWidget->setVisible(visible); } } void RegisterGroupWidget::filterRegisters(const std::string& keyword) { int matchingWidgetCount = 0; - for (auto& registerWidget : this->registerWidgets) { + for (const auto& registerWidget : this->registerWidgets) { if (keyword.empty() || (registerWidget->descriptor.name.value().find(keyword) != std::string::npos) ) { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp index 7791f0d3..616ba44e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/TargetRegistersPaneWidget.cpp @@ -126,7 +126,7 @@ TargetRegistersPaneWidget::TargetRegistersPaneWidget( void TargetRegistersPaneWidget::filterRegisters(const QString& keyword) { auto stdKeyword = keyword.toLower().toStdString(); - for (auto& registerGroupWidget : this->registerGroupWidgets) { + for (const auto& registerGroupWidget : this->registerGroupWidgets) { // If the group name matches the keyword, then don't bother iterating through all the register widgets if (keyword.isEmpty() || registerGroupWidget->name.contains(keyword, Qt::CaseInsensitive)) { registerGroupWidget->setVisible(true);