From ccf03b131b6552625635612d3d2aabd757ed6ffc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Mar 2023 14:50:25 +0100 Subject: [PATCH 1/2] avoid exceptions --- CHANGELOG.md | 2 ++ bsp_q7s/core/CoreController.cpp | 35 +++++++++++++------ bsp_q7s/core/WatchdogHandler.cpp | 3 +- bsp_q7s/fs/SdCardManager.cpp | 9 +++-- bsp_q7s/memory/LocalParameterHandler.h | 2 +- bsp_q7s/obsw.cpp | 6 ++-- fsfw | 2 +- mission/controller/acs/Guidance.cpp | 15 ++++---- mission/devices/ScexDeviceHandler.cpp | 9 +++-- .../devices/SolarArrayDeploymentHandler.cpp | 10 +++--- .../payloadPcduDefinitions.h | 2 +- mission/memory/CMakeLists.txt | 2 +- ...ParameterBase.cpp => NvmParameterBase.cpp} | 10 ++++-- ...{NVMParameterBase.h => NvmParameterBase.h} | 0 mission/tmtc/PersistentTmStore.cpp | 3 +- mission/utility/GlobalConfigHandler.h | 2 +- test/DummyParameter.h | 4 +-- watchdog/Watchdog.cpp | 9 +++-- watchdog/main.cpp | 3 +- 19 files changed, 83 insertions(+), 45 deletions(-) rename mission/memory/{NVMParameterBase.cpp => NvmParameterBase.cpp} (86%) rename mission/memory/{NVMParameterBase.h => NvmParameterBase.h} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31057e8f..25297084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ will consitute of a breaking change warranting a new major release: ## Fixed +- `std::filesystem` API usages: Avoid exceptions by using variants which return an error code + instead of throwing exceptions. - GPS fix loss was not reported if mode is unset. - Star Tracker: OFF to NORMAL transition now posssible. Requires FSFW bump which sets transition source modes properly for those transitions. diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 95ff671a..8823bf4e 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -605,7 +605,8 @@ ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetS sif::info << "Unmounting SD card " << sdChar << std::endl; return sdcMan->unmountSdCard(sdCard); } else { - if (std::filesystem::exists(mountString)) { + std::error_code e; + if (std::filesystem::exists(mountString, e)) { sif::info << "SD card " << sdChar << " already on and mounted at " << mountString << std::endl; return SdCardManager::ALREADY_MOUNTED; @@ -702,7 +703,8 @@ ReturnValue_t CoreController::initVersionFile() { std::string versionFilePath = currMntPrefix + VERSION_FILE; std::fstream versionFile; - if (not std::filesystem::exists(versionFilePath)) { + std::error_code e; + if (not std::filesystem::exists(versionFilePath, e)) { sif::info << "Writing version file " << versionFilePath << ".." << std::endl; versionFile.open(versionFilePath, std::ios_base::out); versionFile << fullObswVersionString << std::endl; @@ -814,7 +816,8 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, } ReturnValue_t CoreController::initBootCopyFile() { - if (not std::filesystem::exists(CURR_COPY_FILE)) { + std::error_code e; + if (not std::filesystem::exists(CURR_COPY_FILE, e)) { // This file is created by the systemd service eive-early-config so this should // not happen normally std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); @@ -1118,7 +1121,8 @@ ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { return result; } } - if (not filesystem::exists(CHIP_STATE_FILE)) { + std::error_code e; + if (not filesystem::exists(CHIP_STATE_FILE, e)) { return returnvalue::FAILED; } ifstream chipStateFile(CHIP_STATE_FILE); @@ -1197,8 +1201,13 @@ void CoreController::performMountedSdCardOperations() { if (not performOneShotSdCardOpsSwitch) { std::ostringstream path; path << mntPoint << "/" << CONF_FOLDER; - if (not std::filesystem::exists(path.str())) { - std::filesystem::create_directory(path.str()); + std::error_code e; + if (not std::filesystem::exists(path.str()), e) { + bool created = std::filesystem::create_directory(path.str(), e); + if (not created) { + sif::error << "Could not create CONF folder at " << path << ": " << e << std::endl; + return; + } } initVersionFile(); ReturnValue_t result = initBootCopyFile(); @@ -1283,7 +1292,8 @@ ReturnValue_t CoreController::performSdCardCheck() { void CoreController::performRebootFileHandling(bool recreateFile) { using namespace std; std::string path = currMntPrefix + REBOOT_FILE; - if (not std::filesystem::exists(path) or recreateFile) { + std::error_code e; + if (not std::filesystem::exists(path, e) or recreateFile) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl; #endif @@ -1750,7 +1760,8 @@ ReturnValue_t CoreController::initClockFromTimeFile() { using namespace GpsHyperion; using namespace std; std::string fileName = currMntPrefix + BACKUP_TIME_FILE; - if (sdcMan->isSdCardUsable(std::nullopt) and std::filesystem::exists(fileName) and + std::error_code e; + if (sdcMan->isSdCardUsable(std::nullopt) and std::filesystem::exists(fileName, e) and ((gpsFix == FixMode::UNKNOWN or gpsFix == FixMode::NOT_SEEN) or not utility::timeSanityCheck())) { ifstream timeFile(fileName); @@ -1875,7 +1886,8 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u prefixPath = path("/tmp"); } path archivePath = prefixPath / path(config::OBSW_UPDATE_ARCHIVE_FILE_NAME); - if (not exists(archivePath)) { + std::error_code e; + if (not exists(archivePath, e)) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; } ostringstream cmd("tar -xJf", ios::app); @@ -1885,12 +1897,13 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u utility::handleSystemError(result, "CoreController::executeAction: SW Update Decompression"); } path strippedImagePath = prefixPath / path(config::STRIPPED_OBSW_BINARY_FILE_NAME); - if (!exists(strippedImagePath)) { + std::error_code e; + if (!exists(strippedImagePath, e)) { // TODO: Custom returnvalue? return returnvalue::FAILED; } path obswVersionFilePath = prefixPath / path(config::OBSW_VERSION_FILE_NAME); - if (!exists(obswVersionFilePath)) { + if (!exists(obswVersionFilePath, e)) { // TODO: Custom returnvalue? return returnvalue::FAILED; } diff --git a/bsp_q7s/core/WatchdogHandler.cpp b/bsp_q7s/core/WatchdogHandler.cpp index 71569b65..9e3a1020 100644 --- a/bsp_q7s/core/WatchdogHandler.cpp +++ b/bsp_q7s/core/WatchdogHandler.cpp @@ -45,7 +45,8 @@ void WatchdogHandler::periodicOperation() { ReturnValue_t WatchdogHandler::initialize(bool enableWatchdogFunction) { using namespace std::filesystem; this->enableWatchFunction = enableWatchdogFunction; - if (not std::filesystem::exists(watchdog::FIFO_NAME)) { + std::error_code e; + if (not std::filesystem::exists(watchdog::FIFO_NAME, e)) { // Still return returnvalue::OK for now sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate" << " watchdog" << std::endl; diff --git a/bsp_q7s/fs/SdCardManager.cpp b/bsp_q7s/fs/SdCardManager.cpp index d21a373e..fa46f8e0 100644 --- a/bsp_q7s/fs/SdCardManager.cpp +++ b/bsp_q7s/fs/SdCardManager.cpp @@ -198,7 +198,8 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { ReturnValue_t SdCardManager::getSdCardsStatus(SdStatePair& active) { using namespace std; MutexGuard mg(sdLock, LOCK_TYPE, SD_LOCK_TIMEOUT, LOCK_CTX); - if (not filesystem::exists(SD_STATE_FILE)) { + std::error_code e; + if (not filesystem::exists(SD_STATE_FILE, e)) { return STATUS_FILE_NEXISTS; } @@ -239,7 +240,8 @@ ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { mountDev = SD_1_DEV_NAME; mountPoint = config::SD_1_MOUNT_POINT; } - if (not filesystem::exists(mountDev)) { + std::error_code e; + if (not filesystem::exists(mountDev, e)) { sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" " turn on the SD card" << std::endl; @@ -274,7 +276,8 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { } else if (sdCard == sd::SdCard::SLOT_1) { mountPoint = config::SD_1_MOUNT_POINT; } - if (not filesystem::exists(mountPoint)) { + std::error_code e; + if (not filesystem::exists(mountPoint, e)) { sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint << "does not exist" << std::endl; return UNMOUNT_ERROR; diff --git a/bsp_q7s/memory/LocalParameterHandler.h b/bsp_q7s/memory/LocalParameterHandler.h index cdbcff06..74626202 100644 --- a/bsp_q7s/memory/LocalParameterHandler.h +++ b/bsp_q7s/memory/LocalParameterHandler.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_ #define BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_ -#include +#include #include #include diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index a0067574..e264283f 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -37,9 +37,10 @@ int obsw::obsw(int argc, char* argv[]) { std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 + std::error_code e; // Check special file here. This file is created or deleted by the eive-watchdog application // or systemd service! - if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { + if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) { sif::warning << "File " << watchdog::RUNNING_FILE_NAME << " exists so the software might " "already be running. Check if obsw systemd service has been stopped." @@ -84,8 +85,9 @@ void obsw::bootDelayHandling() { homedir = getpwuid(getuid())->pw_dir; } std::filesystem::path bootDelayFile = std::filesystem::path(homedir) / "boot_delay_secs.txt"; + std::error_code e; // Init delay handling. - if (std::filesystem::exists(bootDelayFile)) { + if (std::filesystem::exists(bootDelayFile, e)) { std::ifstream ifile(bootDelayFile); std::string lineStr; unsigned int bootDelaySecs = 0; diff --git a/fsfw b/fsfw index 7f6ba5f4..26e44451 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 7f6ba5f40b47bc32802efdc4ed41b4bad4b8071b +Subproject commit 26e4445189b676eaee11840e5a9d0ede25cf3896 diff --git a/mission/controller/acs/Guidance.cpp b/mission/controller/acs/Guidance.cpp index 09f0be20..122e7ea2 100644 --- a/mission/controller/acs/Guidance.cpp +++ b/mission/controller/acs/Guidance.cpp @@ -540,8 +540,10 @@ ReturnValue_t Guidance::getDistributionMatrixRw(ACS::SensorValues *sensorValues, } void Guidance::getTargetParamsSafe(double sunTargetSafe[3], double satRateSafe[3]) { - if (not std::filesystem::exists(SD_0_SKEWED_PTG_FILE) or - not std::filesystem::exists(SD_1_SKEWED_PTG_FILE)) { // ToDo: if file does not exist anymore + std::error_code e; + if (not std::filesystem::exists(SD_0_SKEWED_PTG_FILE, e) or + not std::filesystem::exists(SD_1_SKEWED_PTG_FILE, + e)) { // ToDo: if file does not exist anymore std::memcpy(sunTargetSafe, acsParameters.safeModeControllerParameters.sunTargetDir, 3 * sizeof(double)); } else { @@ -553,15 +555,16 @@ void Guidance::getTargetParamsSafe(double sunTargetSafe[3], double satRateSafe[3 } ReturnValue_t Guidance::solarArrayDeploymentComplete() { - if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE)) { + std::error_code e; + if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE, e)) { std::remove(SD_0_SKEWED_PTG_FILE); - if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE)) { + if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE, e)) { return returnvalue::FAILED; } } - if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE)) { + if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE, e)) { std::remove(SD_1_SKEWED_PTG_FILE); - if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE)) { + if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE, e)) { return returnvalue::FAILED; } } diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index e2061a6b..9f41c8a0 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -319,11 +319,14 @@ void ScexDeviceHandler::performOperationHook() { auto mntPrefix = sdcMan.getCurrentMountPrefix(); if (mntPrefix != nullptr) { std::filesystem::path fullFilePath = mntPrefix; + std::error_code e; fullFilePath /= "scex"; - bool fileExists = std::filesystem::exists(fullFilePath); - + bool fileExists = std::filesystem::exists(fullFilePath, e); if (not fileExists) { - std::filesystem::create_directory(fullFilePath); + bool created = std::filesystem::create_directory(fullFilePath, e); + if (not created) { + sif::error << "Could not create SCEX directory: " << e << std::endl; + } } } uint32_t remainingMillis = finishCountdown.getRemainingMillis(); diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index 77c826fd..e4356630 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -43,15 +43,16 @@ ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCod #endif if (opDivider.checkAndIncrement()) { auto activeSdc = sdcMan.getActiveSdCard(); + std::error_code e; if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and sdcMan.isSdCardUsable(activeSdc.value())) { - if (exists(SD_0_DEPL_FILE)) { + if (exists(SD_0_DEPL_FILE, e)) { // perform autonomous deployment handling performAutonomousDepl(sd::SdCard::SLOT_0, dryRunStringInFile(SD_0_DEPL_FILE)); } } else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and sdcMan.isSdCardUsable(activeSdc.value())) { - if (exists(SD_1_DEPL_FILE)) { + if (exists(SD_1_DEPL_FILE, e)) { // perform autonomous deployment handling performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE)); } @@ -137,15 +138,16 @@ ReturnValue_t SolarArrayDeploymentHandler::performAutonomousDepl(sd::SdCard sdCa of << "phase: init\n"; of << "secs_since_start: 0\n"; }; + std::error_code e; if (sdCard == sd::SdCard::SLOT_0) { - if (not exists(SD_0_DEPLY_INFO)) { + if (not exists(SD_0_DEPLY_INFO, e)) { initFile(SD_0_DEPLY_INFO); } if (not autonomousDeplForFile(sd::SdCard::SLOT_0, SD_0_DEPLY_INFO, dryRun)) { initFile(SD_0_DEPLY_INFO); } } else if (sdCard == sd::SdCard::SLOT_1) { - if (not exists(SD_1_DEPLY_INFO)) { + if (not exists(SD_1_DEPLY_INFO, e)) { initFile(SD_1_DEPLY_INFO); } if (not autonomousDeplForFile(sd::SdCard::SLOT_1, SD_1_DEPLY_INFO, dryRun)) { diff --git a/mission/devices/devicedefinitions/payloadPcduDefinitions.h b/mission/devices/devicedefinitions/payloadPcduDefinitions.h index b1adae5f..a5c3effd 100644 --- a/mission/devices/devicedefinitions/payloadPcduDefinitions.h +++ b/mission/devices/devicedefinitions/payloadPcduDefinitions.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -10,7 +11,6 @@ #include "OBSWConfig.h" #include "mission/devices/max1227.h" -#include "mission/memory/NVMParameterBase.h" namespace plpcdu { diff --git a/mission/memory/CMakeLists.txt b/mission/memory/CMakeLists.txt index 132f0551..8c2da887 100644 --- a/mission/memory/CMakeLists.txt +++ b/mission/memory/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE NVMParameterBase.cpp) +target_sources(${LIB_EIVE_MISSION} PRIVATE NvmParameterBase.cpp) diff --git a/mission/memory/NVMParameterBase.cpp b/mission/memory/NvmParameterBase.cpp similarity index 86% rename from mission/memory/NVMParameterBase.cpp rename to mission/memory/NvmParameterBase.cpp index 368dd772..9856acf8 100644 --- a/mission/memory/NVMParameterBase.cpp +++ b/mission/memory/NvmParameterBase.cpp @@ -1,4 +1,4 @@ -#include "NVMParameterBase.h" +#include #include @@ -10,7 +10,8 @@ NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {} NVMParameterBase::NVMParameterBase() {} ReturnValue_t NVMParameterBase::readJsonFile() { - if (std::filesystem::exists(fullName)) { + std::error_code e; + if (std::filesystem::exists(fullName, e)) { // Read JSON file content into object std::ifstream i(fullName); try { @@ -39,7 +40,10 @@ void NVMParameterBase::setFullName(std::string fullName) { this->fullName = full std::string NVMParameterBase::getFullName() const { return fullName; } -bool NVMParameterBase::getJsonFileExists() { return std::filesystem::exists(fullName); } +bool NVMParameterBase::getJsonFileExists() { + std::error_code e; + return std::filesystem::exists(fullName, e); +} void NVMParameterBase::printKeys() const { sif::info << "Printing keys for JSON file " << fullName << std::endl; diff --git a/mission/memory/NVMParameterBase.h b/mission/memory/NvmParameterBase.h similarity index 100% rename from mission/memory/NVMParameterBase.h rename to mission/memory/NvmParameterBase.h diff --git a/mission/tmtc/PersistentTmStore.cpp b/mission/tmtc/PersistentTmStore.cpp index 91a87248..7b29e06f 100644 --- a/mission/tmtc/PersistentTmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -174,7 +174,8 @@ bool PersistentTmStore::updateBaseDir() { return false; } basePath = path(currentPrefix) / baseDir / baseName; - if (not exists(basePath)) { + std::error_code e; + if (not exists(basePath, e)) { create_directories(basePath); } baseDirUninitialized = false; diff --git a/mission/utility/GlobalConfigHandler.h b/mission/utility/GlobalConfigHandler.h index 80e141c6..bb3badf2 100644 --- a/mission/utility/GlobalConfigHandler.h +++ b/mission/utility/GlobalConfigHandler.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -22,7 +23,6 @@ #include "OBSWConfig.h" #include "fsfw/parameters/HasParametersIF.h" #include "fsfw/parameters/ParameterHelper.h" -#include "mission/memory/NVMParameterBase.h" static std::map PARAM_KEY_MAP = { {PARAM0, "Parameter0"}, diff --git a/test/DummyParameter.h b/test/DummyParameter.h index 410f0958..fe9296ba 100644 --- a/test/DummyParameter.h +++ b/test/DummyParameter.h @@ -1,11 +1,11 @@ #ifndef BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ #define BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_ +#include + #include #include -#include "mission/memory/NVMParameterBase.h" - class DummyParameter : public NVMParameterBase { public: static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1"; diff --git a/watchdog/Watchdog.cpp b/watchdog/Watchdog.cpp index 3518192e..18d71609 100644 --- a/watchdog/Watchdog.cpp +++ b/watchdog/Watchdog.cpp @@ -18,8 +18,9 @@ WatchdogTask::WatchdogTask() : fd(0) { int result = 0; + std::error_code e; // Only create the FIFO if it does not exist yet - if (not std::filesystem::exists(watchdog::FIFO_NAME)) { + if (not std::filesystem::exists(watchdog::FIFO_NAME, e)) { // Permission 666 or rw-rw-rw- mode_t mode = DEFFILEMODE; result = mkfifo(watchdog::FIFO_NAME.c_str(), mode); @@ -167,7 +168,8 @@ int WatchdogTask::performRunningOperation() { std::cout << "OBSW is running" << std::endl; #if WATCHDOG_CREATE_FILE_IF_RUNNING == 1 std::cout << "Creating " << watchdog::RUNNING_FILE_NAME << std::endl; - if (not std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { + std::error_code e; + if (not std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) { std::ofstream obswRunningFile(watchdog::RUNNING_FILE_NAME); if (not obswRunningFile.good()) { std::cerr << "Creating file " << watchdog::RUNNING_FILE_NAME << " failed" << std::endl; @@ -196,7 +198,8 @@ int WatchdogTask::performNotRunningOperation(LoopResult type) { if (obswRunning) { #if WATCHDOG_CREATE_FILE_IF_RUNNING == 1 std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl; - if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { + std::error_code e; + if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) { int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str()); if (result != 0) { std::cerr << "Removing " << watchdog::RUNNING_FILE_NAME << " failed with code " << errno diff --git a/watchdog/main.cpp b/watchdog/main.cpp index 1ee6aea0..0173a299 100644 --- a/watchdog/main.cpp +++ b/watchdog/main.cpp @@ -12,7 +12,8 @@ */ int main() { std::cout << "Starting OBSW watchdog" << std::endl; - if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) { + std::error_code e; + if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) { std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl; int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str()); if (result != 0) { -- 2.43.0 From 2dd97a55f8827b857daa717d9e3542d732ca4471 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Mar 2023 14:59:50 +0100 Subject: [PATCH 2/2] fixes --- bsp_q7s/core/CoreController.cpp | 4 ++-- mission/memory/NvmParameterBase.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 8823bf4e..f51f6bf9 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1205,7 +1205,8 @@ void CoreController::performMountedSdCardOperations() { if (not std::filesystem::exists(path.str()), e) { bool created = std::filesystem::create_directory(path.str(), e); if (not created) { - sif::error << "Could not create CONF folder at " << path << ": " << e << std::endl; + sif::error << "Could not create CONF folder at " << path.str() << ": " << e.message() + << std::endl; return; } } @@ -1897,7 +1898,6 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u utility::handleSystemError(result, "CoreController::executeAction: SW Update Decompression"); } path strippedImagePath = prefixPath / path(config::STRIPPED_OBSW_BINARY_FILE_NAME); - std::error_code e; if (!exists(strippedImagePath, e)) { // TODO: Custom returnvalue? return returnvalue::FAILED; diff --git a/mission/memory/NvmParameterBase.cpp b/mission/memory/NvmParameterBase.cpp index 9856acf8..9b89440f 100644 --- a/mission/memory/NvmParameterBase.cpp +++ b/mission/memory/NvmParameterBase.cpp @@ -16,8 +16,8 @@ ReturnValue_t NVMParameterBase::readJsonFile() { std::ifstream i(fullName); try { i >> json; - } catch (nlohmann::json::exception& e) { - sif::warning << "Reading JSON file failed with error " << e.what() << std::endl; + } catch (nlohmann::json::exception& nlohmannE) { + sif::warning << "Reading JSON file failed with error " << nlohmannE.what() << std::endl; return returnvalue::FAILED; } return returnvalue::OK; -- 2.43.0