diff --git a/src/fsfw/cfdp/VarLenFields.cpp b/src/fsfw/cfdp/VarLenFields.cpp index b9e0b3a83..10f8a0862 100644 --- a/src/fsfw/cfdp/VarLenFields.cpp +++ b/src/fsfw/cfdp/VarLenFields.cpp @@ -3,7 +3,7 @@ #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" -cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() { +cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, uint64_t value) : VarLenField() { ReturnValue_t result = this->setValue(width, value); if (result != returnvalue::OK) { #if FSFW_DISABLE_PRINTOUT == 0 @@ -20,7 +20,7 @@ cfdp::VarLenField::VarLenField() : width(cfdp::WidthInBytes::ONE_BYTE) { value.o cfdp::WidthInBytes cfdp::VarLenField::getWidth() const { return width; } -ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_t value_) { +ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, uint64_t value_) { switch (widthInBytes) { case (cfdp::WidthInBytes::ONE_BYTE): { if (value_ > UINT8_MAX) { @@ -51,7 +51,7 @@ ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_ return returnvalue::OK; } -size_t cfdp::VarLenField::getValue() const { +uint64_t cfdp::VarLenField::getValue() const { switch (width) { case (cfdp::WidthInBytes::ONE_BYTE): { return value.oneByte; diff --git a/src/fsfw/cfdp/VarLenFields.h b/src/fsfw/cfdp/VarLenFields.h index 37602c751..c9fad3066 100644 --- a/src/fsfw/cfdp/VarLenFields.h +++ b/src/fsfw/cfdp/VarLenFields.h @@ -25,13 +25,13 @@ class VarLenField : public SerializeIF { template explicit VarLenField(UnsignedByteField byteField); - VarLenField(cfdp::WidthInBytes width, size_t value); + VarLenField(cfdp::WidthInBytes width, uint64_t value); bool operator==(const VarLenField &other) const; bool operator!=(const VarLenField &other) const; bool operator<(const VarLenField &other) const; - ReturnValue_t setValue(cfdp::WidthInBytes, size_t value); + ReturnValue_t setValue(cfdp::WidthInBytes, uint64_t value); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; @@ -42,7 +42,7 @@ class VarLenField : public SerializeIF { Endianness streamEndianness); [[nodiscard]] cfdp::WidthInBytes getWidth() const; - [[nodiscard]] size_t getValue() const; + [[nodiscard]] uint64_t getValue() const; #if FSFW_CPP_OSTREAM_ENABLED == 1 friend std::ostream &operator<<(std::ostream &os, const VarLenField &id) { diff --git a/src/fsfw/cfdp/pdu/EofInfo.cpp b/src/fsfw/cfdp/pdu/EofInfo.cpp index 98e79df70..77f328f81 100644 --- a/src/fsfw/cfdp/pdu/EofInfo.cpp +++ b/src/fsfw/cfdp/pdu/EofInfo.cpp @@ -42,6 +42,6 @@ size_t EofInfo::getSerializedSize(bool fssLarge) { return size; } -ReturnValue_t EofInfo::setFileSize(size_t fileSize, bool isLarge) { +ReturnValue_t EofInfo::setFileSize(uint64_t fileSize, bool isLarge) { return this->fileSize.setFileSize(fileSize, isLarge); } diff --git a/src/fsfw/cfdp/pdu/EofInfo.h b/src/fsfw/cfdp/pdu/EofInfo.h index 4b4fb0573..69effa493 100644 --- a/src/fsfw/cfdp/pdu/EofInfo.h +++ b/src/fsfw/cfdp/pdu/EofInfo.h @@ -21,7 +21,7 @@ struct EofInfo { void setChecksum(uint32_t checksum); void setConditionCode(cfdp::ConditionCode conditionCode); void setFaultLoc(EntityIdTlv* faultLoc); - ReturnValue_t setFileSize(size_t size, bool isLarge); + ReturnValue_t setFileSize(uint64_t size, bool isLarge); private: cfdp::ConditionCode conditionCode; diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index b62c19b60..3082726b5 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -109,7 +109,7 @@ ReturnValue_t LocalPool::deleteData(uint8_t* ptr, size_t size, store_address_t* ReturnValue_t result = ILLEGAL_ADDRESS; for (uint16_t n = 0; n < NUMBER_OF_SUBPOOLS; n++) { // Not sure if new allocates all stores in order. so better be careful. - if ((store[n].data() <= ptr) and (&store[n][numberOfElements[n] * elementSizes[n]] > ptr)) { + if ((store[n].data() <= ptr) and (&store[n][numberOfElements[n] * elementSizes[n] - 1] >= ptr)) { localId.poolIndex = n; uint32_t deltaAddress = ptr - store[n].data(); // Getting any data from the right "block" is ok. diff --git a/unittests/cfdp/pdu/testEofPdu.cpp b/unittests/cfdp/pdu/testEofPdu.cpp index 83e617808..62b99fc28 100644 --- a/unittests/cfdp/pdu/testEofPdu.cpp +++ b/unittests/cfdp/pdu/testEofPdu.cpp @@ -42,7 +42,9 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { REQUIRE(sz == 20); eofInfo.setConditionCode(cfdp::ConditionCode::FILESTORE_REJECTION); - eofInfo.setFileSize(0x10ffffff10, true); + uint64_t value = 0x13ffffffff; + size_t vlaue1 = value; + eofInfo.setFileSize(0x13fffefd10, true); pduConf.largeFile = true; // Should serialize with fault location now auto serializeWithFaultLocation = EofPduCreator(pduConf, eofInfo); @@ -57,7 +59,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { uint64_t fileSizeLarge = 0; result = SerializeAdapter::deSerialize(&fileSizeLarge, buf.data() + 16, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(fileSizeLarge == 0x10ffffff10); + REQUIRE(fileSizeLarge == 0x13fffefd10); REQUIRE(buf[sz - 4] == cfdp::TlvType::ENTITY_ID); // width of entity ID is 2 REQUIRE(buf[sz - 3] == 2); diff --git a/unittests/container/TestPlacementFactory.cpp b/unittests/container/TestPlacementFactory.cpp index fa8e1e076..aea5dba16 100644 --- a/unittests/container/TestPlacementFactory.cpp +++ b/unittests/container/TestPlacementFactory.cpp @@ -40,7 +40,6 @@ TEST_CASE("PlacementFactory Tests", "[containers]") { REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) == static_cast(returnvalue::OK)); REQUIRE(storagePool.deleteData(address) == static_cast(returnvalue::OK)); - // Check that PlacementFactory checks for nullptr ptr = nullptr; REQUIRE(factory.destroy(ptr) == static_cast(returnvalue::FAILED)); diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index 06d4f3747..6feb5c028 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -221,9 +221,12 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Remove recursively") { fs::create_directory(dir0.string().c_str()); ofstream of(fileInDir0); + of.close(); CHECK(fs::is_directory(dir0)); CHECK(fs::is_regular_file(fileInDir0)); - REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.string().c_str()), true) == + // See note at the top + std::string dir0_string = dir0.string(); + REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0_string.c_str()), true) == returnvalue::OK); CHECK(not fs::is_directory(dir0)); CHECK(not fs::is_regular_file(fileInDir0));