From ff4cbea57137521d60dfa283cfc72c6989439257 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 17:44:55 +0200 Subject: [PATCH 1/8] improvements for auto-formatter script --- scripts/auto-formatter.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/auto-formatter.sh b/scripts/auto-formatter.sh index c0ae7099..723add4f 100755 --- a/scripts/auto-formatter.sh +++ b/scripts/auto-formatter.sh @@ -3,6 +3,11 @@ if [[ ! -f README.md ]]; then cd .. fi +folder_list=( + "./src" + "./unittests" +) + cmake_fmt="cmake-format" file_selectors="-iname CMakeLists.txt" if command -v ${cmake_fmt} &> /dev/null; then @@ -15,8 +20,10 @@ fi cpp_format="clang-format" file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp" if command -v ${cpp_format} &> /dev/null; then - find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i - find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i + for dir in ${folder_list[@]}; do + echo "Auto-formatting ${dir} recursively" + find ${dir} ${file_selectors} | xargs clang-format --style=file -i + done else echo "No ${cpp_format} tool found, not formatting C++/C files" fi From fd278e410b943efeb30435b9a5fb00988c171be9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 12:01:44 +0200 Subject: [PATCH 2/8] additional safety check --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 7b9ba7c0..59261cfd 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -588,10 +588,12 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } // additional security check, this should never be true - if (itBegin->first > itEnd->first) { + if ((itBegin != telecommandMap.end() and itEnd != telecommandMap.end()) and + (itBegin->first > itEnd->first)) { #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; #else - sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); + sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); #endif return returnvalue::FAILED; } From e2e0190caef8d26d019ad4e50e3518a7c14e9597 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 29 Aug 2022 14:51:14 +0200 Subject: [PATCH 3/8] Revert "additional safety check" This reverts commit fd278e410b943efeb30435b9a5fb00988c171be9. --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 59261cfd..7b9ba7c0 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -588,12 +588,10 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } // additional security check, this should never be true - if ((itBegin != telecommandMap.end() and itEnd != telecommandMap.end()) and - (itBegin->first > itEnd->first)) { + if (itBegin->first > itEnd->first) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; #else - sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); + sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); #endif return returnvalue::FAILED; } From 6605ffb6b1e2a039d6132b3e150bdc13c42dd543 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 29 Aug 2022 14:54:52 +0200 Subject: [PATCH 4/8] Fixing check in Srv 11 Filer --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 7b9ba7c0..7f60f7e8 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -588,10 +588,11 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } // additional security check, this should never be true - if (itBegin->first > itEnd->first) { + if (itBegin > itEnd) { #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; #else - sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); + sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); #endif return returnvalue::FAILED; } From 3bffb4f968ea14fa77596bf881621c8a1b14803d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 15:20:33 +0200 Subject: [PATCH 5/8] fix for static fw obj setter --- misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp index 4670c7e7..4d6e91f1 100644 --- a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp @@ -35,7 +35,7 @@ void Factory::produceFsfwObjects(void) { } void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::NO_OBJECT; + PusServiceBase::PUS_DISTRIBUTOR = objects::NO_OBJECT; PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT; CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; From b499dedd76637e1330a90f3f8ef0d0743ef0246a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 15:27:53 +0200 Subject: [PATCH 6/8] remove TODO --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index fa76d2a7..0a7dd5ab 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -14,7 +14,6 @@ #include "internal/HasLocalDpIFManagerAttorney.h" #include "internal/LocalPoolDataSetAttorney.h" -// TODO: Get rid of this. This should be a constructor argument, not something hardcoded in any way object_id_t LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, From cb23911ccd5b678bc53ceda59f5258b77a042a56 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 15:30:45 +0200 Subject: [PATCH 7/8] default initialization of CDS short struct --- src/fsfw/timemanager/CCSDSTime.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 607026e3..77801cec 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -39,13 +39,13 @@ class CCSDSTime { * Struct for CDS day-segmented format. */ struct CDS_short { - uint8_t pField; - uint8_t dayMSB; - uint8_t dayLSB; - uint8_t msDay_hh; - uint8_t msDay_h; - uint8_t msDay_l; - uint8_t msDay_ll; + uint8_t pField = P_FIELD_CDS_SHORT; + uint8_t dayMSB = 0; + uint8_t dayLSB = 0; + uint8_t msDay_hh = 0; + uint8_t msDay_h = 0; + uint8_t msDay_l = 0; + uint8_t msDay_ll = 0; }; /** * Struct for the CCS fromat in day of month variation with max resolution From 2cab73d9722da97c32ad46e63cbec4d54645b897 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 20:08:59 +0200 Subject: [PATCH 8/8] avoid duplicate code --- src/fsfw/ipc/MessageQueueMessage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/ipc/MessageQueueMessage.cpp b/src/fsfw/ipc/MessageQueueMessage.cpp index 6e841c7f..b0ce090f 100644 --- a/src/fsfw/ipc/MessageQueueMessage.cpp +++ b/src/fsfw/ipc/MessageQueueMessage.cpp @@ -12,7 +12,7 @@ MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize() MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) : messageSize(MessageQueueMessage::HEADER_SIZE + size) { if (size <= MessageQueueMessage::MAX_DATA_SIZE) { - std::memcpy(internalBuffer + MessageQueueMessage::HEADER_SIZE, data, size); + std::memcpy(MessageQueueMessage::getData(), data, size); this->messageSize = MessageQueueMessage::HEADER_SIZE + size; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1