From dd204742d303aacc5fcaadde4976ed535b9d8bde Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 1 Jun 2022 21:48:27 +0100 Subject: [PATCH] Renamed Linux to GNU/Linux and other tidying --- README.md | 2 +- resources/help.txt | 2 +- src/DebugToolDrivers/USB/HID/HidInterface.cpp | 4 ++-- src/DebugToolDrivers/USB/HID/HidInterface.hpp | 2 +- src/Helpers/EpollInstance.cpp | 2 +- src/Helpers/EventFdNotifier.cpp | 4 ++-- src/SignalHandler/SignalHandler.cpp | 23 ++++++++++--------- src/SignalHandler/SignalHandler.hpp | 6 ++--- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 4 +--- src/VersionNumber.cpp | 5 +++- 10 files changed, 28 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index eb6dd766..2e4191c7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Bloom can be downloaded at https://bloom.oscillate.io/download. -Bloom is a debug interface for embedded systems development on Linux. This is the official repository for Bloom's +Bloom is a debug interface for embedded systems development on GNU/Linux. This is the official repository for Bloom's source code. For information on how to use Bloom, please visit https://bloom.oscillate.io. Bloom implements a number of user-space device drivers, enabling support for many debug tools (such as the Atmel-ICE, diff --git a/resources/help.txt b/resources/help.txt index 5d347c9f..43e77e6e 100644 --- a/resources/help.txt +++ b/resources/help.txt @@ -1,4 +1,4 @@ -A debug interface for embedded systems development on Linux. +A debug interface for embedded systems development on GNU/Linux. Usage: bloom [ENVIRONMENT_NAME/COMMAND] diff --git a/src/DebugToolDrivers/USB/HID/HidInterface.cpp b/src/DebugToolDrivers/USB/HID/HidInterface.cpp index 04dbf292..2d33a786 100644 --- a/src/DebugToolDrivers/USB/HID/HidInterface.cpp +++ b/src/DebugToolDrivers/USB/HID/HidInterface.cpp @@ -71,7 +71,7 @@ namespace Bloom::Usb return output; } - void HidInterface::write(std::vector buffer) { + void HidInterface::write(std::vector&& buffer) { if (buffer.size() > this->getInputReportSize()) { throw DeviceCommunicationFailure( "Cannot send data via HID interface - data exceeds maximum packet size." @@ -87,7 +87,7 @@ namespace Bloom::Usb } int transferred = 0; - auto length = buffer.size(); + const auto length = buffer.size(); if ((transferred = hid_write(this->getHidDevice(), buffer.data(), length)) != length) { Logger::debug("Attempted to write " + std::to_string(length) diff --git a/src/DebugToolDrivers/USB/HID/HidInterface.hpp b/src/DebugToolDrivers/USB/HID/HidInterface.hpp index 6c07b816..38851145 100644 --- a/src/DebugToolDrivers/USB/HID/HidInterface.hpp +++ b/src/DebugToolDrivers/USB/HID/HidInterface.hpp @@ -50,7 +50,7 @@ namespace Bloom::Usb * * @param buffer */ - void write(std::vector buffer); + void write(std::vector&& buffer); /** * Resolves a device path from a USB interface number. diff --git a/src/Helpers/EpollInstance.cpp b/src/Helpers/EpollInstance.cpp index 6da8962b..0d55102d 100644 --- a/src/Helpers/EpollInstance.cpp +++ b/src/Helpers/EpollInstance.cpp @@ -23,7 +23,7 @@ namespace Bloom } void EpollInstance::addEntry(int fileDescriptor, std::uint16_t eventMask) { - struct epoll_event event = { + struct ::epoll_event event = { .events = eventMask, .data = { .fd = fileDescriptor diff --git a/src/Helpers/EventFdNotifier.cpp b/src/Helpers/EventFdNotifier.cpp index 2759302b..e72e3b88 100644 --- a/src/Helpers/EventFdNotifier.cpp +++ b/src/Helpers/EventFdNotifier.cpp @@ -12,7 +12,7 @@ namespace Bloom using Exceptions::Exception; EventFdNotifier::EventFdNotifier() { - this->fileDescriptor = ::eventfd(0, EFD_NONBLOCK); + this->fileDescriptor = ::eventfd(0, ::EFD_NONBLOCK); if (this->fileDescriptor < 0) { throw Exception( @@ -40,7 +40,7 @@ namespace Bloom } void EventFdNotifier::clear() { - eventfd_t counter = {}; + ::eventfd_t counter = {}; if (::eventfd_read(this->fileDescriptor.value(), &counter) < 0 && errno != EAGAIN) { throw Exceptions::Exception("Failed to clear EventFdNotifier object - eventfd_read failed - " "error number: " + std::to_string(errno)); diff --git a/src/SignalHandler/SignalHandler.cpp b/src/SignalHandler/SignalHandler.cpp index c60daaab..4d786598 100644 --- a/src/SignalHandler/SignalHandler.cpp +++ b/src/SignalHandler/SignalHandler.cpp @@ -11,16 +11,17 @@ namespace Bloom void SignalHandler::run() { try { this->startup(); - auto signalSet = this->getRegisteredSignalSet(); + const auto signalSet = this->getRegisteredSignalSet(); int signalNumber = 0; Logger::debug("SignalHandler ready"); while(Thread::getThreadState() == ThreadState::READY) { - if (sigwait(&signalSet, &signalNumber) == 0) { + if (::sigwait(&signalSet, &signalNumber) == 0) { Logger::debug("SIGNAL " + std::to_string(signalNumber) + " received"); - if (this->handlersMappedBySignalNum.contains(signalNumber)) { + + if (this->handlersBySignalNum.contains(signalNumber)) { // We have a registered handler for this signal. - this->handlersMappedBySignalNum.at(signalNumber)(); + this->handlersBySignalNum.at(signalNumber)(); } } } @@ -39,15 +40,15 @@ namespace Bloom Logger::debug("Starting SignalHandler"); // Block all signal interrupts auto signalSet = this->getRegisteredSignalSet(); - sigprocmask(SIG_SETMASK, &signalSet, NULL); + ::sigprocmask(SIG_SETMASK, &signalSet, NULL); // Register handlers - this->handlersMappedBySignalNum.insert(std::pair( + this->handlersBySignalNum.insert(std::pair( SIGINT, std::bind(&SignalHandler::triggerApplicationShutdown, this) )); - this->handlersMappedBySignalNum.insert(std::pair( + this->handlersBySignalNum.insert(std::pair( SIGTERM, std::bind(&SignalHandler::triggerApplicationShutdown, this) )); @@ -58,10 +59,10 @@ namespace Bloom } } - sigset_t SignalHandler::getRegisteredSignalSet() const { - sigset_t set = {}; - if (sigfillset(&set) == -1) { - throw Exceptions::Exception("sigfillset() failed - error number: " + std::to_string(errno)); + ::sigset_t SignalHandler::getRegisteredSignalSet() const { + ::sigset_t set = {}; + if (::sigfillset(&set) == -1) { + throw Exceptions::Exception("::sigfillset() failed - error number: " + std::to_string(errno)); } return set; diff --git a/src/SignalHandler/SignalHandler.hpp b/src/SignalHandler/SignalHandler.hpp index b1b37457..47b01c07 100644 --- a/src/SignalHandler/SignalHandler.hpp +++ b/src/SignalHandler/SignalHandler.hpp @@ -27,9 +27,9 @@ namespace Bloom private: /** - * Mapping of signal numbers to functions. + * Mapping of signal numbers to handler functions. */ - std::map> handlersMappedBySignalNum; + std::map> handlersBySignalNum; /** * We keep record of the number of shutdown signals received. See definition of triggerApplicationShutdown() @@ -49,7 +49,7 @@ namespace Bloom * * @return */ - [[nodiscard]] sigset_t getRegisteredSignalSet() const; + [[nodiscard]] ::sigset_t getRegisteredSignalSet() const; /** * Handler for SIGINT, SIGTERM, etc signals. diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index eefc54d0..7aede7b7 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -1,11 +1,9 @@ #include "Avr8.hpp" -#include -#include -#include #include #include #include +#include #include "src/Logger/Logger.hpp" #include "src/Helpers/Paths.hpp" diff --git a/src/VersionNumber.cpp b/src/VersionNumber.cpp index 7c301d5e..f26dd566 100644 --- a/src/VersionNumber.cpp +++ b/src/VersionNumber.cpp @@ -6,7 +6,10 @@ namespace Bloom { VersionNumber::VersionNumber(std::uint16_t major, std::uint16_t minor, std::uint16_t patch) - : major{major}, minor{minor}, patch{patch} { + : major{major} + , minor{minor} + , patch{patch} + { this->combined = static_cast( std::stoul(std::to_string(this->major) + std::to_string(this->minor) + std::to_string(this->patch)) );