diff --git a/Drv/Ports/DataTypes/DataBuffer.cpp b/Drv/Ports/DataTypes/DataBuffer.cpp index 4e517a97b7a..9d5fffeb6f5 100644 --- a/Drv/Ports/DataTypes/DataBuffer.cpp +++ b/Drv/Ports/DataTypes/DataBuffer.cpp @@ -29,7 +29,7 @@ namespace Drv { return *this; } - NATIVE_UINT_TYPE DataBuffer::getBuffCapacity() const { + FwSizeType DataBuffer::getBuffCapacity() const { return sizeof(this->m_data); } diff --git a/Drv/Ports/DataTypes/DataBuffer.hpp b/Drv/Ports/DataTypes/DataBuffer.hpp index 5530a5bbd0d..6b878b485bd 100644 --- a/Drv/Ports/DataTypes/DataBuffer.hpp +++ b/Drv/Ports/DataTypes/DataBuffer.hpp @@ -21,7 +21,7 @@ namespace Drv { virtual ~DataBuffer(); DataBuffer& operator=(const DataBuffer& other); - NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer + FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Buffer/Buffer.cpp b/Fw/Buffer/Buffer.cpp index 00729b5baa0..81a95b2fed6 100644 --- a/Fw/Buffer/Buffer.cpp +++ b/Fw/Buffer/Buffer.cpp @@ -116,7 +116,7 @@ Fw::SerializeStatus Buffer::serialize(Fw::SerializeBufferBase& buffer) const { return stat; } #endif - stat = buffer.serialize(reinterpret_cast(this->m_bufferData)); + stat = buffer.serialize(reinterpret_cast(this->m_bufferData)); if (stat != Fw::FW_SERIALIZE_OK) { return stat; } @@ -146,7 +146,7 @@ Fw::SerializeStatus Buffer::deserialize(Fw::SerializeBufferBase& buffer) { return Fw::FW_DESERIALIZE_TYPE_MISMATCH; } #endif - POINTER_CAST pointer; + PlatformPointerCastType pointer; stat = buffer.deserialize(pointer); if (stat != Fw::FW_SERIALIZE_OK) { return stat; diff --git a/Fw/Cmd/CmdArgBuffer.cpp b/Fw/Cmd/CmdArgBuffer.cpp index 93b11fd4ffb..c03b8d58021 100644 --- a/Fw/Cmd/CmdArgBuffer.cpp +++ b/Fw/Cmd/CmdArgBuffer.cpp @@ -3,7 +3,7 @@ namespace Fw { - CmdArgBuffer::CmdArgBuffer(const U8 *args, NATIVE_UINT_TYPE size) { + CmdArgBuffer::CmdArgBuffer(const U8 *args, FwSizeType size) { SerializeStatus stat = this->setBuff(args,size); FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); } @@ -29,7 +29,7 @@ namespace Fw { return *this; } - NATIVE_UINT_TYPE CmdArgBuffer::getBuffCapacity() const { + FwSizeType CmdArgBuffer::getBuffCapacity() const { return sizeof(this->m_bufferData); } diff --git a/Fw/Cmd/CmdArgBuffer.hpp b/Fw/Cmd/CmdArgBuffer.hpp index 4744c6124ce..91f3b12f6bc 100644 --- a/Fw/Cmd/CmdArgBuffer.hpp +++ b/Fw/Cmd/CmdArgBuffer.hpp @@ -26,13 +26,13 @@ namespace Fw { SERIALIZED_SIZE = FW_CMD_ARG_BUFFER_MAX_SIZE + sizeof(I32) //!< size when serialized. Buffer + size of buffer }; - CmdArgBuffer(const U8 *args, NATIVE_UINT_TYPE size); //!< buffer source constructor + CmdArgBuffer(const U8 *args, FwSizeType size); //!< buffer source constructor CmdArgBuffer(); //!< default constructor CmdArgBuffer(const CmdArgBuffer& other); //!< other arg buffer constructor virtual ~CmdArgBuffer(); //!< destructor CmdArgBuffer& operator=(const CmdArgBuffer& other); //!< Equal operator - NATIVE_UINT_TYPE getBuffCapacity() const; //!< return capacity of buffer (how much it can hold) + FwSizeType getBuffCapacity() const; //!< return capacity of buffer (how much it can hold) U8* getBuffAddr(); //!< return address of buffer (non const version) const U8* getBuffAddr() const; //!< return address of buffer (const version) diff --git a/Fw/Com/ComBuffer.cpp b/Fw/Com/ComBuffer.cpp index bc72cab4eab..4bcd3070586 100644 --- a/Fw/Com/ComBuffer.cpp +++ b/Fw/Com/ComBuffer.cpp @@ -3,7 +3,7 @@ namespace Fw { - ComBuffer::ComBuffer(const U8 *args, NATIVE_UINT_TYPE size) { + ComBuffer::ComBuffer(const U8 *args, FwSizeType size) { SerializeStatus stat = SerializeBufferBase::setBuff(args,size); FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); } @@ -29,7 +29,7 @@ namespace Fw { return *this; } - NATIVE_UINT_TYPE ComBuffer::getBuffCapacity() const { + FwSizeType ComBuffer::getBuffCapacity() const { return sizeof(this->m_bufferData); } diff --git a/Fw/Com/ComBuffer.hpp b/Fw/Com/ComBuffer.hpp index a9d552a6305..cf70e7c32cb 100644 --- a/Fw/Com/ComBuffer.hpp +++ b/Fw/Com/ComBuffer.hpp @@ -25,13 +25,13 @@ namespace Fw { SERIALIZED_SIZE = FW_COM_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType) // size of buffer + storage of size word }; - ComBuffer(const U8 *args, NATIVE_UINT_TYPE size); + ComBuffer(const U8 *args, FwSizeType size); ComBuffer(); ComBuffer(const ComBuffer& other); virtual ~ComBuffer(); ComBuffer& operator=(const ComBuffer& other); - NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer + FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Comp/ActiveComponentBase.cpp b/Fw/Comp/ActiveComponentBase.cpp index 0a3d6b5a640..cca4d4f14a8 100644 --- a/Fw/Comp/ActiveComponentBase.cpp +++ b/Fw/Comp/ActiveComponentBase.cpp @@ -8,7 +8,7 @@ namespace Fw { class ActiveComponentExitSerializableBuffer : public Fw::SerializeBufferBase { public: - NATIVE_UINT_TYPE getBuffCapacity() const { + FwSizeType getBuffCapacity() const { return sizeof(m_buff); } @@ -33,7 +33,7 @@ namespace Fw { ActiveComponentBase::~ActiveComponentBase() { } - void ActiveComponentBase::init(NATIVE_INT_TYPE instance) { + void ActiveComponentBase::init(FwEnumStoreType instance) { QueuedComponentBase::init(instance); } diff --git a/Fw/Comp/ActiveComponentBase.hpp b/Fw/Comp/ActiveComponentBase.hpp index feed74ec8a0..9acda657b10 100644 --- a/Fw/Comp/ActiveComponentBase.hpp +++ b/Fw/Comp/ActiveComponentBase.hpp @@ -43,7 +43,7 @@ class ActiveComponentBase : public QueuedComponentBase { explicit ActiveComponentBase(const char* name); //!< Constructor virtual ~ActiveComponentBase(); //!< Destructor - void init(NATIVE_INT_TYPE instance); //!< initialization code + void init(FwEnumStoreType instance); //!< initialization code virtual void preamble(); //!< A function that will be called before the event loop is entered MsgDispatchStatus dispatch(); //!< The function that will dispatching messages virtual void finalizer(); //!< A function that will be called after exiting the loop diff --git a/Fw/Comp/PassiveComponentBase.cpp b/Fw/Comp/PassiveComponentBase.cpp index 1a57bcd0467..7f525988dd6 100644 --- a/Fw/Comp/PassiveComponentBase.cpp +++ b/Fw/Comp/PassiveComponentBase.cpp @@ -14,7 +14,7 @@ namespace Fw { return "Comp: %s"; } - void PassiveComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) { + void PassiveComponentBase::toString(char* buffer, FwSizeType size) { FW_ASSERT(size > 0); FW_ASSERT(buffer != nullptr); Fw::FormatStatus status = Fw::ExternalString(buffer, static_cast(size)).format( @@ -34,12 +34,12 @@ namespace Fw { PassiveComponentBase::~PassiveComponentBase() { } - void PassiveComponentBase::init(NATIVE_INT_TYPE instance) { + void PassiveComponentBase::init(FwEnumStoreType instance) { ObjBase::init(); this->m_instance = instance; } - NATIVE_INT_TYPE PassiveComponentBase::getInstance() const { + FwEnumStoreType PassiveComponentBase::getInstance() const { return this->m_instance; } diff --git a/Fw/Comp/PassiveComponentBase.hpp b/Fw/Comp/PassiveComponentBase.hpp index ff56a799cd7..97cb5cbe604 100644 --- a/Fw/Comp/PassiveComponentBase.hpp +++ b/Fw/Comp/PassiveComponentBase.hpp @@ -20,17 +20,17 @@ namespace Fw { PROTECTED: PassiveComponentBase(const char* name); //!< Named constructor virtual ~PassiveComponentBase(); //!< Destructor - void init(NATIVE_INT_TYPE instance); //!< Initialization function - NATIVE_INT_TYPE getInstance() const; + void init(FwEnumStoreType instance); //!< Initialization function + FwEnumStoreType getInstance() const; #if FW_OBJECT_TO_STRING == 1 virtual const char* getToStringFormatString(); //!< Return the format for a generic component toString - void toString(char* str, NATIVE_INT_TYPE size) override; //!< returns string description of component + void toString(char* str, FwSizeType size) override; //!< returns string description of component #endif PRIVATE: U32 m_idBase; //!< ID base for opcodes etc. - NATIVE_INT_TYPE m_instance; //!< instance of component object + FwEnumStoreType m_instance; //!< instance of component object }; diff --git a/Fw/Comp/QueuedComponentBase.cpp b/Fw/Comp/QueuedComponentBase.cpp index 6fa01d695d0..781b93236dc 100644 --- a/Fw/Comp/QueuedComponentBase.cpp +++ b/Fw/Comp/QueuedComponentBase.cpp @@ -15,7 +15,7 @@ namespace Fw { } - void QueuedComponentBase::init(NATIVE_INT_TYPE instance) { + void QueuedComponentBase::init(FwEnumStoreType instance) { PassiveComponentBase::init(instance); } @@ -36,7 +36,7 @@ namespace Fw { return this->m_queue.create(queueName, depth, msgSize); } - NATIVE_INT_TYPE QueuedComponentBase::getNumMsgsDropped() { + FwSizeType QueuedComponentBase::getNumMsgsDropped() { return this->m_msgsDropped; } diff --git a/Fw/Comp/QueuedComponentBase.hpp b/Fw/Comp/QueuedComponentBase.hpp index d78f69d3939..236e2286c89 100644 --- a/Fw/Comp/QueuedComponentBase.hpp +++ b/Fw/Comp/QueuedComponentBase.hpp @@ -32,17 +32,17 @@ namespace Fw { PROTECTED: QueuedComponentBase(const char* name); //!< Constructor virtual ~QueuedComponentBase(); //!< Destructor - void init(NATIVE_INT_TYPE instance); //!< initialization function + void init(FwEnumStoreType instance); //!< initialization function Os::Queue m_queue; //!< queue object for active component Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize); virtual MsgDispatchStatus doDispatch()=0; //!< method to dispatch a single message in the queue. #if FW_OBJECT_TO_STRING == 1 virtual const char* getToStringFormatString(); //!< Format string for toString function #endif - NATIVE_INT_TYPE getNumMsgsDropped(); //!< return number of messages dropped + FwSizeType getNumMsgsDropped(); //!< return number of messages dropped void incNumMsgDropped(); //!< increment the number of messages dropped PRIVATE: - NATIVE_INT_TYPE m_msgsDropped; //!< number of messages dropped from full queue + FwSizeType m_msgsDropped; //!< number of messages dropped from full queue }; } diff --git a/Fw/Dp/DpContainer.cpp b/Fw/Dp/DpContainer.cpp index be3a6c6f77d..f9163b3af77 100644 --- a/Fw/Dp/DpContainer.cpp +++ b/Fw/Dp/DpContainer.cpp @@ -203,7 +203,7 @@ Utils::HashBuffer DpContainer::computeDataHash() const { FW_ASSERT(DATA_OFFSET + dataSize <= bufferSize, static_cast(DATA_OFFSET + dataSize), static_cast(bufferSize)); Utils::HashBuffer computedHash; - Utils::Hash::hash(dataAddr, static_cast(dataSize), computedHash); + Utils::Hash::hash(dataAddr, dataSize, computedHash); return computedHash; } diff --git a/Fw/Dp/test/util/DpContainerHeader.hpp b/Fw/Dp/test/util/DpContainerHeader.hpp index 6c7cf5f5672..7b74482a42a 100644 --- a/Fw/Dp/test/util/DpContainerHeader.hpp +++ b/Fw/Dp/test/util/DpContainerHeader.hpp @@ -76,7 +76,7 @@ struct DpContainerHeader { DP_CONTAINER_HEADER_ASSERT_EQ(status, FW_SERIALIZE_OK); // Deserialize the user data DpContainerHeader::moveDeserToOffset(file, line, buffer, DpContainer::Header::USER_DATA_OFFSET); - NATIVE_UINT_TYPE size = sizeof this->m_userData; + FwSizeType size = sizeof this->m_userData; const bool omitLength = true; status = serializeRepr.deserialize(this->m_userData, size, omitLength); DP_CONTAINER_HEADER_ASSERT_EQ(status, FW_SERIALIZE_OK); diff --git a/Fw/Log/AmpcsEvrLogPacket.cpp b/Fw/Log/AmpcsEvrLogPacket.cpp index 1a6e1736c38..cde64ae79ae 100644 --- a/Fw/Log/AmpcsEvrLogPacket.cpp +++ b/Fw/Log/AmpcsEvrLogPacket.cpp @@ -50,7 +50,7 @@ namespace Fw { } SerializeStatus AmpcsEvrLogPacket::deserialize(SerializeBufferBase& buffer) { - NATIVE_UINT_TYPE len; + FwSizeType len; SerializeStatus stat; @@ -75,7 +75,7 @@ namespace Fw { return stat; } - NATIVE_UINT_TYPE size = buffer.getBuffLeft(); + FwSizeType size = buffer.getBuffLeft(); stat = buffer.deserialize(this->m_logBuffer.getBuffAddr(),size,true); if (stat == FW_SERIALIZE_OK) { // Shouldn't fail diff --git a/Fw/Log/LogBuffer.cpp b/Fw/Log/LogBuffer.cpp index 58683d5cb10..e85534c6da1 100644 --- a/Fw/Log/LogBuffer.cpp +++ b/Fw/Log/LogBuffer.cpp @@ -3,7 +3,7 @@ namespace Fw { - LogBuffer::LogBuffer(const U8 *args, NATIVE_UINT_TYPE size) { + LogBuffer::LogBuffer(const U8 *args, FwSizeType size) { SerializeStatus stat = SerializeBufferBase::setBuff(args,size); FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -29,7 +29,7 @@ namespace Fw { return *this; } - NATIVE_UINT_TYPE LogBuffer::getBuffCapacity() const { + FwSizeType LogBuffer::getBuffCapacity() const { return sizeof(this->m_bufferData); } diff --git a/Fw/Log/LogBuffer.hpp b/Fw/Log/LogBuffer.hpp index 8e310f8f3c2..c60e5a68f10 100644 --- a/Fw/Log/LogBuffer.hpp +++ b/Fw/Log/LogBuffer.hpp @@ -26,13 +26,13 @@ namespace Fw { SERIALIZED_SIZE = FW_LOG_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType) }; - LogBuffer(const U8 *args, NATIVE_UINT_TYPE size); + LogBuffer(const U8 *args, FwSizeType size); LogBuffer(); LogBuffer(const LogBuffer& other); virtual ~LogBuffer(); LogBuffer& operator=(const LogBuffer& other); - NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer + FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Log/LogPacket.cpp b/Fw/Log/LogPacket.cpp index 46ecae07a85..ad8a214d690 100644 --- a/Fw/Log/LogPacket.cpp +++ b/Fw/Log/LogPacket.cpp @@ -56,7 +56,7 @@ namespace Fw { } // remainder of buffer must be telemetry value - NATIVE_UINT_TYPE size = buffer.getBuffLeft(); + FwSizeType size = buffer.getBuffLeft(); stat = buffer.deserialize(this->m_logBuffer.getBuffAddr(),size,true); if (stat == FW_SERIALIZE_OK) { // Shouldn't fail diff --git a/Fw/Logger/test/ut/LoggerRules.cpp b/Fw/Logger/test/ut/LoggerRules.cpp index 45ee2519f49..06e9ef445dd 100644 --- a/Fw/Logger/test/ut/LoggerRules.cpp +++ b/Fw/Logger/test/ut/LoggerRules.cpp @@ -27,7 +27,7 @@ bool Register::precondition(const MockLogging::FakeLogger& truth) { // Register NULL or truth as the system logger void Register::action(MockLogging::FakeLogger& truth) { // Select a registration value: 1 -> logger, 0 -> NULL - NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, 1); + U32 random = STest::Pick::lowerUpper(0, 1); if (random == 1) { Fw::Logger::registerLogger(&truth); truth.s_current = &truth; @@ -48,8 +48,8 @@ bool LogGood::precondition(const MockLogging::FakeLogger& truth) { // Log valid messages void LogGood::action(MockLogging::FakeLogger& truth) { - NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, 10); - NATIVE_INT_TYPE ra[10]; + U32 random = STest::Pick::lowerUpper(0, 10); + U32 ra[10]; for (int i = 0; i < 10; ++i) { ra[i] = STest::Pick::lowerUpper(0, 0xffffffff); } @@ -127,8 +127,8 @@ bool LogGoodStringObject::precondition(const MockLogging::FakeLogger& truth) { // Log valid messages void LogGoodStringObject::action(MockLogging::FakeLogger& truth) { Fw::String my_string; - NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, my_string.getCapacity() - 1); - for (int i = 0; i < random; ++i) { + U32 random = STest::Pick::lowerUpper(0, my_string.getCapacity() - 1); + for (U32 i = 0; i < random; ++i) { const_cast(my_string.toChar())[i] = static_cast(STest::Pick::lowerUpper(0, std::numeric_limits::max())); } @@ -149,8 +149,8 @@ bool LogBad::precondition(const MockLogging::FakeLogger& truth) { // Log valid messages void LogBad::action(MockLogging::FakeLogger& truth) { - NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, 10); - NATIVE_INT_TYPE ra[10]; + U32 random = STest::Pick::lowerUpper(0, 10); + U32 ra[10]; for (int i = 0; i < 10; ++i) { ra[i] = STest::Pick::lowerUpper(0, 0xffffffff); } diff --git a/Fw/Obj/ObjBase.cpp b/Fw/Obj/ObjBase.cpp index 2d86ebac2a3..ad9cf851141 100644 --- a/Fw/Obj/ObjBase.cpp +++ b/Fw/Obj/ObjBase.cpp @@ -44,7 +44,7 @@ namespace Fw { this->m_objName = name; } #if FW_OBJECT_TO_STRING == 1 - void ObjBase::toString(char* str, NATIVE_INT_TYPE size) { + void ObjBase::toString(char* str, FwSizeType size) { FW_ASSERT(size > 0); FW_ASSERT(str != nullptr); Fw::FormatStatus formatStatus = Fw::ExternalString(str, static_cast(size)).format("Obj: %s", this->m_objName.toChar()); diff --git a/Fw/Obj/ObjBase.hpp b/Fw/Obj/ObjBase.hpp index b0b30d18ab9..f402c8681dd 100644 --- a/Fw/Obj/ObjBase.hpp +++ b/Fw/Obj/ObjBase.hpp @@ -61,7 +61,7 @@ namespace Fw { //! //! \param str destination buffer where string description is placed //! \param size destination buffer size (including terminator). String should be terminated - virtual void toString(char* str, NATIVE_INT_TYPE size); //!< virtual method to get description of object + virtual void toString(char* str, FwSizeType size); //!< virtual method to get description of object #endif // FW_OBJECT_TO_STRING #endif // FW_OBJECT_NAMES diff --git a/Fw/Obj/SimpleObjRegistry.cpp b/Fw/Obj/SimpleObjRegistry.cpp index 2521349fa76..e6eb35ed68a 100644 --- a/Fw/Obj/SimpleObjRegistry.cpp +++ b/Fw/Obj/SimpleObjRegistry.cpp @@ -13,7 +13,7 @@ namespace Fw { ObjBase::setObjRegistry(this); this->m_numEntries = 0; // Initialize pointer array - for (NATIVE_INT_TYPE entry = 0; entry < FW_OBJ_SIMPLE_REG_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < FW_OBJ_SIMPLE_REG_ENTRIES; entry++) { this->m_objPtrArray[entry] = nullptr; } } @@ -23,7 +23,7 @@ namespace Fw { } void SimpleObjRegistry::dump() { - for (NATIVE_INT_TYPE obj = 0; obj < this->m_numEntries; obj++) { + for (FwSizeType obj = 0; obj < this->m_numEntries; obj++) { #if FW_OBJECT_NAMES == 1 #if FW_OBJECT_TO_STRING == 1 char objDump[FW_OBJ_SIMPLE_REG_BUFF_SIZE]; @@ -43,7 +43,7 @@ namespace Fw { #if FW_OBJECT_NAMES == 1 void SimpleObjRegistry::dump(const char* objName) { - for (NATIVE_INT_TYPE obj = 0; obj < this->m_numEntries; obj++) { + for (FwSizeType obj = 0; obj < this->m_numEntries; obj++) { char objDump[FW_OBJ_SIMPLE_REG_BUFF_SIZE]; if (strncmp(objName,this->m_objPtrArray[obj]->getObjName(),sizeof(objDump)) == 0) { #if FW_OBJECT_TO_STRING == 1 diff --git a/Fw/Obj/SimpleObjRegistry.hpp b/Fw/Obj/SimpleObjRegistry.hpp index 4d700b698e6..31776172c18 100644 --- a/Fw/Obj/SimpleObjRegistry.hpp +++ b/Fw/Obj/SimpleObjRegistry.hpp @@ -38,7 +38,7 @@ namespace Fw { private: void regObject(ObjBase* obj); //!< register an object with the registry ObjBase* m_objPtrArray[FW_OBJ_SIMPLE_REG_ENTRIES]; //!< array of objects - NATIVE_INT_TYPE m_numEntries; //!< number of entries in the registry + FwSizeType m_numEntries; //!< number of entries in the registry }; } diff --git a/Fw/Port/PortBase.cpp b/Fw/Port/PortBase.cpp index 10621269b94..87f019afd87 100644 --- a/Fw/Port/PortBase.cpp +++ b/Fw/Port/PortBase.cpp @@ -81,7 +81,7 @@ namespace Fw { return "Port: %s %s->(%s)"; } - void PortBase::toString(char* buffer, NATIVE_INT_TYPE size) { + void PortBase::toString(char* buffer, FwSizeType size) { FW_ASSERT(size > 0); // Get the port-custom format string const char* formatString = this->getToStringFormatString(); diff --git a/Fw/Port/PortBase.hpp b/Fw/Port/PortBase.hpp index c9b8c09458a..ad064d79aec 100644 --- a/Fw/Port/PortBase.hpp +++ b/Fw/Port/PortBase.hpp @@ -35,7 +35,7 @@ namespace Fw { #if FW_OBJECT_TO_STRING virtual const char* getToStringFormatString(); //!< Get format string for toString call - void toString(char* str, NATIVE_INT_TYPE size) override; //!< Unified port toString method + void toString(char* str, FwSizeType size) override; //!< Unified port toString method #endif diff --git a/Fw/Prm/PrmBuffer.cpp b/Fw/Prm/PrmBuffer.cpp index da4f1d00b90..f4c68beead8 100644 --- a/Fw/Prm/PrmBuffer.cpp +++ b/Fw/Prm/PrmBuffer.cpp @@ -3,7 +3,7 @@ namespace Fw { - ParamBuffer::ParamBuffer(const U8 *args, NATIVE_UINT_TYPE size) { + ParamBuffer::ParamBuffer(const U8 *args, FwSizeType size) { SerializeStatus stat = SerializeBufferBase::setBuff(args,size); FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); } @@ -29,7 +29,7 @@ namespace Fw { return *this; } - NATIVE_UINT_TYPE ParamBuffer::getBuffCapacity() const { + FwSizeType ParamBuffer::getBuffCapacity() const { return sizeof(this->m_bufferData); } diff --git a/Fw/Prm/PrmBuffer.hpp b/Fw/Prm/PrmBuffer.hpp index ef97d4f69e4..3d33942793f 100644 --- a/Fw/Prm/PrmBuffer.hpp +++ b/Fw/Prm/PrmBuffer.hpp @@ -32,13 +32,13 @@ namespace Fw { SERIALIZED_SIZE = FW_PARAM_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType) }; - ParamBuffer(const U8 *args, NATIVE_UINT_TYPE size); + ParamBuffer(const U8 *args, FwSizeType size); ParamBuffer(); ParamBuffer(const ParamBuffer& other); virtual ~ParamBuffer(); ParamBuffer& operator=(const ParamBuffer& other); - NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer + FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/SerializableFile/SerializableFile.cpp b/Fw/SerializableFile/SerializableFile.cpp index 35e79b3f62f..6c252d358c5 100644 --- a/Fw/SerializableFile/SerializableFile.cpp +++ b/Fw/SerializableFile/SerializableFile.cpp @@ -16,7 +16,7 @@ namespace Fw { - SerializableFile::SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize) : + SerializableFile::SerializableFile(MemAllocator* allocator, FwSizeType maxSerializedSize) : m_allocator(allocator), m_recoverable(false), // for compiler; not used m_actualSize(maxSerializedSize), @@ -50,7 +50,7 @@ namespace Fw { this->reset(); SerializeStatus serStatus; - serStatus = this->m_buffer.setBuffLen(static_cast(length)); + serStatus = this->m_buffer.setBuffLen(static_cast(length)); FW_ASSERT(FW_SERIALIZE_OK == serStatus, serStatus); serStatus = serializable.deserialize(this->m_buffer); if(FW_SERIALIZE_OK != serStatus) { diff --git a/Fw/SerializableFile/SerializableFile.hpp b/Fw/SerializableFile/SerializableFile.hpp index 55b66268392..5677c672888 100644 --- a/Fw/SerializableFile/SerializableFile.hpp +++ b/Fw/SerializableFile/SerializableFile.hpp @@ -32,7 +32,7 @@ namespace Fw { }; // NOTE!: This should not be used with an allocator that can return a smaller buffer than requested - SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize); + SerializableFile(MemAllocator* allocator, FwSizeType maxSerializedSize); ~SerializableFile(); Status load(const char* fileName, Serializable& serializable); @@ -42,7 +42,7 @@ namespace Fw { void reset(); MemAllocator* m_allocator; bool m_recoverable; // don't care; for allocator - NATIVE_UINT_TYPE m_actualSize; // for checking + FwSizeType m_actualSize; // for checking SerialBuffer m_buffer; }; } diff --git a/Fw/Sm/SmSignalBuffer.cpp b/Fw/Sm/SmSignalBuffer.cpp index f13e8991a8c..2293a51eb7e 100644 --- a/Fw/Sm/SmSignalBuffer.cpp +++ b/Fw/Sm/SmSignalBuffer.cpp @@ -6,7 +6,7 @@ namespace Fw { SmSignalBuffer::SmSignalBuffer(const U8 *args, Serializable::SizeType size) : m_bufferData{} { FW_ASSERT(args != nullptr); FW_ASSERT(size <= sizeof(this->m_bufferData)); - SerializeStatus stat = SerializeBufferBase::setBuff(args,static_cast(size)); + SerializeStatus stat = SerializeBufferBase::setBuff(args,size); FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); } diff --git a/Fw/Test/UnitTestAssert.cpp b/Fw/Test/UnitTestAssert.cpp index 3e651f8ad63..4181e8999cf 100644 --- a/Fw/Test/UnitTestAssert.cpp +++ b/Fw/Test/UnitTestAssert.cpp @@ -45,14 +45,14 @@ namespace Test { #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT (void)fprintf(stderr,"Assert: 0x%" PRIx32 ":%" PRI_PlatformUIntType "\n", this->m_file, this->m_lineNo); #else - (void)fprintf(stderr,"Assert: %s:%" PRI_PlatformUIntType "\n", this->m_file.toChar(), this->m_lineNo); + (void)fprintf(stderr,"Assert: %s:%" PRI_FwSizeType "\n", this->m_file.toChar(), this->m_lineNo); #endif } void UnitTestAssert::reportAssert( FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -80,8 +80,8 @@ namespace Test { void UnitTestAssert::retrieveAssert( File& file, - NATIVE_UINT_TYPE& lineNo, - NATIVE_UINT_TYPE& numArgs, + FwSizeType& lineNo, + FwSizeType& numArgs, FwAssertArgType& arg1, FwAssertArgType& arg2, FwAssertArgType& arg3, diff --git a/Fw/Test/UnitTestAssert.hpp b/Fw/Test/UnitTestAssert.hpp index 07d1620a6b6..66d92e09771 100644 --- a/Fw/Test/UnitTestAssert.hpp +++ b/Fw/Test/UnitTestAssert.hpp @@ -32,8 +32,8 @@ namespace Test { void doAssert(); void reportAssert( FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -44,8 +44,8 @@ namespace Test { // retrieves assertion failure values void retrieveAssert( File& file, - NATIVE_UINT_TYPE& lineNo, - NATIVE_UINT_TYPE& numArgs, + FwSizeType& lineNo, + FwSizeType& numArgs, FwAssertArgType& arg1, FwAssertArgType& arg2, FwAssertArgType& arg3, @@ -62,8 +62,8 @@ namespace Test { private: File m_file; - NATIVE_UINT_TYPE m_lineNo; - NATIVE_UINT_TYPE m_numArgs; + FwSizeType m_lineNo; + FwSizeType m_numArgs; FwAssertArgType m_arg1; FwAssertArgType m_arg2; FwAssertArgType m_arg3; diff --git a/Fw/Tlm/TlmBuffer.cpp b/Fw/Tlm/TlmBuffer.cpp index ed18d188c6e..fea76543c14 100644 --- a/Fw/Tlm/TlmBuffer.cpp +++ b/Fw/Tlm/TlmBuffer.cpp @@ -3,7 +3,7 @@ namespace Fw { - TlmBuffer::TlmBuffer(const U8 *args, NATIVE_UINT_TYPE size) { + TlmBuffer::TlmBuffer(const U8 *args, FwSizeType size) { SerializeStatus stat = SerializeBufferBase::setBuff(args,size); FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); } @@ -29,7 +29,7 @@ namespace Fw { return *this; } - NATIVE_UINT_TYPE TlmBuffer::getBuffCapacity() const { + FwSizeType TlmBuffer::getBuffCapacity() const { return sizeof(this->m_bufferData); } diff --git a/Fw/Tlm/TlmBuffer.hpp b/Fw/Tlm/TlmBuffer.hpp index 4de7a678677..dfdaa610e83 100644 --- a/Fw/Tlm/TlmBuffer.hpp +++ b/Fw/Tlm/TlmBuffer.hpp @@ -25,13 +25,13 @@ namespace Fw { SERIALIZED_SIZE = FW_TLM_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType) }; - TlmBuffer(const U8 *args, NATIVE_UINT_TYPE size); + TlmBuffer(const U8 *args, FwSizeType size); TlmBuffer(); TlmBuffer(const TlmBuffer& other); virtual ~TlmBuffer(); TlmBuffer& operator=(const TlmBuffer& other); - NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer + FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer U8* getBuffAddr(); const U8* getBuffAddr() const; diff --git a/Fw/Tlm/TlmPacket.cpp b/Fw/Tlm/TlmPacket.cpp index 1fe3ebd8d02..899310cf0b8 100644 --- a/Fw/Tlm/TlmPacket.cpp +++ b/Fw/Tlm/TlmPacket.cpp @@ -49,7 +49,7 @@ namespace Fw { return Fw::FW_SERIALIZE_OK; } - NATIVE_UINT_TYPE TlmPacket::getNumEntries() { + FwSizeType TlmPacket::getNumEntries() { return this->m_numEntries; } @@ -63,7 +63,7 @@ namespace Fw { SerializeStatus TlmPacket::addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer) { // check to make sure there is room for all the fields - NATIVE_UINT_TYPE left = this->m_tlmBuffer.getBuffCapacity()-this->m_tlmBuffer.getBuffLength(); + FwSizeType left = this->m_tlmBuffer.getBuffCapacity()-this->m_tlmBuffer.getBuffLength(); if ( (sizeof(FwChanIdType) + Time::SERIALIZED_SIZE + buffer.getBuffLength()) > left ) { @@ -97,7 +97,7 @@ namespace Fw { } // extract telemetry value - SerializeStatus TlmPacket::extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, NATIVE_UINT_TYPE bufferSize) { + SerializeStatus TlmPacket::extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, FwSizeType bufferSize) { // deserialize items out of buffer @@ -147,7 +147,7 @@ namespace Fw { return stat; } // deserialize the channel value entry buffers - NATIVE_UINT_TYPE size = buffer.getBuffLeft(); + FwSizeType size = buffer.getBuffLeft(); stat = buffer.deserialize(this->m_tlmBuffer.getBuffAddr(),size,true); if (stat == FW_SERIALIZE_OK) { // Shouldn't fail diff --git a/Fw/Tlm/TlmPacket.hpp b/Fw/Tlm/TlmPacket.hpp index 3459ef7e7ef..c064d389056 100644 --- a/Fw/Tlm/TlmPacket.hpp +++ b/Fw/Tlm/TlmPacket.hpp @@ -31,7 +31,7 @@ namespace Fw { SerializeStatus addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer); //! extract telemetry value - since there are potentially multiple channel values in the packet, //! the size of the entry must be known - SerializeStatus extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, NATIVE_UINT_TYPE bufferSize); + SerializeStatus extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, FwSizeType bufferSize); //! Reset serialization of values. This should be done when starting to accumulate a new set of values. SerializeStatus resetPktSer(); @@ -42,11 +42,11 @@ namespace Fw { //! set the internal buffer for deserializing values void setBuffer(Fw::ComBuffer& buffer); //! get the number of packets added via addValue() - NATIVE_UINT_TYPE getNumEntries(); + FwSizeType getNumEntries(); PRIVATE: ComBuffer m_tlmBuffer; //!< serialized data - NATIVE_UINT_TYPE m_numEntries; //!< number of entries stored during addValue() + FwSizeType m_numEntries; //!< number of entries stored during addValue() }; } /* namespace Fw */ diff --git a/Fw/Tlm/test/ut/TlmTest.cpp b/Fw/Tlm/test/ut/TlmTest.cpp index 6f4da39f9e7..0e2c582ed5b 100644 --- a/Fw/Tlm/test/ut/TlmTest.cpp +++ b/Fw/Tlm/test/ut/TlmTest.cpp @@ -40,18 +40,18 @@ TEST(FwTlmTest,TlmPacketSerializeFill) { // compute a single entry size assuming for the test that the value of the telemetry channel // is a U32 - static const NATIVE_UINT_TYPE SIZE_OF_ENTRY = sizeof(FwChanIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32); + static const FwSizeType SIZE_OF_ENTRY = sizeof(FwChanIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32); // compute the number of entries that should fit - will equal rounded down value of // ComBuffer size - size of telemetry packet id / size of an entry - static const NATIVE_UINT_TYPE NUM_ENTRIES = (FW_COM_BUFFER_MAX_SIZE - sizeof(FwPacketDescriptorType))/SIZE_OF_ENTRY; + static const FwSizeType NUM_ENTRIES = (FW_COM_BUFFER_MAX_SIZE - sizeof(FwPacketDescriptorType))/SIZE_OF_ENTRY; Fw::TlmPacket pktIn; ASSERT_EQ(Fw::FW_SERIALIZE_OK,pktIn.resetPktSer()); // fill a telemetry packet - for (NATIVE_UINT_TYPE entry = 0; entry < NUM_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < NUM_ENTRIES; entry++) { // Serialize data @@ -81,7 +81,7 @@ TEST(FwTlmTest,TlmPacketSerializeFill) { ASSERT_EQ(Fw::FW_SERIALIZE_OK,pktOut.resetPktDeser()); // empty the packet of entries - for (NATIVE_UINT_TYPE entry = 0; entry < NUM_ENTRIES; entry++) { + for (FwSizeType entry = 0; entry < NUM_ENTRIES; entry++) { // Deserialize data Fw::TlmBuffer buffOut; Fw::Time timeOut; diff --git a/Fw/Types/Assert.cpp b/Fw/Types/Assert.cpp index f69cc862875..38945147e40 100644 --- a/Fw/Types/Assert.cpp +++ b/Fw/Types/Assert.cpp @@ -20,8 +20,8 @@ void defaultPrintAssert(const CHAR* msg) { } void defaultReportAssert(FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -29,40 +29,38 @@ void defaultReportAssert(FILE_NAME_ARG file, FwAssertArgType arg5, FwAssertArgType arg6, CHAR* destBuffer, - NATIVE_INT_TYPE buffSize) { - static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), - "NATIVE_INT_TYPE cannot fit into FwSizeType"); + FwSizeType buffSize) { switch (numArgs) { case 0: - (void)stringFormat(destBuffer, static_cast(buffSize), fileIdFs, file, lineNo); + (void)stringFormat(destBuffer, buffSize, fileIdFs, file, lineNo); break; case 1: - (void)stringFormat(destBuffer, static_cast(buffSize), + (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType, file, lineNo, arg1); break; case 2: - (void)stringFormat(destBuffer, static_cast(buffSize), + (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, arg1, arg2); break; case 3: - (void)stringFormat(destBuffer, static_cast(buffSize), + (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, arg1, arg2, arg3); break; case 4: - (void)stringFormat(destBuffer, static_cast(buffSize), + (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, arg1, arg2, arg3, arg4); break; case 5: - (void)stringFormat(destBuffer, static_cast(buffSize), + (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, arg1, arg2, arg3, arg4, arg5); break; case 6: - (void)stringFormat(destBuffer, static_cast(buffSize), + (void)stringFormat(destBuffer, buffSize, fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, arg1, arg2, arg3, arg4, arg5, arg6); @@ -77,8 +75,8 @@ void AssertHook::printAssert(const CHAR* msg) { } void AssertHook::reportAssert(FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -86,7 +84,7 @@ void AssertHook::reportAssert(FILE_NAME_ARG file, FwAssertArgType arg5, FwAssertArgType arg6) { CHAR destBuffer[FW_ASSERT_TEXT_SIZE]; - defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, destBuffer, sizeof(destBuffer)); + defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, destBuffer, static_cast(sizeof(destBuffer))); // print message this->printAssert(destBuffer); } @@ -107,9 +105,9 @@ void AssertHook::deregisterHook() { } // Default handler of SwAssert functions -NATIVE_INT_TYPE defaultSwAssert(FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, +I8 defaultSwAssert(FILE_NAME_ARG file, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -118,7 +116,7 @@ NATIVE_INT_TYPE defaultSwAssert(FILE_NAME_ARG file, FwAssertArgType arg6) { if (nullptr == s_assertHook) { CHAR assertMsg[FW_ASSERT_TEXT_SIZE]; - defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, assertMsg, sizeof(assertMsg)); + defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, assertMsg, static_cast(sizeof(assertMsg))); defaultPrintAssert(assertMsg); assert(0); } else { @@ -128,66 +126,66 @@ NATIVE_INT_TYPE defaultSwAssert(FILE_NAME_ARG file, return 0; } -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo) { +I8 SwAssert(FILE_NAME_ARG file, FwSizeType lineNo) { return defaultSwAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0); } -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, NATIVE_UINT_TYPE lineNo) { +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwSizeType lineNo) { return defaultSwAssert(file, lineNo, 1, arg1, 0, 0, 0, 0, 0); } -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, NATIVE_UINT_TYPE lineNo) { +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwSizeType lineNo) { return defaultSwAssert(file, lineNo, 2, arg1, arg2, 0, 0, 0, 0); } -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, - NATIVE_UINT_TYPE lineNo) { + FwSizeType lineNo) { return defaultSwAssert(file, lineNo, 3, arg1, arg2, arg3, 0, 0, 0); } -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, - NATIVE_UINT_TYPE lineNo) { + FwSizeType lineNo) { return defaultSwAssert(file, lineNo, 4, arg1, arg2, arg3, arg4, 0, 0); } -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, FwAssertArgType arg5, - NATIVE_UINT_TYPE lineNo) { + FwSizeType lineNo) { return defaultSwAssert(file, lineNo, 5, arg1, arg2, arg3, arg4, arg5, 0); } -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, FwAssertArgType arg5, FwAssertArgType arg6, - NATIVE_UINT_TYPE lineNo) { + FwSizeType lineNo) { return defaultSwAssert(file, lineNo, 6, arg1, arg2, arg3, arg4, arg5, arg6); } } // namespace Fw -// define C asserts. +// define C asserts with C linkage extern "C" { -NATIVE_INT_TYPE CAssert0(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo); +I8 CAssert0(FILE_NAME_ARG file, FwSizeType lineNo); } -NATIVE_INT_TYPE CAssert0(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo) { +I8 CAssert0(FILE_NAME_ARG file, FwSizeType lineNo) { if (nullptr == Fw::s_assertHook) { CHAR assertMsg[FW_ASSERT_TEXT_SIZE]; - Fw::defaultReportAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0, assertMsg, sizeof(assertMsg)); + Fw::defaultReportAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0, assertMsg, static_cast(sizeof(assertMsg))); } else { Fw::s_assertHook->reportAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0); Fw::s_assertHook->doAssert(); diff --git a/Fw/Types/Assert.hpp b/Fw/Types/Assert.hpp index 87f72a2f95d..35bc0c04c1a 100644 --- a/Fw/Types/Assert.hpp +++ b/Fw/Types/Assert.hpp @@ -55,48 +55,48 @@ namespace Fw { //! Assert with no arguments -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN; +I8 SwAssert(FILE_NAME_ARG file, FwSizeType lineNo) CLANG_ANALYZER_NORETURN; //! Assert with one argument -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN; +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwSizeType lineNo) CLANG_ANALYZER_NORETURN; //! Assert with two arguments -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, NATIVE_UINT_TYPE lineNo) +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwSizeType lineNo) CLANG_ANALYZER_NORETURN; //! Assert with three arguments -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, - NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN; + FwSizeType lineNo) CLANG_ANALYZER_NORETURN; //! Assert with four arguments -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, - NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN; + FwSizeType lineNo) CLANG_ANALYZER_NORETURN; //! Assert with five arguments -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, FwAssertArgType arg5, - NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN; + FwSizeType lineNo) CLANG_ANALYZER_NORETURN; //! Assert with six arguments -NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, +I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, FwAssertArgType arg5, FwAssertArgType arg6, - NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN; + FwSizeType lineNo) CLANG_ANALYZER_NORETURN; } // namespace Fw // Base class for declaring an assert hook @@ -111,8 +111,8 @@ class AssertHook { virtual ~AssertHook(){}; //!< destructor // override this function to intercept asserts virtual void reportAssert(FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, diff --git a/Fw/Types/CAssert.h b/Fw/Types/CAssert.h index 17e417e0ce2..f3d512374e8 100644 --- a/Fw/Types/CAssert.h +++ b/Fw/Types/CAssert.h @@ -21,15 +21,14 @@ extern "C" { #else // ASSERT is defined #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT -#define FILE_NAME_ARG NATIVE_UINT_TYPE +#define FILE_NAME_ARG U32 #define FW_CASSERT(cond) ((void)((cond) ? (0) : (CAssert0(ASSERT_FILE_ID, __LINE__)))) #else #define FILE_NAME_ARG const CHAR* #define FW_CASSERT(cond) ((void)((cond) ? (0) : (CAssert0((FILE_NAME_ARG)(__FILE__), __LINE__)))) #endif -I32 CAssert0(FILE_NAME_ARG file, U32 lineNo); //!< C assert function -I32 CAssert1(FILE_NAME_ARG file, U32 lineNo, NATIVE_INT_TYPE arg1); //!< C assert function 1 +I8 CAssert0(FILE_NAME_ARG file, FwSizeType lineNo); //!< C assert function #endif // ASSERT is defined diff --git a/Fw/Types/MallocAllocator.cpp b/Fw/Types/MallocAllocator.cpp index a218c7d4a27..bbbc7a680a3 100644 --- a/Fw/Types/MallocAllocator.cpp +++ b/Fw/Types/MallocAllocator.cpp @@ -19,7 +19,7 @@ MallocAllocator::MallocAllocator() {} MallocAllocator::~MallocAllocator() {} -void* MallocAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable) { +void* MallocAllocator::allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable) { // don't use identifier // heap memory is never recoverable recoverable = false; @@ -30,7 +30,7 @@ void* MallocAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_T return mem; } -void MallocAllocator::deallocate(const NATIVE_UINT_TYPE identifier, void* ptr) { +void MallocAllocator::deallocate(const FwEnumStoreType identifier, void* ptr) { ::free(ptr); } diff --git a/Fw/Types/MallocAllocator.hpp b/Fw/Types/MallocAllocator.hpp index 354435e581c..58f10ecc86a 100644 --- a/Fw/Types/MallocAllocator.hpp +++ b/Fw/Types/MallocAllocator.hpp @@ -37,13 +37,13 @@ class MallocAllocator : public MemAllocator { * \param recoverable - flag to indicate the memory could be recoverable (always set to false) * \return the pointer to memory. Zero if unable to allocate. */ - void* allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable); + void* allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable); //! Deallocate memory /*! * \param identifier the memory segment identifier (not used) * \param ptr the pointer to memory returned by allocate() */ - void deallocate(const NATIVE_UINT_TYPE identifier, void* ptr); + void deallocate(const FwEnumStoreType identifier, void* ptr); }; } /* namespace Fw */ diff --git a/Fw/Types/MemAllocator.hpp b/Fw/Types/MemAllocator.hpp index 418ce604453..5e7cf4e17e4 100644 --- a/Fw/Types/MemAllocator.hpp +++ b/Fw/Types/MemAllocator.hpp @@ -52,13 +52,13 @@ class MemAllocator { * \param recoverable - flag to indicate the memory could be recoverable * \return the pointer to memory. Zero if unable to allocate */ - virtual void* allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable) = 0; + virtual void* allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable) = 0; //! Deallocate memory /*! * \param identifier the memory segment identifier, each identifier is to be used in once single allocation * \param ptr the pointer to memory returned by allocate() */ - virtual void deallocate(const NATIVE_UINT_TYPE identifier, void* ptr) = 0; + virtual void deallocate(const FwEnumStoreType identifier, void* ptr) = 0; protected: MemAllocator(); diff --git a/Fw/Types/MmapAllocator.cpp b/Fw/Types/MmapAllocator.cpp index 7ff42c8fa96..bf1855bcd6c 100644 --- a/Fw/Types/MmapAllocator.cpp +++ b/Fw/Types/MmapAllocator.cpp @@ -21,7 +21,7 @@ MmapAllocator::MmapAllocator() : m_length(0) {} MmapAllocator::~MmapAllocator() {} -void* MmapAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable) { +void* MmapAllocator::allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable) { void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (addr == MAP_FAILED) { size = 0; @@ -35,7 +35,7 @@ void* MmapAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYP return addr; } -void MmapAllocator::deallocate(const NATIVE_UINT_TYPE identifier, void* ptr) { +void MmapAllocator::deallocate(const FwEnumStoreType identifier, void* ptr) { if (this->m_length) { int stat = munmap(ptr, this->m_length); FW_ASSERT(stat == 0, stat); diff --git a/Fw/Types/MmapAllocator.hpp b/Fw/Types/MmapAllocator.hpp index 1574cafcfc2..5be4e1e043e 100644 --- a/Fw/Types/MmapAllocator.hpp +++ b/Fw/Types/MmapAllocator.hpp @@ -31,15 +31,15 @@ class MmapAllocator : public MemAllocator { //! \param identifier: identifier to use with allocation //! \param size: size of memory to be allocated //! \param recoverable: (output) is this memory recoverable after a reset. Always false for mmap. - void* allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable); + void* allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable); //! Deallocation of memory using the mmap allocator //! \param identifier: identifier used at allocation //! \param ptr: pointer to memory being deallocated - void deallocate(const NATIVE_UINT_TYPE identifier, void* ptr); + void deallocate(const FwEnumStoreType identifier, void* ptr); private: - NATIVE_UINT_TYPE m_length; + FwSizeType m_length; }; } /* namespace Fw */ diff --git a/Fw/Types/SerialBuffer.cpp b/Fw/Types/SerialBuffer.cpp index 89d2ea16a11..e42f22ed8c8 100644 --- a/Fw/Types/SerialBuffer.cpp +++ b/Fw/Types/SerialBuffer.cpp @@ -15,9 +15,9 @@ namespace Fw { -SerialBuffer ::SerialBuffer(U8* const data, const U32 capacity) : m_data(data), m_capacity(capacity) {} +SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : m_data(data), m_capacity(capacity) {} -NATIVE_UINT_TYPE SerialBuffer ::getBuffCapacity() const { +FwSizeType SerialBuffer ::getBuffCapacity() const { return m_capacity; } @@ -34,12 +34,12 @@ void SerialBuffer ::fill() { FW_ASSERT(status == FW_SERIALIZE_OK); } -SerializeStatus SerialBuffer ::pushBytes(const U8* const addr, const NATIVE_UINT_TYPE n) { +SerializeStatus SerialBuffer ::pushBytes(const U8* const addr, const FwSizeType n) { // "true" means "just push the bytes" return this->serialize(const_cast(addr), n, true); } -SerializeStatus SerialBuffer ::popBytes(U8* const addr, NATIVE_UINT_TYPE n) { +SerializeStatus SerialBuffer ::popBytes(U8* const addr, FwSizeType n) { // "true" means "just pop the bytes" return this->deserialize(addr, n, true); } diff --git a/Fw/Types/SerialBuffer.hpp b/Fw/Types/SerialBuffer.hpp index 4fc5dcf43c3..9b04e37421b 100644 --- a/Fw/Types/SerialBuffer.hpp +++ b/Fw/Types/SerialBuffer.hpp @@ -30,7 +30,7 @@ class SerialBuffer : public SerializeBufferBase { //! Construct a SerialBuffer //! SerialBuffer(U8* const data, //!< Pointer to the data - const U32 capacity //!< The buffer capacity + const FwSizeType capacity //!< The buffer capacity ); public: @@ -38,7 +38,7 @@ class SerialBuffer : public SerializeBufferBase { // Pure virtual methods from SerializeBufferBase // ---------------------------------------------------------------------- - NATIVE_UINT_TYPE getBuffCapacity() const; + FwSizeType getBuffCapacity() const; U8* getBuffAddr(); @@ -53,13 +53,13 @@ class SerialBuffer : public SerializeBufferBase { void fill(); //! Push n bytes onto the buffer - SerializeStatus pushBytes(const U8* const addr, //!< Address of bytes to push - const NATIVE_UINT_TYPE n //!< Number of bytes + SerializeStatus pushBytes(const U8* const addr, //!< Address of bytes to push + const FwSizeType n //!< Number of bytes ); //! Pop n bytes off the buffer - SerializeStatus popBytes(U8* const addr, //!< Address of bytes to pop - NATIVE_UINT_TYPE n //!< Number of bytes to pop + SerializeStatus popBytes(U8* const addr, //!< Address of bytes to pop + FwSizeType n //!< Number of bytes to pop ); private: @@ -71,7 +71,7 @@ class SerialBuffer : public SerializeBufferBase { U8* const m_data; //! The capacity - const U32 m_capacity; + const FwSizeType m_capacity; }; } // namespace Fw diff --git a/Fw/Types/Serializable.cpp b/Fw/Types/Serializable.cpp index afe43934ed6..5a0395dd592 100644 --- a/Fw/Types/Serializable.cpp +++ b/Fw/Types/Serializable.cpp @@ -222,7 +222,7 @@ SerializeStatus SerializeBufferBase::serialize(const void* val) { return FW_SERIALIZE_NO_ROOM_LEFT; } - return this->serialize(reinterpret_cast(val)); + return this->serialize(reinterpret_cast(val)); } SerializeStatus SerializeBufferBase::serialize(const U8* buff, Serializable::SizeType length) { diff --git a/Fw/Types/Serializable.hpp b/Fw/Types/Serializable.hpp index 61513d5531b..bf3abcc36b2 100644 --- a/Fw/Types/Serializable.hpp +++ b/Fw/Types/Serializable.hpp @@ -25,7 +25,7 @@ class SerializeBufferBase; //!< forward declaration class Serializable { public: // Size type for backwards compatibility - using SizeType = NATIVE_UINT_TYPE; + using SizeType = FwSizeType; public: virtual SerializeStatus serialize(SerializeBufferBase& buffer) const = 0; //!< serialize contents @@ -85,9 +85,9 @@ class SerializeBufferBase { const void* val); //!< serialize pointer (careful, only pointer value, not contents are serialized) //! serialize data buffer - SerializeStatus serialize(const U8* buff, NATIVE_UINT_TYPE length, bool noLength); + SerializeStatus serialize(const U8* buff, FwSizeType length, bool noLength); //! serialize data buffer - SerializeStatus serialize(const U8* buff, NATIVE_UINT_TYPE length); + SerializeStatus serialize(const U8* buff, FwSizeType length); //! \brief serialize a byte buffer of a given length //! @@ -133,10 +133,10 @@ class SerializeBufferBase { SerializeStatus deserialize(void*& val); //!< deserialize point value (careful, pointer value only, not contents) //! deserialize data buffer - SerializeStatus deserialize(U8* buff, NATIVE_UINT_TYPE& length, bool noLength); + SerializeStatus deserialize(U8* buff, FwSizeType& length, bool noLength); //! deserialize data buffer - SerializeStatus deserialize(U8* buff, NATIVE_UINT_TYPE& length); + SerializeStatus deserialize(U8* buff, FwSizeType& length); //! \brief deserialize a byte buffer of a given length //! //! Deserialize bytes into `buff` of `length` bytes. If `serializationMode` is set to `INCLUDE_LENGTH` then diff --git a/Fw/Types/StringBase.hpp b/Fw/Types/StringBase.hpp index 6290386afe4..11319425b67 100644 --- a/Fw/Types/StringBase.hpp +++ b/Fw/Types/StringBase.hpp @@ -24,7 +24,7 @@ namespace Fw { class StringBase : public Serializable { public: - using SizeType = NATIVE_UINT_TYPE; + using SizeType = FwSizeType; virtual const CHAR* toChar() const = 0; // -/** - * Default implementation for deprecated (see note) - */ -#ifndef PLATFORM_INT_TYPE_DEFINED -typedef int PlatformIntType; -extern const PlatformIntType PlatformIntType_MIN; -extern const PlatformIntType PlatformIntType_MAX; -#define PLATFORM_INT_TYPE_DEFINED -#define PRI_PlatformIntType "d" -#endif - -/** - * Default implementation for deprecated (see note) - */ -#ifndef PLATFORM_UINT_TYPE_DEFINED -typedef unsigned int PlatformUIntType; -extern const PlatformUIntType PlatformUIntType_MIN; -extern const PlatformUIntType PlatformUIntType_MAX; -#define PLATFORM_UINT_TYPE_DEFINED -#define PRI_PlatformUIntType "ud" -#endif - -/** - * Default implementation for ports indices - */ -#ifndef PLATFORM_INDEX_TYPE_DEFINED -typedef PlatformIntType PlatformIndexType; -extern const PlatformIndexType PlatformIndexType_MIN; -extern const PlatformIndexType PlatformIndexType_MAX; -#define PLATFORM_INDEX_TYPE_DEFINED -#define PRI_PlatformIndexType PRI_PlatformIntType -#endif - -/** - * Default implementation for sizes - */ -#ifndef PLATFORM_SIZE_TYPE_DEFINED -typedef PlatformUIntType PlatformSizeType; -extern const PlatformSizeType PlatformSizeType_MIN; -extern const PlatformSizeType PlatformSizeType_MAX; -#define PLATFORM_SIZE_TYPE_DEFINED -#define PRI_PlatformSizeType PRI_PlatformUIntType -#endif - -/** - * Default implementation for argument to fw_assert - */ -#ifndef PLATFORM_ASSERT_ARG_TYPE_DEFINED -typedef PlatformIntType PlatformAssertArgType; -extern const PlatformAssertArgType PlatformAssertArgType_MIN; -extern const PlatformAssertArgType PlatformAssertArgType_MAX; -#define PLATFORM_ASSERT_ARG_TYPE_DEFINED -#define PRI_PlatformAssertArgType PRI_PlatformIntType -#endif - -/** - * Default implementation for pointers stored as integers - */ -#ifndef PLATFORM_POINTER_CAST_TYPE_DEFINED -// Check for __SIZEOF_POINTER__ or cause error -#ifndef __SIZEOF_POINTER__ -#error "Compiler does not support __SIZEOF_POINTER__, cannot use default for PlatformPointerCastType" -#endif - -// Pointer sizes are determined by size of compiler -#if __SIZEOF_POINTER__ == 8 -typedef uint64_t PlatformPointerCastType; -extern const PlatformPointerCastType PlatformPointerCastType_MIN; -extern const PlatformPointerCastType PlatformPointerCastType_MAX; -#define PRI_PlatformPointerCastType PRIx64 -#elif __SIZEOF_POINTER__ == 4 -typedef uint32_t PlatformPointerCastType; -extern const PlatformPointerCastType PlatformPointerCastType_MIN; -extern const PlatformPointerCastType PlatformPointerCastType_MAX; -#define PRI_PlatformPointerCastType PRIx32 -#elif __SIZEOF_POINTER__ == 2 -typedef uint16_t PlatformPointerCastType; -extern const PlatformPointerCastType PlatformPointerCastType_MIN; -extern const PlatformPointerCastType PlatformPointerCastType_MAX; -#define PRI_PlatformPointerCastType PRIx16 -#else -typedef uint8_t PlatformPointerCastType; -extern const PlatformPointerCastType PlatformPointerCastType_MIN; -extern const PlatformPointerCastType PlatformPointerCastType_MAX; -#define PRI_PlatformPointerCastType PRIx8 -#endif -#define PLATFORM_POINTER_CAST_TYPE_DEFINED -#endif diff --git a/Fw/Types/test/ut/TypesTest.cpp b/Fw/Types/test/ut/TypesTest.cpp index e34639fb171..b0c568d0e37 100644 --- a/Fw/Types/test/ut/TypesTest.cpp +++ b/Fw/Types/test/ut/TypesTest.cpp @@ -29,7 +29,7 @@ class SerializeTestBuffer : public Fw::SerializeBufferBase { public: - NATIVE_UINT_TYPE getBuffCapacity() const { // !< returns capacity, not current size, of buffer + FwSizeType getBuffCapacity() const { // !< returns capacity, not current size, of buffer return sizeof(m_testBuff); } @@ -742,8 +742,8 @@ void AssertTest() { TestAssertHook() {} virtual ~TestAssertHook() {} void reportAssert(FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -765,9 +765,9 @@ void AssertTest() { FILE_NAME_ARG getFile() { return this->m_file; } - NATIVE_UINT_TYPE getLineNo() { return this->m_lineNo; } + FwSizeType getLineNo() { return this->m_lineNo; } - NATIVE_UINT_TYPE getNumArgs() { return this->m_numArgs; } + FwSizeType getNumArgs() { return this->m_numArgs; } FwAssertArgType getArg1() { return this->m_arg1; } @@ -793,8 +793,8 @@ void AssertTest() { #else FILE_NAME_ARG m_file = nullptr; #endif - NATIVE_UINT_TYPE m_lineNo = 0; - NATIVE_UINT_TYPE m_numArgs = 0; + FwSizeType m_lineNo = 0; + FwSizeType m_numArgs = 0; FwAssertArgType m_arg1 = 0; FwAssertArgType m_arg2 = 0; FwAssertArgType m_arg3 = 0; @@ -1202,12 +1202,12 @@ TEST(PerformanceTest, F64SerPerfTest) { F64 in = 10000.0; F64 out = 0; - NATIVE_INT_TYPE iters = 1000000; + FwSizeType iters = 1000000; Os::IntervalTimer timer; timer.start(); - for (NATIVE_INT_TYPE iter = 0; iter < iters; iter++) { + for (FwSizeType iter = 0; iter < iters; iter++) { buff.resetSer(); buff.serialize(in); buff.deserialize(out); @@ -1215,7 +1215,7 @@ TEST(PerformanceTest, F64SerPerfTest) { timer.stop(); - printf("%d iterations took %d us (%f us each).\n", iters, timer.getDiffUsec(), + printf("%" PRI_FwSizeType " iterations took %d us (%f us each).\n", iters, timer.getDiffUsec(), static_cast(timer.getDiffUsec()) / static_cast(iters)); } @@ -1223,7 +1223,7 @@ TEST(AllocatorTest, MallocAllocatorTest) { // Since it is a wrapper around malloc, the test consists of requesting // memory and verifying a non-zero pointer, unchanged size, and not recoverable. Fw::MallocAllocator allocator; - NATIVE_UINT_TYPE size = 100; // one hundred bytes + FwSizeType size = 100; // one hundred bytes bool recoverable; void* ptr = allocator.allocate(10, size, recoverable); ASSERT_EQ(100, size); diff --git a/Os/ValidateFileCommon.cpp b/Os/ValidateFileCommon.cpp index 673a1b3c430..429349499b0 100644 --- a/Os/ValidateFileCommon.cpp +++ b/Os/ValidateFileCommon.cpp @@ -20,11 +20,10 @@ namespace Os { FileSystem::Status fs_status; FwSignedSizeType fileSize = 0; fs_status = FileSystem::getFileSize(fileName, fileSize); //!< gets the size of the file (in bytes) at location path - // fileSize will be used as a NATIVE_INT_TYPE below and thus must cast cleanly to that type if( FileSystem::OP_OK != fs_status) { return File::BAD_SIZE; } - const NATIVE_INT_TYPE max_itr = static_cast(fileSize/VFILE_HASH_CHUNK_SIZE + 1); + const FwSignedSizeType max_itr = (fileSize/VFILE_HASH_CHUNK_SIZE + 1); // Read all data from file and update hash: Utils::Hash hash; @@ -44,7 +43,7 @@ namespace Os { break; } // Add chunk to hash calculation: - hash.update(&buffer, static_cast(size)); + hash.update(&buffer, static_cast(size)); cnt++; } file.close(); @@ -74,18 +73,18 @@ namespace Os { // Read hash from checksum file: unsigned char savedHash[HASH_DIGEST_LENGTH]; - FwSignedSizeType size = hashBuffer.getBuffCapacity(); + FwSignedSizeType size = static_cast(hashBuffer.getBuffCapacity()); status = hashFile.read(savedHash, size); if( File::OP_OK != status ) { return status; } - if( size != static_cast(hashBuffer.getBuffCapacity()) ) { + if(static_cast(size) != hashBuffer.getBuffCapacity()) { return File::BAD_SIZE; } hashFile.close(); // Return the hash buffer: - Utils::HashBuffer savedHashBuffer(savedHash, static_cast(size)); + Utils::HashBuffer savedHashBuffer(savedHash, static_cast(size)); hashBuffer = savedHashBuffer; return status; @@ -101,12 +100,12 @@ namespace Os { } // Write out the hash - FwSignedSizeType size = hashBuffer.getBuffLength(); + FwSignedSizeType size = static_cast(hashBuffer.getBuffLength()); status = hashFile.write(hashBuffer.getBuffAddr(), size, Os::File::WaitType::NO_WAIT); if( File::OP_OK != status ) { return status; } - if( size != static_cast(hashBuffer.getBuffLength()) ) { + if(static_cast(size) != hashBuffer.getBuffLength()) { return File::BAD_SIZE; } hashFile.close(); diff --git a/Os/test/ut/OsValidateFileTest.cpp b/Os/test/ut/OsValidateFileTest.cpp index adf41d502e6..7b11643610e 100644 --- a/Os/test/ut/OsValidateFileTest.cpp +++ b/Os/test/ut/OsValidateFileTest.cpp @@ -57,7 +57,7 @@ void testValidateFile(const char* fileName) { return; } Utils::HashBuffer buf; - EXPECT_TRUE(fileSize == buf.getBuffCapacity()); + EXPECT_TRUE(static_cast(fileSize) == buf.getBuffCapacity()); // Validate file: printf("Validating file %s against hash file %s\n", fileName, hashFileName); diff --git a/Ref/RecvBuffApp/RecvBuffComponentImpl.cpp b/Ref/RecvBuffApp/RecvBuffComponentImpl.cpp index ef007585f81..1c45d216414 100644 --- a/Ref/RecvBuffApp/RecvBuffComponentImpl.cpp +++ b/Ref/RecvBuffApp/RecvBuffComponentImpl.cpp @@ -34,7 +34,7 @@ namespace Ref { FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast(stat)); // deserialize data U8 testData[24] = {0}; - NATIVE_UINT_TYPE size = sizeof(testData); + FwSizeType size = sizeof(testData); stat = buff.deserialize(testData,size); FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast(stat)); // deserialize checksum diff --git a/Svc/ActiveTextLogger/LogFile.cpp b/Svc/ActiveTextLogger/LogFile.cpp index 4045f3ea03d..94220a1f0c4 100644 --- a/Svc/ActiveTextLogger/LogFile.cpp +++ b/Svc/ActiveTextLogger/LogFile.cpp @@ -37,7 +37,7 @@ namespace Svc { // Member Functions // ---------------------------------------------------------------------- - bool LogFile::write_to_log(const char *const buf, const U32 size) + bool LogFile::write_to_log(const char *const buf, const FwSizeType size) { FW_ASSERT(buf != nullptr); @@ -50,9 +50,9 @@ namespace Svc { // Make sure we won't exceed the maximum size: // Note: second condition in if statement is true if there is overflow // in the addition below - U32 projectedSize = this->m_currentFileSize + size; + FwSizeType projectedSize = this->m_currentFileSize + size; if ( projectedSize > this->m_maxFileSize || - (this->m_currentFileSize > (std::numeric_limits::max() - size)) ) { + (this->m_currentFileSize > (std::numeric_limits::max() - size)) ) { status = false; this->m_openFile = false; @@ -61,16 +61,16 @@ namespace Svc { // Won't exceed max size, so write to file: else { - FwSignedSizeType writeSize = size; + FwSignedSizeType writeSize = static_cast(size); Os::File::Status stat = this->m_file.write(reinterpret_cast(buf),writeSize,Os::File::WAIT); // Assert that we are not trying to write to a file we never opened: FW_ASSERT(stat != Os::File::NOT_OPENED); // Only return a good status if the write was valid - status = (writeSize > 0); + status = (stat == Os::File::OP_OK) && (static_cast(writeSize) == size); - this->m_currentFileSize += static_cast(writeSize); + this->m_currentFileSize += static_cast(writeSize); } } @@ -78,7 +78,7 @@ namespace Svc { } - bool LogFile::set_log_file(const char* fileName, const U32 maxSize, const U32 maxBackups) + bool LogFile::set_log_file(const char* fileName, const FwSizeType maxSize, const FwSizeType maxBackups) { FW_ASSERT(fileName != nullptr); diff --git a/Svc/ActiveTextLogger/LogFile.hpp b/Svc/ActiveTextLogger/LogFile.hpp index 1aa431bf679..4f09743c3c5 100644 --- a/Svc/ActiveTextLogger/LogFile.hpp +++ b/Svc/ActiveTextLogger/LogFile.hpp @@ -40,7 +40,7 @@ namespace Svc { //! \param maxBackups The max backups for the file. Default: 10 //! //! \return true if creating the file was successful, false otherwise - bool set_log_file(const char* fileName, const U32 maxSize, const U32 maxBackups = 10); + bool set_log_file(const char* fileName, const FwSizeType maxSize, const FwSizeType maxBackups = 10); //! \brief Write the passed buf to the log if possible //! @@ -48,7 +48,7 @@ namespace Svc { //! \param size The size of buf //! //! \return true if writing to the file was successful, false otherwise - bool write_to_log(const char *const buf, const U32 size); + bool write_to_log(const char *const buf, const FwSizeType size); // ---------------------------------------------------------------------- // Member Variables @@ -61,13 +61,13 @@ namespace Svc { Os::File m_file; // The max size of the text log file: - U32 m_maxFileSize; + FwSizeType m_maxFileSize; // True if there is currently an open file to write text logs to: bool m_openFile; // Current size of the file: - U32 m_currentFileSize; + FwSizeType m_currentFileSize; }; } diff --git a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp index 6618d9c2f90..d974bfbe15e 100644 --- a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp +++ b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp @@ -22,8 +22,8 @@ namespace Fw { void defaultReportAssert ( FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -31,7 +31,7 @@ namespace Fw { FwAssertArgType arg5, FwAssertArgType arg6, CHAR* destBuffer, - NATIVE_INT_TYPE buffSize + FwSizeType buffSize ); } @@ -62,8 +62,8 @@ namespace Svc { void AssertFatalAdapterComponentImpl::AssertFatalAdapter::reportAssert( FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -98,8 +98,8 @@ namespace Svc { void AssertFatalAdapterComponentImpl::reportAssert( FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -117,7 +117,7 @@ namespace Svc { #endif CHAR msg[Fw::StringBase::BUFFER_SIZE(FW_ASSERT_TEXT_SIZE)] = {0}; - Fw::defaultReportAssert(file,lineNo,numArgs,arg1,arg2,arg3,arg4,arg5,arg6,msg,sizeof(msg)); + Fw::defaultReportAssert(file,static_cast(lineNo),numArgs,arg1,arg2,arg3,arg4,arg5,arg6,msg,sizeof(msg)); Fw::Logger::log("%s\n", msg); // Handle the case where the ports aren't connected yet @@ -130,25 +130,25 @@ namespace Svc { case 0: this->log_FATAL_AF_ASSERT_0( fileArg, - lineNo); + static_cast(lineNo)); break; case 1: this->log_FATAL_AF_ASSERT_1( fileArg, - lineNo, + static_cast(lineNo), static_cast(arg1)); break; case 2: this->log_FATAL_AF_ASSERT_2( fileArg, - lineNo, + static_cast(lineNo), static_cast(arg1), static_cast(arg2)); break; case 3: this->log_FATAL_AF_ASSERT_3( fileArg, - lineNo, + static_cast(lineNo), static_cast(arg1), static_cast(arg2), static_cast(arg3)); @@ -156,7 +156,7 @@ namespace Svc { case 4: this->log_FATAL_AF_ASSERT_4( fileArg, - lineNo, + static_cast(lineNo), static_cast(arg1), static_cast(arg2), static_cast(arg3), @@ -165,7 +165,7 @@ namespace Svc { case 5: this->log_FATAL_AF_ASSERT_5( fileArg, - lineNo, + static_cast(lineNo), static_cast(arg1), static_cast(arg2), static_cast(arg3), @@ -175,7 +175,7 @@ namespace Svc { case 6: this->log_FATAL_AF_ASSERT_6( fileArg, - lineNo, + static_cast(lineNo), static_cast(arg1), static_cast(arg2), static_cast(arg3), @@ -184,7 +184,7 @@ namespace Svc { static_cast(arg6)); break; default: - this->log_FATAL_AF_UNEXPECTED_ASSERT(fileArg,lineNo,numArgs); + this->log_FATAL_AF_UNEXPECTED_ASSERT(fileArg,static_cast(lineNo),static_cast(numArgs)); break; } diff --git a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.hpp b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.hpp index c96a585add2..ade822f1f36 100644 --- a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.hpp +++ b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.hpp @@ -40,8 +40,8 @@ namespace Svc { //! Report the assert as a FATAL void reportAssert( FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, @@ -60,8 +60,8 @@ namespace Svc { private: void reportAssert( FILE_NAME_ARG file, - NATIVE_UINT_TYPE lineNo, - NATIVE_UINT_TYPE numArgs, + FwSizeType lineNo, + FwSizeType numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, diff --git a/Svc/BufferAccumulator/BufferAccumulator.cpp b/Svc/BufferAccumulator/BufferAccumulator.cpp index aed2f3a52e9..c977a6b9793 100644 --- a/Svc/BufferAccumulator/BufferAccumulator.cpp +++ b/Svc/BufferAccumulator/BufferAccumulator.cpp @@ -15,7 +15,7 @@ #include #include "Fw/Types/BasicTypes.hpp" - +#include namespace Svc { @@ -46,21 +46,25 @@ BufferAccumulator ::~BufferAccumulator() {} // ---------------------------------------------------------------------- void BufferAccumulator ::allocateQueue( - NATIVE_INT_TYPE identifier, Fw::MemAllocator& allocator, + FwEnumStoreType identifier, Fw::MemAllocator& allocator, NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers ) { this->m_allocatorId = identifier; - NATIVE_UINT_TYPE memSize = static_cast(sizeof(Fw::Buffer) * maxNumBuffers); + // Overflow protection + FW_ASSERT( + (std::numeric_limits::max() / maxNumBuffers) >= sizeof(Fw::Buffer) + ); + FwSizeType memSize = static_cast(sizeof(Fw::Buffer) * maxNumBuffers); bool recoverable = false; this->m_bufferMemory = static_cast( - allocator.allocate(static_cast(identifier), memSize, recoverable)); + allocator.allocate(identifier, memSize, recoverable)); //TODO: Fail gracefully here m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers); } void BufferAccumulator ::deallocateQueue(Fw::MemAllocator& allocator) { - allocator.deallocate(static_cast(this->m_allocatorId), this->m_bufferMemory); + allocator.deallocate(static_cast(this->m_allocatorId), this->m_bufferMemory); } // ---------------------------------------------------------------------- diff --git a/Svc/BufferAccumulator/BufferAccumulator.hpp b/Svc/BufferAccumulator/BufferAccumulator.hpp index 83169f958bc..367c964f457 100644 --- a/Svc/BufferAccumulator/BufferAccumulator.hpp +++ b/Svc/BufferAccumulator/BufferAccumulator.hpp @@ -103,7 +103,7 @@ namespace Svc { //! Give the class a memory buffer. Should be called after constructor //! and init, but before task is spawned. void allocateQueue( - NATIVE_INT_TYPE identifier, Fw::MemAllocator& allocator, + FwEnumStoreType identifier, Fw::MemAllocator& allocator, NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers ); @@ -204,7 +204,7 @@ namespace Svc { U32 m_cmdSeq; //! The allocator ID - NATIVE_INT_TYPE m_allocatorId; + FwEnumStoreType m_allocatorId; }; } // namespace Svc diff --git a/Svc/BufferLogger/BufferLogger.cpp b/Svc/BufferLogger/BufferLogger.cpp index 4da04fafa8e..5d32e3379ba 100644 --- a/Svc/BufferLogger/BufferLogger.cpp +++ b/Svc/BufferLogger/BufferLogger.cpp @@ -37,7 +37,7 @@ namespace Svc { initLog( const char *const logFilePrefix, const char *const logFileSuffix, - const U32 maxFileSize, + const FwSizeType maxFileSize, const U8 sizeOfSize ) { @@ -56,7 +56,7 @@ namespace Svc { { if (m_state == LogState::LOGGING_ON) { const U8 *const addr = fwBuffer.getData(); - const U32 size = fwBuffer.getSize(); + const FwSizeType size = fwBuffer.getSize(); m_file.logBuffer(addr, size); } this->bufferSendOut_out(0, fwBuffer); @@ -71,7 +71,7 @@ namespace Svc { { if (m_state == LogState::LOGGING_ON) { const U8 *const addr = data.getBuffAddr(); - const U32 size = data.getBuffLength(); + const FwSizeType size = data.getBuffLength(); m_file.logBuffer(addr, size); } } diff --git a/Svc/BufferLogger/BufferLogger.hpp b/Svc/BufferLogger/BufferLogger.hpp index 043ef00a21b..b9d9d7cfd75 100644 --- a/Svc/BufferLogger/BufferLogger.hpp +++ b/Svc/BufferLogger/BufferLogger.hpp @@ -61,7 +61,7 @@ namespace Svc { void init( const char *const prefix, //!< The file name prefix const char *const suffix, //!< The file name suffix - const U32 maxSize, //!< The maximum file size + const FwSizeType maxSize, //!< The maximum file size const U8 sizeOfSize //!< The number of bytes to use when storing the size field and the start of each buffer) ); @@ -73,7 +73,7 @@ namespace Svc { //! Log a buffer void logBuffer( const U8 *const data, //!< The buffer data - const U32 size //!< The size + const FwSizeType size //!< The size ); //! Close the file and emit an event @@ -91,20 +91,20 @@ namespace Svc { //! \return Success or failure bool writeBuffer( const U8 *const data, //!< The buffer data - const U32 size //!< The number of bytes to write + const FwSizeType size //!< The number of bytes to write ); //! Write the size field of a buffer //! \return Success or failure bool writeSize( - const U32 size //!< The size + const FwSizeType size //!< The size ); //! Write bytes to a file //! \return Success or failure bool writeBytes( const void *const data, //!< The data - const U32 length //!< The number of bytes to write + const FwSizeType length //!< The number of bytes to write ); //! Write a hash file @@ -131,7 +131,7 @@ namespace Svc { NATIVE_UINT_TYPE m_fileCounter; //! The maximum file size - U32 m_maxSize; + FwSizeType m_maxSize; //! The number of bytes to use when storing the size field at the start of each buffer U8 m_sizeOfSize; @@ -146,7 +146,7 @@ namespace Svc { Os::File m_osFile; //! The number of bytes written to the current file - U32 m_bytesWritten; + FwSizeType m_bytesWritten; }; // class File @@ -170,7 +170,7 @@ namespace Svc { void initLog( const char *const logFilePrefix, //!< The log file name prefix const char *const logFileSuffix, //!< The log file name suffix - const U32 maxFileSize, //!< The maximum file size + const FwSizeType maxFileSize, //!< The maximum file size const U8 sizeOfSize //!< The number of bytes to use when storing the size field at the start of each buffer ); diff --git a/Svc/BufferLogger/BufferLoggerFile.cpp b/Svc/BufferLogger/BufferLoggerFile.cpp index 6d3268c735e..4dbef4118e0 100644 --- a/Svc/BufferLogger/BufferLoggerFile.cpp +++ b/Svc/BufferLogger/BufferLoggerFile.cpp @@ -50,7 +50,7 @@ namespace Svc { init( const char *const logFilePrefix, const char *const logFileSuffix, - const U32 maxFileSize, + const FwSizeType maxFileSize, const U8 sizeOfSize ) { @@ -62,7 +62,7 @@ namespace Svc { this->m_maxSize = maxFileSize; this->m_sizeOfSize = sizeOfSize; - FW_ASSERT(sizeOfSize <= sizeof(U32), sizeOfSize); + FW_ASSERT(sizeOfSize <= sizeof(FwSizeType), sizeOfSize); FW_ASSERT(m_maxSize > sizeOfSize, static_cast(m_maxSize)); } @@ -82,12 +82,12 @@ namespace Svc { void BufferLogger::File :: logBuffer( const U8 *const data, - const U32 size + const FwSizeType size ) { // Close the file if it will be too big if (this->m_mode == File::Mode::OPEN) { - const U32 projectedByteCount = + const FwSizeType projectedByteCount = this->m_bytesWritten + this->m_sizeOfSize + size; if (projectedByteCount > this->m_maxSize) { this->closeAndEmitEvent(); @@ -124,7 +124,7 @@ namespace Svc { // NOTE(mereweth) - check that file path has been set and that initLog has been called if ((this->m_baseName.toChar()[0] == '\0') || - (this->m_sizeOfSize > sizeof(U32)) || + (this->m_sizeOfSize > sizeof(FwSizeType)) || (this->m_maxSize <= this->m_sizeOfSize)) { this->m_bufferLogger.log_WARNING_HI_BL_NoLogFileOpenInitError(); return; @@ -168,7 +168,7 @@ namespace Svc { bool BufferLogger::File :: writeBuffer( const U8 *const data, - const U32 size + const FwSizeType size ) { bool status = this->writeSize(size); @@ -179,11 +179,11 @@ namespace Svc { } bool BufferLogger::File :: - writeSize(const U32 size) + writeSize(const FwSizeType size) { - FW_ASSERT(this->m_sizeOfSize <= sizeof(U32)); - U8 sizeBuffer[sizeof(U32)]; - U32 sizeRegister = size; + FW_ASSERT(this->m_sizeOfSize <= sizeof(FwSizeType)); + U8 sizeBuffer[sizeof(FwSizeType)]; + FwSizeType sizeRegister = size; for (U8 i = 0; i < this->m_sizeOfSize; ++i) { sizeBuffer[this->m_sizeOfSize - i - 1] = sizeRegister & 0xFF; sizeRegister >>= 8; @@ -198,11 +198,11 @@ namespace Svc { bool BufferLogger::File :: writeBytes( const void *const data, - const U32 length + const FwSizeType length ) { - FW_ASSERT(length > 0, static_cast(length)); - FwSignedSizeType size = length; + FW_ASSERT((length > 0) and (length <= std::numeric_limits::max()), static_cast(length)); + FwSignedSizeType size = static_cast(length); const Os::File::Status fileStatus = this->m_osFile.write(reinterpret_cast(data), size); bool status; if (fileStatus == Os::File::OP_OK && size == static_cast(length)) { @@ -212,7 +212,7 @@ namespace Svc { else { Fw::LogStringArg string(this->m_name.toChar()); - this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, static_cast(size), length, string); + this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, static_cast(size), static_cast(length), string); status = false; } return status; diff --git a/Svc/BufferManager/BufferManagerComponentImpl.cpp b/Svc/BufferManager/BufferManagerComponentImpl.cpp index b7d41e14cfa..159be56eaf9 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.cpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.cpp @@ -160,7 +160,7 @@ namespace Svc { void BufferManagerComponentImpl::setup( NATIVE_UINT_TYPE mgrId, //!< manager ID - NATIVE_UINT_TYPE memId, //!< Memory segment identifier + FwEnumStoreType memId, //!< Memory segment identifier Fw::MemAllocator& allocator, //!< memory allocator const BufferBins& bins //!< Set of user bins ) { @@ -186,7 +186,7 @@ namespace Svc { } } - NATIVE_UINT_TYPE allocatedSize = memorySize; + FwSizeType allocatedSize = memorySize; bool recoverable = false; //!< don't care if it is recoverable since they are a pool of user buffers // allocate memory diff --git a/Svc/BufferManager/BufferManagerComponentImpl.hpp b/Svc/BufferManager/BufferManagerComponentImpl.hpp index 50d55ecddeb..c9f54ceb69b 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.hpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.hpp @@ -85,7 +85,7 @@ namespace Svc void setup( NATIVE_UINT_TYPE mgrID, //!< ID of manager for buffer checking - NATIVE_UINT_TYPE memID, //!< Memory segment identifier + FwEnumStoreType memID, //!< Memory segment identifier Fw::MemAllocator &allocator, //!< memory allocator. MUST be persistent for later deallocation. //! MUST persist past destructor if cleanup() not called explicitly. const BufferBins &bins //!< Set of user bins @@ -141,7 +141,7 @@ namespace Svc AllocatedBuffer *m_buffers; //!< pointer to allocated buffer space Fw::MemAllocator *m_allocator; //!< allocator for memory - NATIVE_UINT_TYPE m_memId; //!< identifier for allocator + FwEnumStoreType m_memId; //!< identifier for allocator NATIVE_UINT_TYPE m_numStructs; //!< number of allocated structs // stats diff --git a/Svc/BufferManager/test/ut/BufferManagerTester.cpp b/Svc/BufferManager/test/ut/BufferManagerTester.cpp index 223d8fb7c41..62a8991e926 100644 --- a/Svc/BufferManager/test/ut/BufferManagerTester.cpp +++ b/Svc/BufferManager/test/ut/BufferManagerTester.cpp @@ -44,8 +44,8 @@ class TestAllocator: public Fw::MemAllocator { * \return the pointer to memory. Zero if unable to allocate. */ void *allocate( - const NATIVE_UINT_TYPE identifier, - NATIVE_UINT_TYPE &size, + const FwEnumStoreType identifier, + FwSizeType &size, bool& recoverable) { this->m_reqId = identifier; this->m_reqSize = size; @@ -58,7 +58,7 @@ class TestAllocator: public Fw::MemAllocator { * \ptr the pointer to memory returned by allocate() */ void deallocate( - const NATIVE_UINT_TYPE identifier, + const FwEnumStoreType identifier, void* ptr) { this->m_alloc.deallocate(identifier,ptr); } @@ -77,8 +77,8 @@ class TestAllocator: public Fw::MemAllocator { private: Fw::MallocAllocator m_alloc; - NATIVE_UINT_TYPE m_reqId; - NATIVE_UINT_TYPE m_reqSize; + FwEnumStoreType m_reqId; + FwSizeType m_reqSize; void* m_mem; }; diff --git a/Svc/CmdSequencer/CmdSequencerImpl.cpp b/Svc/CmdSequencer/CmdSequencerImpl.cpp index 8f3660c03fa..b955f828fb0 100644 --- a/Svc/CmdSequencer/CmdSequencerImpl.cpp +++ b/Svc/CmdSequencer/CmdSequencerImpl.cpp @@ -56,9 +56,9 @@ namespace Svc { void CmdSequencerComponentImpl :: allocateBuffer( - const NATIVE_INT_TYPE identifier, + const FwEnumStoreType identifier, Fw::MemAllocator& allocator, - const NATIVE_UINT_TYPE bytes + const FwSizeType bytes ) { this->m_sequence->allocateBuffer(identifier, allocator, bytes); diff --git a/Svc/CmdSequencer/CmdSequencerImpl.hpp b/Svc/CmdSequencer/CmdSequencerImpl.hpp index 304b57f06cd..a38c02d6b05 100644 --- a/Svc/CmdSequencer/CmdSequencerImpl.hpp +++ b/Svc/CmdSequencer/CmdSequencerImpl.hpp @@ -217,9 +217,9 @@ namespace Svc { //! Give the sequence representation a memory buffer void allocateBuffer( - NATIVE_INT_TYPE identifier, //!< The identifier + FwEnumStoreType identifier, //!< The identifier Fw::MemAllocator& allocator, //!< The allocator - NATIVE_UINT_TYPE bytes //!< The number of bytes + FwSizeType bytes //!< The number of bytes ); //! Deallocate the buffer @@ -291,7 +291,7 @@ namespace Svc { Fw::ExternalSerializeBuffer m_buffer; //! The allocator ID - NATIVE_INT_TYPE m_allocatorId; + FwEnumStoreType m_allocatorId; //! The sequence header Header m_header; @@ -325,7 +325,7 @@ namespace Svc { //! Update computed CRC void update( const BYTE* buffer, //!< The buffer - NATIVE_UINT_TYPE bufferSize //!< The buffer size + FwSizeType bufferSize //!< The buffer size ); //! Finalize computed CRC @@ -544,9 +544,9 @@ namespace Svc { //! Call this after constructor and init, and after setting //! the sequence format, but before task is spawned. void allocateBuffer( - const NATIVE_INT_TYPE identifier, //!< The identifier + const FwEnumStoreType identifier, //!< The identifier Fw::MemAllocator& allocator, //!< The allocator - const NATIVE_UINT_TYPE bytes //!< The number of bytes + const FwSizeType bytes //!< The number of bytes ); //! (Optional) Load a sequence to run later. diff --git a/Svc/CmdSequencer/FPrimeSequence.cpp b/Svc/CmdSequencer/FPrimeSequence.cpp index a24c343be6c..c5043cfb01d 100644 --- a/Svc/CmdSequencer/FPrimeSequence.cpp +++ b/Svc/CmdSequencer/FPrimeSequence.cpp @@ -31,10 +31,10 @@ namespace Svc { } void CmdSequencerComponentImpl::FPrimeSequence::CRC :: - update(const BYTE* buffer, NATIVE_UINT_TYPE bufferSize) + update(const BYTE* buffer, FwSizeType bufferSize) { FW_ASSERT(buffer); - for(NATIVE_UINT_TYPE index = 0; index < bufferSize; index++) { + for(FwSizeType index = 0; index < bufferSize; index++) { this->m_computed = static_cast(update_crc_32(this->m_computed, static_cast(buffer[index]))); } } @@ -148,7 +148,7 @@ namespace Svc { and this->extractCRC(); } if (status) { - const NATIVE_UINT_TYPE buffLen = this->m_buffer.getBuffLength(); + const FwSizeType buffLen = this->m_buffer.getBuffLength(); this->m_crc.update(buffAddr, buffLen); this->m_crc.finalize(); } @@ -166,9 +166,9 @@ namespace Svc { FwSignedSizeType readLen = Sequence::Header::SERIALIZED_SIZE; FW_ASSERT(readLen >= 0, static_cast(readLen)); - const NATIVE_UINT_TYPE capacity = buffer.getBuffCapacity(); + const FwSizeType capacity = buffer.getBuffCapacity(); FW_ASSERT( - capacity >= static_cast(readLen), + capacity >= static_cast(readLen), static_cast(capacity), static_cast(readLen) ); @@ -260,10 +260,10 @@ namespace Svc { readRecordsAndCRC() { Os::File& file = this->m_sequenceFile; - const NATIVE_UINT_TYPE size = this->m_header.m_fileSize; + const FwSizeType size = this->m_header.m_fileSize; Fw::SerializeBufferBase& buffer = this->m_buffer; - FwSignedSizeType readLen = size; + FwSignedSizeType readLen = static_cast(size); Os::File::Status fileStatus = file.read( buffer.getBuffAddr(), readLen @@ -277,7 +277,7 @@ namespace Svc { return false; } // check read size - if (static_cast(size) != readLen) { + if (size != static_cast(readLen)) { this->m_events.fileInvalid( CmdSequencer_FileReadStage::READ_SEQ_DATA_SIZE, static_cast(readLen) @@ -298,8 +298,8 @@ namespace Svc { U32& crc = this->m_crc.m_stored; // Compute the data size - const U32 buffSize = buffer.getBuffLength(); - const U32 crcSize = sizeof(crc); + const FwSizeType buffSize = buffer.getBuffLength(); + const FwSizeType crcSize = sizeof(crc); U8 *const buffAddr = buffer.getBuffAddr(); if (buffSize < crcSize) { this->m_events.fileInvalid( @@ -309,7 +309,7 @@ namespace Svc { return false; } FW_ASSERT(buffSize >= crcSize, static_cast(buffSize), crcSize); - const NATIVE_UINT_TYPE dataSize = buffSize - crcSize; + const FwSizeType dataSize = buffSize - crcSize; // Create a CRC buffer pointing at the CRC in the main buffer, after the data Fw::ExternalSerializeBuffer crcBuff(&buffAddr[dataSize], crcSize); Fw::SerializeStatus status = crcBuff.setBuffLen(crcSize); @@ -409,7 +409,7 @@ namespace Svc { { Fw::SerializeBufferBase& buffer = this->m_buffer; comBuffer.resetSer(); - NATIVE_UINT_TYPE size = recordSize; + FwSizeType size = recordSize; Fw::SerializeStatus status = comBuffer.setBuffLen(recordSize); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); status = buffer.deserialize(comBuffer.getBuffAddr(), size, true); @@ -430,7 +430,7 @@ namespace Svc { } // Deserialize all records - for (NATIVE_UINT_TYPE recordNumber = 0; recordNumber < numRecords; recordNumber++) { + for (U32 recordNumber = 0; recordNumber < numRecords; recordNumber++) { Fw::SerializeStatus status = this->deserializeRecord(record); if (status != Fw::FW_SERIALIZE_OK) { this->m_events.recordInvalid(recordNumber, status); @@ -438,9 +438,9 @@ namespace Svc { } } // Check there is no data left - const U32 buffLeftSize = buffer.getBuffLeft(); + const FwSizeType buffLeftSize = buffer.getBuffLeft(); if (buffLeftSize > 0) { - this->m_events.recordMismatch(numRecords, buffLeftSize); + this->m_events.recordMismatch(numRecords, static_cast(buffLeftSize)); return false; } // Rewind deserialization diff --git a/Svc/CmdSequencer/Sequence.cpp b/Svc/CmdSequencer/Sequence.cpp index 30cc2ccb50f..63f9eeef6e9 100644 --- a/Svc/CmdSequencer/Sequence.cpp +++ b/Svc/CmdSequencer/Sequence.cpp @@ -75,9 +75,9 @@ namespace Svc { void CmdSequencerComponentImpl::Sequence :: allocateBuffer( - NATIVE_INT_TYPE identifier, + FwEnumStoreType identifier, Fw::MemAllocator& allocator, - NATIVE_UINT_TYPE bytes + FwSizeType bytes ) { // has to be at least as big as a header @@ -85,7 +85,7 @@ namespace Svc { bool recoverable; this->m_allocatorId = identifier; this->m_buffer.setExtBuffer( - static_cast(allocator.allocate(static_cast(identifier),bytes,recoverable)), + static_cast(allocator.allocate(identifier,bytes,recoverable)), bytes ); } @@ -94,7 +94,7 @@ namespace Svc { deallocateBuffer(Fw::MemAllocator& allocator) { allocator.deallocate( - static_cast(this->m_allocatorId), + this->m_allocatorId, this->m_buffer.getBuffAddr() ); this->m_buffer.clear(); diff --git a/Svc/CmdSequencer/formats/AMPCSSequence.cpp b/Svc/CmdSequencer/formats/AMPCSSequence.cpp index a8347719ea3..41327b50fbd 100644 --- a/Svc/CmdSequencer/formats/AMPCSSequence.cpp +++ b/Svc/CmdSequencer/formats/AMPCSSequence.cpp @@ -148,7 +148,7 @@ namespace Svc { Sequence::Record record; // Deserialize all records and count the records - const NATIVE_UINT_TYPE loopBound = buffer.getBuffLeft(); + const U32 loopBound = static_cast(buffer.getBuffLeft()); U32 numRecords = 0; for ( ; numRecords < loopBound; ++numRecords) { if (not this->hasMoreRecords()) { @@ -254,7 +254,7 @@ namespace Svc { } if (status) { U8 *const buffAddr = this->m_buffer.getBuffAddr(); - const NATIVE_UINT_TYPE buffLen = this->m_buffer.getBuffLength(); + const FwSizeType buffLen = this->m_buffer.getBuffLength(); FW_ASSERT( buffLen == this->m_header.m_fileSize, static_cast(buffLen), @@ -305,17 +305,17 @@ namespace Svc { readRecords() { Os::File& file = this->m_sequenceFile; - const NATIVE_UINT_TYPE size = this->m_header.m_fileSize; + const FwSizeType size = this->m_header.m_fileSize; Fw::SerializeBufferBase& buffer = this->m_buffer; U8 *const addr = buffer.getBuffAddr(); // Check file size if (size > this->m_buffer.getBuffCapacity()) { - this->m_events.fileSizeError(size); + this->m_events.fileSizeError(static_cast(size)); return false; } - FwSignedSizeType readLen = size; + FwSignedSizeType readLen = static_cast(size); const Os::File::Status fileStatus = file.read(addr, readLen); // Check read status if (fileStatus != Os::File::OP_OK) { @@ -326,7 +326,7 @@ namespace Svc { return false; } // Check read size - const NATIVE_UINT_TYPE readLenUint = static_cast(readLen); + const FwSizeType readLenUint = static_cast(readLen); if (readLenUint != size) { this->m_events.fileInvalid( CmdSequencer_FileReadStage::READ_SEQ_DATA_SIZE, @@ -433,7 +433,7 @@ namespace Svc { status = comBuffer.serialize(zeros); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); // Set the buffer length - const U32 fixedBuffLen = comBuffer.getBuffLength(); + const U32 fixedBuffLen = static_cast(comBuffer.getBuffLength()); FW_ASSERT( fixedBuffLen == sizeof(cmdDescriptor) + sizeof(zeros), static_cast(fixedBuffLen) @@ -442,7 +442,7 @@ namespace Svc { status = comBuffer.setBuffLen(totalBuffLen); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); // Copy the opcode and argument bytes - NATIVE_UINT_TYPE size = cmdLength; + FwSizeType size = cmdLength; U8 *const addr = comBuffer.getBuffAddr(); FW_ASSERT(addr != nullptr); // true means "don't serialize the length" diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp index d077805881b..36971da3dc9 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.cpp @@ -19,7 +19,7 @@ namespace Svc { namespace Buffers { - NATIVE_UINT_TYPE FileBuffer :: + FwSizeType FileBuffer :: getBuffCapacity() const { return sizeof(m_buff); diff --git a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp index bb9a1eaa730..e459b0f2059 100644 --- a/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp +++ b/Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp @@ -33,7 +33,7 @@ namespace Svc { public: - NATIVE_UINT_TYPE getBuffCapacity() const; + FwSizeType getBuffCapacity() const; U8* getBuffAddr(); diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index 6ac54198b8e..3bc2192d035 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -102,11 +102,11 @@ namespace Svc { FW_ASSERT(portNum == 0); // Get length of buffer: - U32 size32 = data.getBuffLength(); + FwSizeType sizeNative = data.getBuffLength(); // ComLogger only writes 16-bit sizes to save space // on disk: - FW_ASSERT(size32 < 65536, static_cast(size32)); - U16 size = size32 & 0xFFFF; + FW_ASSERT(sizeNative < 65536, static_cast(sizeNative)); + U16 size = sizeNative & 0xFFFF; // Close the file if it will be too big: if( OPEN == this->m_fileMode ) { @@ -223,7 +223,7 @@ namespace Svc { serialLength.serialize(size); if(this->writeToFile(serialLength.getBuffAddr(), static_cast(serialLength.getBuffLength()))) { - this->m_byteCount += serialLength.getBuffLength(); + this->m_byteCount += static_cast(serialLength.getBuffLength()); } else { return; diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index cab729cdb7a..3a32e803158 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -24,7 +24,7 @@ ComQueue ::QueueConfigurationTable ::QueueConfigurationTable() { ComQueue ::ComQueue(const char* const compName) : ComQueueComponentBase(compName), m_state(WAITING), - m_allocationId(static_cast(-1)), + m_allocationId(static_cast(-1)), m_allocator(nullptr), m_allocation(nullptr) { // Initialize throttles to "off" @@ -43,10 +43,10 @@ void ComQueue ::cleanup() { } void ComQueue::configure(QueueConfigurationTable queueConfig, - NATIVE_UINT_TYPE allocationId, + FwEnumStoreType allocationId, Fw::MemAllocator& allocator) { FwIndexType currentPriorityIndex = 0; - NATIVE_UINT_TYPE totalAllocation = 0; + FwSizeType totalAllocation = 0; // Store/initialize allocator members this->m_allocator = &allocator; @@ -167,7 +167,7 @@ void ComQueue::run_handler(const FwIndexType portNum, U32 context) { // Downlink the high-water marks for the Fw::ComBuffer array types ComQueueDepth comQueueDepth; for (U32 i = 0; i < comQueueDepth.SIZE; i++) { - comQueueDepth[i] = this->m_queues[i].get_high_water_mark(); + comQueueDepth[i] = static_cast(this->m_queues[i].get_high_water_mark()); this->m_queues[i].clear_high_water_mark(); } this->tlmWrite_comQueueDepth(comQueueDepth); @@ -175,7 +175,7 @@ void ComQueue::run_handler(const FwIndexType portNum, U32 context) { // Downlink the high-water marks for the Fw::Buffer array types BuffQueueDepth buffQueueDepth; for (U32 i = 0; i < buffQueueDepth.SIZE; i++) { - buffQueueDepth[i] = this->m_queues[i + COM_PORT_COUNT].get_high_water_mark(); + buffQueueDepth[i] = static_cast(this->m_queues[i + COM_PORT_COUNT].get_high_water_mark()); this->m_queues[i + COM_PORT_COUNT].clear_high_water_mark(); } this->tlmWrite_buffQueueDepth(buffQueueDepth); diff --git a/Svc/ComQueue/ComQueue.hpp b/Svc/ComQueue/ComQueue.hpp index 8d535c51885..f3703a9161f 100644 --- a/Svc/ComQueue/ComQueue.hpp +++ b/Svc/ComQueue/ComQueue.hpp @@ -111,7 +111,7 @@ class ComQueue : public ComQueueComponentBase { //! Takes in the queue depth and priority per-port in order from Fw::Com through Fw::Buffer ports. Calculates the //! queue metadata stored `m_prioritizedList` and then sorts that list by priority. void configure(QueueConfigurationTable queueConfig, //!< Table of the configuration properties for the component - NATIVE_UINT_TYPE allocationId, //!< Identifier used when dealing with the Fw::MemAllocator + FwEnumStoreType allocationId, //!< Identifier used when dealing with the Fw::MemAllocator Fw::MemAllocator& allocator //!< Fw::MemAllocator used to acquire memory ); @@ -192,7 +192,7 @@ class ComQueue : public ComQueueComponentBase { SendState m_state; //!< State of the component // Storage for Fw::MemAllocator properties - NATIVE_UINT_TYPE m_allocationId; //!< Component's allocation ID + FwEnumStoreType m_allocationId; //!< Component's allocation ID Fw::MemAllocator* m_allocator; //!< Pointer to Fw::MemAllocator instance for deallocation void* m_allocation; //!< Pointer to allocated memory }; diff --git a/Svc/Deframer/Deframer.cpp b/Svc/Deframer/Deframer.cpp index 56b7a187c0d..813d86ca2e5 100644 --- a/Svc/Deframer/Deframer.cpp +++ b/Svc/Deframer/Deframer.cpp @@ -123,7 +123,7 @@ void Deframer ::route(Fw::Buffer& packetBuffer) { // Process the packet if (status == Fw::FW_SERIALIZE_OK) { U8 *const packetData = packetBuffer.getData(); - const U32 packetSize = packetBuffer.getSize(); + const FwSizeType packetSize = packetBuffer.getSize(); switch (packetType) { // Handle a command packet case Fw::ComPacket::FW_PACKET_COMMAND: { @@ -148,6 +148,8 @@ void Deframer ::route(Fw::Buffer& packetBuffer) { // If the file uplink output port is connected, // send the file packet. Otherwise take no action. if (isConnected_bufferOut_OutputPort(0)) { + FW_ASSERT((packetSize - sizeof(packetType)) < std::numeric_limits::max(), + static_cast(packetSize - sizeof(packetType))); // Shift the packet buffer to skip the packet type // The FileUplink component does not expect the packet // type to be there. @@ -185,22 +187,22 @@ void Deframer ::route(Fw::Buffer& packetBuffer) { void Deframer ::processBuffer(Fw::Buffer& buffer) { - const U32 bufferSize = buffer.getSize(); + const FwSizeType bufferSize = buffer.getSize(); U8 *const bufferData = buffer.getData(); // Current offset into buffer - U32 offset = 0; + FwSizeType offset = 0; // Remaining data in buffer - U32 remaining = bufferSize; + FwSizeType remaining = bufferSize; - for (U32 i = 0; i < bufferSize; ++i) { + for (FwSizeType i = 0; i < bufferSize; ++i) { // If there is no data left, exit the loop if (remaining == 0) { break; } // Compute the size of data to serialize - const NATIVE_UINT_TYPE ringFreeSize = m_inRing.get_free_size(); - const NATIVE_UINT_TYPE serSize = (ringFreeSize <= remaining) ? - ringFreeSize : static_cast(remaining); + const FwSizeType ringFreeSize = m_inRing.get_free_size(); + const FwSizeType serSize = (ringFreeSize <= remaining) ? + ringFreeSize : static_cast(remaining); // Serialize data into the ring buffer const Fw::SerializeStatus status = m_inRing.serialize(&bufferData[offset], serSize); @@ -229,15 +231,15 @@ void Deframer ::processRing() { FW_ASSERT(m_protocol != nullptr); // The number of remaining bytes in the ring buffer - U32 remaining = 0; + FwSizeType remaining = 0; // The protocol status DeframingProtocol::DeframingStatus status = DeframingProtocol::DEFRAMING_STATUS_SUCCESS; // The ring buffer capacity - const NATIVE_UINT_TYPE ringCapacity = m_inRing.get_capacity(); + const FwSizeType ringCapacity = m_inRing.get_capacity(); // Process the ring buffer looking for at least the header - for (U32 i = 0; i < ringCapacity; i++) { + for (FwSizeType i = 0; i < ringCapacity; i++) { // Get the number of bytes remaining in the ring buffer remaining = m_inRing.get_allocated_size(); // If there are none, we are done diff --git a/Svc/DpCatalog/DpCatalog.cpp b/Svc/DpCatalog/DpCatalog.cpp index 557df4d01fe..572db44c73e 100644 --- a/Svc/DpCatalog/DpCatalog.cpp +++ b/Svc/DpCatalog/DpCatalog.cpp @@ -55,7 +55,7 @@ namespace Svc { Fw::FileNameString directories[DP_MAX_DIRECTORIES], FwSizeType numDirs, Fw::FileNameString& stateFile, - NATIVE_UINT_TYPE memId, + FwEnumStoreType memId, Fw::MemAllocator& allocator ) { @@ -302,7 +302,10 @@ namespace Svc { // Should always fit FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat,serStat); // write the entry - FwSignedSizeType size = entryBuffer.getBuffLength(); + FwSizeType unsignedSize = entryBuffer.getBuffLength(); + // Protect against overflow + FW_ASSERT(unsignedSize < std::numeric_limits::max(), static_cast(unsignedSize)); + FwSignedSizeType size = static_cast(unsignedSize); stat = stateFile.write(buffer, size); if (stat != Os::File::OP_OK) { this->log_WARNING_HI_StateFileWriteError(this->m_stateFile, stat); @@ -348,7 +351,10 @@ namespace Svc { // should fit FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK,serStat); // write the entry - FwSignedSizeType size = entryBuffer.getBuffLength(); + FwSizeType unsignedSize = entryBuffer.getBuffLength(); + // Protect against overflow + FW_ASSERT(unsignedSize < std::numeric_limits::max(), static_cast(unsignedSize)); + FwSignedSizeType size = static_cast(unsignedSize); stat = stateFile.write(buffer, size); if (stat != Os::File::OP_OK) { this->log_WARNING_HI_StateFileWriteError(this->m_stateFile, stat); diff --git a/Svc/DpCatalog/DpCatalog.hpp b/Svc/DpCatalog/DpCatalog.hpp index 399ff12934c..f98aca0253b 100644 --- a/Svc/DpCatalog/DpCatalog.hpp +++ b/Svc/DpCatalog/DpCatalog.hpp @@ -49,7 +49,7 @@ namespace Svc { Fw::FileNameString directories[DP_MAX_DIRECTORIES], FwSizeType numDirs, Fw::FileNameString& stateFile, - NATIVE_UINT_TYPE memId, + FwEnumStoreType memId, Fw::MemAllocator& allocator ); @@ -240,9 +240,9 @@ namespace Svc { DpDstateFileEntry* m_stateFileData; //!< DP state loaded from file FwSizeType m_stateFileEntries; //!< size of state file data - NATIVE_UINT_TYPE m_memSize; //!< size of allocated buffer + FwSizeType m_memSize; //!< size of allocated buffer void* m_memPtr; //!< stored for shutdown - NATIVE_UINT_TYPE m_allocatorId; //!< stored for shutdown + FwEnumStoreType m_allocatorId; //!< stored for shutdown Fw::MemAllocator* m_allocator; //!< stored for shutdown bool m_xmitInProgress; //!< set if DP files are in the process of being sent diff --git a/Svc/Framer/Framer.cpp b/Svc/Framer/Framer.cpp index 3f06f0170db..c335738fa17 100644 --- a/Svc/Framer/Framer.cpp +++ b/Svc/Framer/Framer.cpp @@ -48,7 +48,8 @@ void Framer ::handle_framing(const U8* const data, const U32 size, Fw::ComPacket // ---------------------------------------------------------------------- void Framer ::comIn_handler(const FwIndexType portNum, Fw::ComBuffer& data, U32 context) { - this->handle_framing(data.getBuffAddr(), data.getBuffLength(), Fw::ComPacket::FW_PACKET_UNKNOWN); + FW_ASSERT(data.getBuffLength() < std::numeric_limits::max(), static_cast(data.getBuffLength())); + this->handle_framing(data.getBuffAddr(), static_cast(data.getBuffLength()), Fw::ComPacket::FW_PACKET_UNKNOWN); } void Framer ::bufferIn_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) { diff --git a/Svc/FramingProtocol/FprimeProtocol.cpp b/Svc/FramingProtocol/FprimeProtocol.cpp index 14f1d5b4be3..11f4bd44602 100644 --- a/Svc/FramingProtocol/FprimeProtocol.cpp +++ b/Svc/FramingProtocol/FprimeProtocol.cpp @@ -50,7 +50,7 @@ void FprimeFraming::frame(const U8* const data, const U32 size, Fw::ComPacket::C FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); // Calculate and add transmission hash - Utils::Hash::hash(buffer.getData(), static_cast(total - HASH_DIGEST_LENGTH), hash); + Utils::Hash::hash(buffer.getData(), static_cast(total - HASH_DIGEST_LENGTH), hash); status = serializer.serialize(hash.getBuffAddr(), HASH_DIGEST_LENGTH, true); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); diff --git a/Svc/GenericHub/GenericHubComponentImpl.cpp b/Svc/GenericHub/GenericHubComponentImpl.cpp index 479eccf635d..0380f10aeed 100644 --- a/Svc/GenericHub/GenericHubComponentImpl.cpp +++ b/Svc/GenericHub/GenericHubComponentImpl.cpp @@ -29,9 +29,9 @@ GenericHubComponentImpl ::GenericHubComponentImpl(const char* const compName) : GenericHubComponentImpl ::~GenericHubComponentImpl() {} void GenericHubComponentImpl ::send_data(const HubType type, - const NATIVE_INT_TYPE port, + const FwIndexType port, const U8* data, - const U32 size) { + const FwSizeType size) { FW_ASSERT(data != nullptr); Fw::SerializeStatus status; // Buffer to send and a buffer used to write to it @@ -44,7 +44,7 @@ void GenericHubComponentImpl ::send_data(const HubType type, FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); status = serialize.serialize(data, size); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); - outgoing.setSize(serialize.getBuffLength()); + outgoing.setSize(static_cast(serialize.getBuffLength())); dataOut_out(0, outgoing); } @@ -155,7 +155,7 @@ void GenericHubComponentImpl ::LogRecv_handler(const FwIndexType portNum, FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); status = serializer.serialize(args); FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); - U32 size = serializer.getBuffLength(); + FwSizeType size = serializer.getBuffLength(); this->send_data(HubType::HUB_TYPE_EVENT, portNum, buffer, size); } @@ -174,7 +174,7 @@ void GenericHubComponentImpl ::TlmRecv_handler(const FwIndexType portNum, FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); status = serializer.serialize(val); FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK); - U32 size = serializer.getBuffLength(); + FwSizeType size = serializer.getBuffLength(); this->send_data(HubType::HUB_TYPE_CHANNEL, portNum, buffer, size); } diff --git a/Svc/GenericHub/GenericHubComponentImpl.hpp b/Svc/GenericHub/GenericHubComponentImpl.hpp index 3024c00d3c8..9602e1b5639 100644 --- a/Svc/GenericHub/GenericHubComponentImpl.hpp +++ b/Svc/GenericHub/GenericHubComponentImpl.hpp @@ -32,7 +32,7 @@ class GenericHubComponentImpl : public GenericHubComponentBase { HUB_TYPE_MAX }; - const static U32 GENERIC_HUB_DATA_SIZE = 1024; + constexpr static FwSizeType GENERIC_HUB_DATA_SIZE = 1024; // ---------------------------------------------------------------------- // Construction, initialization, and destruction // ---------------------------------------------------------------------- @@ -89,7 +89,7 @@ class GenericHubComponentImpl : public GenericHubComponentBase { ); // Helpers and members - void send_data(const HubType type, const NATIVE_INT_TYPE port, const U8* data, const U32 size); + void send_data(const HubType type, const FwIndexType port, const U8* data, const FwSizeType size); }; } // end namespace Svc diff --git a/Svc/PrmDb/PrmDbImpl.cpp b/Svc/PrmDb/PrmDbImpl.cpp index d05cacbd713..01041451c81 100644 --- a/Svc/PrmDb/PrmDbImpl.cpp +++ b/Svc/PrmDb/PrmDbImpl.cpp @@ -23,7 +23,7 @@ namespace Svc { class WorkingBuffer : public Fw::SerializeBufferBase { public: - NATIVE_UINT_TYPE getBuffCapacity() const { + FwSizeType getBuffCapacity() const { return sizeof(m_buff); } @@ -173,7 +173,7 @@ namespace Svc { FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat,static_cast(serStat)); // write record size - writeSize = buff.getBuffLength(); + writeSize = static_cast(buff.getBuffLength()); stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); @@ -201,7 +201,7 @@ namespace Svc { FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat,static_cast(serStat)); // write parameter ID - writeSize = buff.getBuffLength(); + writeSize = static_cast(buff.getBuffLength()); stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); @@ -221,7 +221,7 @@ namespace Svc { // write serialized parameter value - writeSize = this->m_db[entry].val.getBuffLength(); + writeSize = static_cast(this->m_db[entry].val.getBuffLength()); stat = paramFile.write(this->m_db[entry].val.getBuffAddr(),writeSize,Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); diff --git a/Utils/CRCChecker.cpp b/Utils/CRCChecker.cpp index 19492656d01..b7010be0681 100644 --- a/Utils/CRCChecker.cpp +++ b/Utils/CRCChecker.cpp @@ -34,7 +34,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, Os::File::Status stat; Utils::Hash hash; U32 checksum; - FwSignedSizeType int_file_size; FwSignedSizeType bytes_to_read; FwSignedSizeType bytes_to_write; Fw::FileNameString hashFilename; @@ -46,8 +45,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, return FAILED_FILE_SIZE; } - int_file_size = filesize; - // Open file stat = f.open(fname, Os::File::OPEN_READ); if(stat != Os::File::OP_OK) @@ -57,7 +54,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, // Read file bytes_to_read = CRC_FILE_READ_BLOCK; - blocks = int_file_size / CRC_FILE_READ_BLOCK; + blocks = filesize / CRC_FILE_READ_BLOCK; for(i = 0; i < blocks; i++) { stat = f.read(block_data, bytes_to_read); @@ -67,10 +64,10 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, return FAILED_FILE_READ; } - hash.update(block_data, static_cast(bytes_to_read)); + hash.update(block_data, static_cast(bytes_to_read)); } - remaining_bytes = int_file_size % CRC_FILE_READ_BLOCK; + remaining_bytes = filesize % CRC_FILE_READ_BLOCK; bytes_to_read = remaining_bytes; if(remaining_bytes > 0) { @@ -81,7 +78,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, return FAILED_FILE_READ; } - hash.update(block_data, static_cast(remaining_bytes)); + hash.update(block_data, static_cast(remaining_bytes)); } // close file @@ -150,7 +147,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, FwSignedSizeType i; FwSignedSizeType blocks; - PlatformIntType remaining_bytes; + FwSignedSizeType remaining_bytes; FwSignedSizeType filesize; Os::File f; Os::FileSystem::Status fs_stat; @@ -158,7 +155,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, Utils::Hash hash; U32 checksum; U32 checksum_from_file; - FwSignedSizeType int_file_size; FwSignedSizeType bytes_to_read; U8 block_data[CRC_FILE_READ_BLOCK]; @@ -168,12 +164,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, return FAILED_FILE_SIZE; } - int_file_size = static_cast(filesize); - if(static_cast(int_file_size) != filesize) - { - return FAILED_FILE_SIZE_CAST; - } - // Open file stat = f.open(fname, Os::File::OPEN_READ); if(stat != Os::File::OP_OK) @@ -193,10 +183,10 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, return FAILED_FILE_READ; } - hash.update(block_data, static_cast(bytes_to_read)); + hash.update(block_data, static_cast(bytes_to_read)); } - remaining_bytes = static_cast(int_file_size % CRC_FILE_READ_BLOCK); + remaining_bytes = filesize % CRC_FILE_READ_BLOCK; bytes_to_read = remaining_bytes; if(remaining_bytes > 0) { @@ -207,7 +197,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING, return FAILED_FILE_READ; } - hash.update(block_data, remaining_bytes); + hash.update(block_data, static_cast(remaining_bytes)); } // close file diff --git a/Utils/CRCChecker.hpp b/Utils/CRCChecker.hpp index d15c23e2e94..21a735f5ffb 100644 --- a/Utils/CRCChecker.hpp +++ b/Utils/CRCChecker.hpp @@ -16,7 +16,7 @@ namespace Utils { - static const NATIVE_INT_TYPE CRC_FILE_READ_BLOCK = 2048; + static const FwSignedSizeType CRC_FILE_READ_BLOCK = 2048; static const U32 CRC_MAX_FILENAME_SIZE = 128; // TODO use a config variable typedef enum diff --git a/Utils/Hash/Hash.hpp b/Utils/Hash/Hash.hpp index 19335d1acf2..c06e0006de6 100644 --- a/Utils/Hash/Hash.hpp +++ b/Utils/Hash/Hash.hpp @@ -49,7 +49,7 @@ namespace Utils { //! \param buffer: filled with resulting hash value static void hash( const void *data, - const NATIVE_INT_TYPE len, + const FwSizeType len, HashBuffer& buffer ); @@ -74,7 +74,7 @@ namespace Utils { //! \param len: length of data to add to hash calculation void update( const void *const data, - const NATIVE_INT_TYPE len + const FwSizeType len ); //! Finalize an incremental computation and return the result @@ -101,7 +101,7 @@ namespace Utils { //! Get the length of the file extension string //! - static NATIVE_UINT_TYPE getFileExtensionLength(); + static FwSizeType getFileExtensionLength(); private: diff --git a/Utils/Hash/HashBuffer.hpp b/Utils/Hash/HashBuffer.hpp index bf35e25f36b..24f43474230 100644 --- a/Utils/Hash/HashBuffer.hpp +++ b/Utils/Hash/HashBuffer.hpp @@ -31,7 +31,7 @@ class HashBuffer : public Fw::SerializeBufferBase { //! Construct a HashBuffer object //! - HashBuffer(const U8* args, NATIVE_UINT_TYPE size); + HashBuffer(const U8* args, FwSizeType size); HashBuffer(const HashBuffer& other); HashBuffer(); @@ -57,7 +57,7 @@ class HashBuffer : public Fw::SerializeBufferBase { //! Get the total buffer length of a hash buffer //! - NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer + FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer //! Get a pointer to the buffer within the hash buffer //! diff --git a/Utils/Hash/HashBufferCommon.cpp b/Utils/Hash/HashBufferCommon.cpp index 94232e564ae..5eb5a952069 100644 --- a/Utils/Hash/HashBufferCommon.cpp +++ b/Utils/Hash/HashBufferCommon.cpp @@ -9,7 +9,7 @@ namespace Utils { HashBuffer::HashBuffer() {} -HashBuffer::HashBuffer(const U8* args, NATIVE_UINT_TYPE size) : Fw::SerializeBufferBase() { +HashBuffer::HashBuffer(const U8* args, FwSizeType size) : Fw::SerializeBufferBase() { Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(args, size); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast(stat)); } @@ -51,7 +51,7 @@ U8* HashBuffer::getBuffAddr() { return this->m_bufferData; } -NATIVE_UINT_TYPE HashBuffer::getBuffCapacity() const { +FwSizeType HashBuffer::getBuffCapacity() const { return sizeof(this->m_bufferData); } diff --git a/Utils/Hash/HashCommon.cpp b/Utils/Hash/HashCommon.cpp index 993a3b3240e..897cad54cfe 100644 --- a/Utils/Hash/HashCommon.cpp +++ b/Utils/Hash/HashCommon.cpp @@ -16,7 +16,7 @@ namespace Utils { extendedName.format("%s%s", baseName.toChar(), HASH_EXTENSION_STRING); } - NATIVE_UINT_TYPE Hash :: + FwSizeType Hash :: getFileExtensionLength() { // Size of returns the size including the '\0' character. diff --git a/Utils/Hash/libcrc/CRC32.cpp b/Utils/Hash/libcrc/CRC32.cpp index 81e94ada5dc..eb002466aa2 100644 --- a/Utils/Hash/libcrc/CRC32.cpp +++ b/Utils/Hash/libcrc/CRC32.cpp @@ -26,13 +26,13 @@ namespace Utils { } void Hash :: - hash(const void *const data, const NATIVE_INT_TYPE len, HashBuffer& buffer) + hash(const void *const data, const FwSizeType len, HashBuffer& buffer) { HASH_HANDLE_TYPE local_hash_handle; local_hash_handle = 0xffffffffL; FW_ASSERT(data); char c; - for(int index = 0; index < len; index++) { + for(FwSizeType index = 0; index < len; index++) { c = static_cast(data)[index]; local_hash_handle = static_cast(update_crc_32(local_hash_handle, c)); } @@ -50,11 +50,11 @@ namespace Utils { } void Hash :: - update(const void *const data, NATIVE_INT_TYPE len) + update(const void *const data, FwSizeType len) { FW_ASSERT(data); char c; - for(int index = 0; index < len; index++) { + for(FwSizeType index = 0; index < len; index++) { c = static_cast(data)[index]; this->hash_handle = static_cast(update_crc_32(this->hash_handle, c)); } diff --git a/Utils/Hash/openssl/SHA256.cpp b/Utils/Hash/openssl/SHA256.cpp index d4bef35e4c0..0bc9c9ff1ee 100644 --- a/Utils/Hash/openssl/SHA256.cpp +++ b/Utils/Hash/openssl/SHA256.cpp @@ -26,7 +26,7 @@ namespace Utils { } void Hash :: - hash(const void *const data, const NATIVE_INT_TYPE len, HashBuffer& buffer) + hash(const void *const data, const FwSizeType len, HashBuffer& buffer) { U8 out[SHA256_DIGEST_LENGTH]; U8* ret = SHA256(static_cast(data), len, out); @@ -43,7 +43,7 @@ namespace Utils { } void Hash :: - update(const void *const data, NATIVE_INT_TYPE len) + update(const void *const data, FwSizeType len) { int ret = SHA256_Update(&this->hash_handle, static_cast(data), len); FW_ASSERT(ret == 1); diff --git a/Utils/Types/CircularBuffer.cpp b/Utils/Types/CircularBuffer.cpp index 7f1ce79dc9f..cef6a5ae61b 100644 --- a/Utils/Types/CircularBuffer.cpp +++ b/Utils/Types/CircularBuffer.cpp @@ -28,7 +28,7 @@ CircularBuffer :: CircularBuffer() : } -CircularBuffer :: CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size) : +CircularBuffer :: CircularBuffer(U8* const buffer, const FwSizeType size) : m_store(nullptr), m_store_size(0), m_head_idx(0), @@ -38,7 +38,7 @@ CircularBuffer :: CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size) setup(buffer, size); } -void CircularBuffer :: setup(U8* const buffer, const NATIVE_UINT_TYPE size) { +void CircularBuffer :: setup(U8* const buffer, const FwSizeType size) { FW_ASSERT(size > 0); FW_ASSERT(buffer != nullptr); FW_ASSERT(m_store == nullptr && m_store_size == 0); // Not already setup @@ -51,22 +51,22 @@ void CircularBuffer :: setup(U8* const buffer, const NATIVE_UINT_TYPE size) { m_high_water_mark = 0; } -NATIVE_UINT_TYPE CircularBuffer :: get_allocated_size() const { +FwSizeType CircularBuffer :: get_allocated_size() const { return m_allocated_size; } -NATIVE_UINT_TYPE CircularBuffer :: get_free_size() const { +FwSizeType CircularBuffer :: get_free_size() const { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called FW_ASSERT(m_allocated_size <= m_store_size, static_cast(m_allocated_size)); return m_store_size - m_allocated_size; } -NATIVE_UINT_TYPE CircularBuffer :: advance_idx(NATIVE_UINT_TYPE idx, NATIVE_UINT_TYPE amount) const { +FwSizeType CircularBuffer :: advance_idx(FwSizeType idx, FwSizeType amount) const { FW_ASSERT(idx < m_store_size, static_cast(idx)); return (idx + amount) % m_store_size; } -Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const NATIVE_UINT_TYPE size) { +Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const FwSizeType size) { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called FW_ASSERT(buffer != nullptr); // Check there is sufficient space @@ -74,7 +74,7 @@ Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const NA return Fw::FW_SERIALIZE_NO_ROOM_LEFT; } // Copy in all the supplied data - NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, m_allocated_size); + FwSizeType idx = advance_idx(m_head_idx, m_allocated_size); for (U32 i = 0; i < size; i++) { FW_ASSERT(idx < m_store_size, static_cast(idx)); m_store[idx] = buffer[i]; @@ -86,34 +86,34 @@ Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const NA return Fw::FW_SERIALIZE_OK; } -Fw::SerializeStatus CircularBuffer :: peek(char& value, NATIVE_UINT_TYPE offset) const { +Fw::SerializeStatus CircularBuffer :: peek(char& value, FwSizeType offset) const { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called return peek(reinterpret_cast(value), offset); } -Fw::SerializeStatus CircularBuffer :: peek(U8& value, NATIVE_UINT_TYPE offset) const { +Fw::SerializeStatus CircularBuffer :: peek(U8& value, FwSizeType offset) const { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called // Check there is sufficient data if ((sizeof(U8) + offset) > m_allocated_size) { return Fw::FW_DESERIALIZE_BUFFER_EMPTY; } - const NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset); + const FwSizeType idx = advance_idx(m_head_idx, offset); FW_ASSERT(idx < m_store_size, static_cast(idx)); value = m_store[idx]; return Fw::FW_SERIALIZE_OK; } -Fw::SerializeStatus CircularBuffer :: peek(U32& value, NATIVE_UINT_TYPE offset) const { +Fw::SerializeStatus CircularBuffer :: peek(U32& value, FwSizeType offset) const { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called // Check there is sufficient data if ((sizeof(U32) + offset) > m_allocated_size) { return Fw::FW_DESERIALIZE_BUFFER_EMPTY; } value = 0; - NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset); + FwSizeType idx = advance_idx(m_head_idx, offset); // Deserialize all the bytes from network format - for (NATIVE_UINT_TYPE i = 0; i < sizeof(U32); i++) { + for (FwSizeType i = 0; i < sizeof(U32); i++) { FW_ASSERT(idx < m_store_size, static_cast(idx)); value = (value << 8) | static_cast(m_store[idx]); idx = advance_idx(idx); @@ -121,16 +121,16 @@ Fw::SerializeStatus CircularBuffer :: peek(U32& value, NATIVE_UINT_TYPE offset) return Fw::FW_SERIALIZE_OK; } -Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset) const { +Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, FwSizeType size, FwSizeType offset) const { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called FW_ASSERT(buffer != nullptr); // Check there is sufficient data if ((size + offset) > m_allocated_size) { return Fw::FW_DESERIALIZE_BUFFER_EMPTY; } - NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset); + FwSizeType idx = advance_idx(m_head_idx, offset); // Deserialize all the bytes from network format - for (NATIVE_UINT_TYPE i = 0; i < size; i++) { + for (FwSizeType i = 0; i < size; i++) { FW_ASSERT(idx < m_store_size, static_cast(idx)); buffer[i] = m_store[idx]; idx = advance_idx(idx); @@ -138,7 +138,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, NATIVE_UINT_TYPE size, NA return Fw::FW_SERIALIZE_OK; } -Fw::SerializeStatus CircularBuffer :: rotate(NATIVE_UINT_TYPE amount) { +Fw::SerializeStatus CircularBuffer :: rotate(FwSizeType amount) { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called // Check there is sufficient data if (amount > m_allocated_size) { @@ -149,12 +149,12 @@ Fw::SerializeStatus CircularBuffer :: rotate(NATIVE_UINT_TYPE amount) { return Fw::FW_SERIALIZE_OK; } -NATIVE_UINT_TYPE CircularBuffer ::get_capacity() const { +FwSizeType CircularBuffer ::get_capacity() const { FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called return m_store_size; } -NATIVE_UINT_TYPE CircularBuffer ::get_high_water_mark() const { +FwSizeType CircularBuffer ::get_high_water_mark() const { return m_high_water_mark; } diff --git a/Utils/Types/CircularBuffer.hpp b/Utils/Types/CircularBuffer.hpp index fbd0e3f7d47..de26f10eac9 100644 --- a/Utils/Types/CircularBuffer.hpp +++ b/Utils/Types/CircularBuffer.hpp @@ -42,7 +42,7 @@ class CircularBuffer { * \param buffer: supplied buffer used as a data store. * \param size: the of the supplied data store. */ - CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size); + CircularBuffer(U8* const buffer, const FwSizeType size); /** * Wraps the supplied buffer as the new data store. Buffer size is supplied in the 'size' argument. Cannot be @@ -53,7 +53,7 @@ class CircularBuffer { * \param buffer: supplied buffer used as a data store. * \param size: the of the supplied data store. */ - void setup(U8* const buffer, const NATIVE_UINT_TYPE size); + void setup(U8* const buffer, const FwSizeType size); /** * Serialize a given buffer into this circular buffer. Will not accept more data than @@ -62,7 +62,7 @@ class CircularBuffer { * \param size: size of the supplied buffer. * \return Fw::FW_SERIALIZE_OK on success or something else on error */ - Fw::SerializeStatus serialize(const U8* const buffer, const NATIVE_UINT_TYPE size); + Fw::SerializeStatus serialize(const U8* const buffer, const FwSizeType size); /** * Deserialize data into the given variable without moving the head index @@ -70,21 +70,21 @@ class CircularBuffer { * \param offset: offset from head to start peak. Default: 0 * \return Fw::FW_SERIALIZE_OK on success or something else on error */ - Fw::SerializeStatus peek(char& value, NATIVE_UINT_TYPE offset = 0) const; + Fw::SerializeStatus peek(char& value, FwSizeType offset = 0) const; /** * Deserialize data into the given variable without moving the head index * \param value: value to fill * \param offset: offset from head to start peak. Default: 0 * \return Fw::FW_SERIALIZE_OK on success or something else on error */ - Fw::SerializeStatus peek(U8& value, NATIVE_UINT_TYPE offset = 0) const; + Fw::SerializeStatus peek(U8& value, FwSizeType offset = 0) const; /** * Deserialize data into the given variable without moving the head index * \param value: value to fill * \param offset: offset from head to start peak. Default: 0 * \return Fw::FW_SERIALIZE_OK on success or something else on error */ - Fw::SerializeStatus peek(U32& value, NATIVE_UINT_TYPE offset = 0) const; + Fw::SerializeStatus peek(U32& value, FwSizeType offset = 0) const; /** * Deserialize data into the given buffer without moving the head variable. @@ -93,7 +93,7 @@ class CircularBuffer { * \param offset: offset from head to start peak. Default: 0 * \return Fw::FW_SERIALIZE_OK on success or something else on error */ - Fw::SerializeStatus peek(U8* buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset = 0) const; + Fw::SerializeStatus peek(U8* buffer, FwSizeType size, FwSizeType offset = 0) const; /** * Rotate the head index, deleting data from the circular buffer and making @@ -101,31 +101,31 @@ class CircularBuffer { * \param amount: amount to rotate by (in bytes) * \return Fw::FW_SERIALIZE_OK on success or something else on error */ - Fw::SerializeStatus rotate(NATIVE_UINT_TYPE amount); + Fw::SerializeStatus rotate(FwSizeType amount); /** * Get the number of bytes allocated in the buffer * \return number of bytes */ - NATIVE_UINT_TYPE get_allocated_size() const; + FwSizeType get_allocated_size() const; /** * Get the number of free bytes, i.e., the number * of bytes that may be stored in the buffer without * deleting data and without exceeding the buffer capacity */ - NATIVE_UINT_TYPE get_free_size() const; + FwSizeType get_free_size() const; /** * Get the logical capacity of the buffer, i.e., the number of available * bytes when the buffer is empty */ - NATIVE_UINT_TYPE get_capacity() const; + FwSizeType get_capacity() const; /** * Return the largest tracked allocated size */ - NATIVE_UINT_TYPE get_high_water_mark() const; + FwSizeType get_high_water_mark() const; /** * Clear tracking of the largest allocated size @@ -139,18 +139,18 @@ class CircularBuffer { * \param amount: amount to advance * \return: new index value */ - NATIVE_UINT_TYPE advance_idx(NATIVE_UINT_TYPE idx, NATIVE_UINT_TYPE amount = 1) const; + FwSizeType advance_idx(FwSizeType idx, FwSizeType amount = 1) const; //! Physical store backing this circular buffer U8* m_store; //! Size of the physical store - NATIVE_UINT_TYPE m_store_size; + FwSizeType m_store_size; //! Index into m_store of byte zero in the logical store. //! When memory is deallocated, this index moves forward and wraps around. - NATIVE_UINT_TYPE m_head_idx; + FwSizeType m_head_idx; //! Allocated size (size of the logical store) - NATIVE_UINT_TYPE m_allocated_size; + FwSizeType m_allocated_size; //! Maximum allocated size - NATIVE_UINT_TYPE m_high_water_mark; + FwSizeType m_high_water_mark; }; } //End Namespace Types #endif diff --git a/Utils/Types/Queue.cpp b/Utils/Types/Queue.cpp index 23bfa989f26..125449ac0bc 100644 --- a/Utils/Types/Queue.cpp +++ b/Utils/Types/Queue.cpp @@ -22,7 +22,7 @@ void Queue::setup(U8* const storage, const FwSizeType storage_size, const FwSize static_cast(storage_size), static_cast(depth), static_cast(message_size)); - m_internal.setup(storage, static_cast(total_needed_size)); + m_internal.setup(storage, total_needed_size); m_message_size = message_size; } @@ -32,7 +32,7 @@ Fw::SerializeStatus Queue::enqueue(const U8* const message, const FwSizeType siz m_message_size == size, static_cast(size), static_cast(m_message_size)); // Message size is as expected - return m_internal.serialize(message, static_cast(m_message_size)); + return m_internal.serialize(message, m_message_size); } Fw::SerializeStatus Queue::dequeue(U8* const message, const FwSizeType size) { @@ -41,25 +41,25 @@ Fw::SerializeStatus Queue::dequeue(U8* const message, const FwSizeType size) { m_message_size <= size, static_cast(size), static_cast(m_message_size)); // Sufficient storage space for read message - Fw::SerializeStatus result = m_internal.peek(message, static_cast(m_message_size), 0); + Fw::SerializeStatus result = m_internal.peek(message, m_message_size, 0); if (result != Fw::FW_SERIALIZE_OK) { return result; } - return m_internal.rotate(static_cast(m_message_size)); + return m_internal.rotate(m_message_size); } -NATIVE_UINT_TYPE Queue::get_high_water_mark() const { +FwSizeType Queue::get_high_water_mark() const { FW_ASSERT(m_message_size > 0, static_cast(m_message_size)); - return static_cast(m_internal.get_high_water_mark() / m_message_size); + return m_internal.get_high_water_mark() / m_message_size; } void Queue::clear_high_water_mark() { m_internal.clear_high_water_mark(); } -NATIVE_UINT_TYPE Queue::getQueueSize() const { +FwSizeType Queue::getQueueSize() const { FW_ASSERT(m_message_size > 0, static_cast(m_message_size)); - return static_cast(m_internal.get_allocated_size() / m_message_size); + return m_internal.get_allocated_size() / m_message_size; } diff --git a/Utils/Types/Queue.hpp b/Utils/Types/Queue.hpp index 157233d8d72..aabb7c239cb 100644 --- a/Utils/Types/Queue.hpp +++ b/Utils/Types/Queue.hpp @@ -73,14 +73,14 @@ class Queue { /** * Return the largest tracked allocated size */ - NATIVE_UINT_TYPE get_high_water_mark() const; + FwSizeType get_high_water_mark() const; /** * Clear tracking of the largest allocated size */ void clear_high_water_mark(); - NATIVE_UINT_TYPE getQueueSize() const; + FwSizeType getQueueSize() const; private: CircularBuffer m_internal; diff --git a/Utils/Types/README.md b/Utils/Types/README.md index 2b835af02e6..7864a06a10f 100644 --- a/Utils/Types/README.md +++ b/Utils/Types/README.md @@ -43,7 +43,7 @@ The `CircularBuffer` type provides the following operations. ### Constructor ```c++ -CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size) +CircularBuffer(U8* const buffer, const FwSizeType size) ``` Construct a circular buffer with the given physical store, @@ -52,7 +52,7 @@ specified as a starting pointer and a size in bytes. ### Adding Data ```c++ -Fw::SerializeStatus serialize(const U8* const buffer, const NATIVE_UINT_TYPE size); +Fw::SerializeStatus serialize(const U8* const buffer, const FwSizeType size); ``` If the current logical store size plus `size` exceeds @@ -67,7 +67,7 @@ No data is actually serialized (the data is copied byte for byte). ### Reading Data ```c++ -Fw::SerializeStatus peek(char& value, NATIVE_UINT_TYPE offset = 0) const; +Fw::SerializeStatus peek(char& value, FwSizeType offset = 0) const; ``` If `offset` is not a valid address of the logical store, @@ -76,13 +76,13 @@ Otherwise read a `char` value at address `offset` of the logical store and store the result into `value`. ```c++ -Fw::SerializeStatus peek(U8& value, NATIVE_UINT_TYPE offset = 0) const; +Fw::SerializeStatus peek(U8& value, FwSizeType offset = 0) const; ``` Same as previous, but read a `U8` value. ```c++ -Fw::SerializeStatus peek(U32& value, NATIVE_UINT_TYPE offset = 0) const; +Fw::SerializeStatus peek(U32& value, FwSizeType offset = 0) const; ``` If `offset` through `offset` + 3 are not valid addresses @@ -92,7 +92,7 @@ interpret them as an unsigned 32-bit integer in big endian order, and store the result into `value`. ```c++ -Fw::SerializeStatus peek(U8* buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset = 0) const; +Fw::SerializeStatus peek(U8* buffer, FwSizeType size, FwSizeType offset = 0) const; ``` If `offset` through `offset + size - 1` are not all valid @@ -103,7 +103,7 @@ the memory starting at `buffer`. ### Deleting Data ```c++ -Fw::SerializeStatus rotate(NATIVE_UINT_TYPE amount); +Fw::SerializeStatus rotate(FwSizeType amount); ``` If the logical store size _s_ is less than `amount`, then @@ -116,7 +116,7 @@ and set the logical store size to _s_ - `amount`. ### Querying Buffer State ```c++ -NATIVE_UINT_TYPE get_allocated_size() const; +FwSizeType get_allocated_size() const; ``` Return the number of allocated bytes, i.e., the @@ -125,7 +125,7 @@ This is the maximum number of bytes that may be read from the logical store without adding data. ```c++ -NATIVE_UINT_TYPE get_free_size() const; +FwSizeType get_free_size() const; ``` Return the number of free bytes, i.e., the @@ -134,7 +134,7 @@ This is the number of bytes that may be added to the logical store without deleting data. ```c++ -NATIVE_UINT_TYPE get_capacity() const; +FwSizeType get_capacity() const; ``` Return the maximum logical store size (equal to the physical store size). diff --git a/Utils/Types/test/ut/CircularBuffer/CircularRules.cpp b/Utils/Types/test/ut/CircularBuffer/CircularRules.cpp index 9fcc65cd752..ad42b72e1fc 100644 --- a/Utils/Types/test/ut/CircularBuffer/CircularRules.cpp +++ b/Utils/Types/test/ut/CircularBuffer/CircularRules.cpp @@ -70,7 +70,7 @@ namespace Types { bool PeekOkRule::precondition(const MockTypes::CircularState& state) { - NATIVE_UINT_TYPE peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); + FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); if (state.getPeekType() == 0 ) { return peek_available >= sizeof(I8) + state.getPeekOffset(); } @@ -120,7 +120,7 @@ namespace Types { ASSERT_TRUE(state.peek(buffer, state.getRandomSize(), state.getPeekOffset())); ASSERT_EQ(state.getTestBuffer().peek(peek_buffer, state.getRandomSize(), state.getPeekOffset()), Fw::FW_SERIALIZE_OK); - for (NATIVE_UINT_TYPE i = 0; i < state.getRandomSize(); i++) { + for (FwSizeType i = 0; i < state.getRandomSize(); i++) { ASSERT_EQ(buffer[i], peek_buffer[i]); } } @@ -135,7 +135,7 @@ namespace Types { bool PeekBadRule::precondition(const MockTypes::CircularState& state) { - NATIVE_UINT_TYPE peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); + FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); if (state.getPeekType() == 0 ) { return peek_available < sizeof(I8) + state.getPeekOffset(); } @@ -181,7 +181,7 @@ namespace Types { bool RotateOkRule::precondition(const MockTypes::CircularState& state) { - NATIVE_UINT_TYPE rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); + FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); return rotate_available >= state.getRandomSize(); } @@ -199,7 +199,7 @@ namespace Types { bool RotateBadRule::precondition(const MockTypes::CircularState& state) { - NATIVE_UINT_TYPE rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); + FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize()); return rotate_available < state.getRandomSize(); } diff --git a/Utils/Types/test/ut/CircularBuffer/CircularState.cpp b/Utils/Types/test/ut/CircularBuffer/CircularState.cpp index 3e6205438b4..39f22e482bb 100644 --- a/Utils/Types/test/ut/CircularBuffer/CircularState.cpp +++ b/Utils/Types/test/ut/CircularBuffer/CircularState.cpp @@ -17,7 +17,7 @@ U8 CIRCULAR_BUFFER_MEMORY[MAX_BUFFER_SIZE]; namespace MockTypes { CircularState::CircularState() : - m_remaining_size(static_cast(sizeof(CIRCULAR_BUFFER_MEMORY))), + m_remaining_size(static_cast(sizeof(CIRCULAR_BUFFER_MEMORY))), m_random_size(MAX_BUFFER_SIZE), m_peek_offset(0), m_peek_type(0), @@ -25,7 +25,7 @@ namespace MockTypes { m_infinite_read(0), m_infinite_write(0), m_infinite_size(0), - m_test_buffer(CIRCULAR_BUFFER_MEMORY, static_cast(sizeof(CIRCULAR_BUFFER_MEMORY))) + m_test_buffer(CIRCULAR_BUFFER_MEMORY, static_cast(sizeof(CIRCULAR_BUFFER_MEMORY))) { memset(m_buffer, 0, sizeof m_buffer); } @@ -37,10 +37,10 @@ namespace MockTypes { } // Generates a random buffer - NATIVE_UINT_TYPE CircularState::generateRandomBuffer() { - m_peek_offset = static_cast(STest::Pick::lowerUpper(0, sizeof(m_buffer))); - m_peek_type = static_cast(STest::Pick::lowerUpper(0, 4)); - NATIVE_UINT_TYPE random_size = static_cast(STest::Pick::lowerUpper(0, sizeof(m_buffer))); + FwSizeType CircularState::generateRandomBuffer() { + m_peek_offset = static_cast(STest::Pick::lowerUpper(0, sizeof(m_buffer))); + m_peek_type = static_cast(STest::Pick::lowerUpper(0, 4)); + FwSizeType random_size = static_cast(STest::Pick::lowerUpper(0, sizeof(m_buffer))); for (U32 i = 0; i < random_size; i++) { m_buffer[i] = static_cast(STest::Pick::lowerUpper(0, 256)); } @@ -48,21 +48,21 @@ namespace MockTypes { return random_size; } - void CircularState::setRandom(NATIVE_UINT_TYPE random, NATIVE_UINT_TYPE peek_type, NATIVE_UINT_TYPE peek_offset) { + void CircularState::setRandom(FwSizeType random, FwSizeType peek_type, FwSizeType peek_offset) { m_random_size = random; m_peek_type = peek_type; m_peek_offset = peek_offset; } - NATIVE_UINT_TYPE CircularState::getPeekOffset() const { + FwSizeType CircularState::getPeekOffset() const { return m_peek_offset; } - NATIVE_UINT_TYPE CircularState::getPeekType() const { + FwSizeType CircularState::getPeekType() const { return m_peek_type; } - bool CircularState::addInfinite(const U8* buffer, NATIVE_UINT_TYPE size) { + bool CircularState::addInfinite(const U8* buffer, FwSizeType size) { // If we are out of "infinite space" add another MB, and check allocation if ((m_infinite_write + size) > m_infinite_size) { void* new_pointer = std::realloc(m_infinite_store, m_infinite_size + 1048576); @@ -77,8 +77,8 @@ namespace MockTypes { return true; } - bool CircularState::peek(U8*& buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset) { - NATIVE_UINT_TYPE final_offset = m_infinite_read + offset; + bool CircularState::peek(U8*& buffer, FwSizeType size, FwSizeType offset) { + FwSizeType final_offset = m_infinite_read + offset; if ((final_offset + size) > m_infinite_write) { return false; } @@ -86,7 +86,7 @@ namespace MockTypes { return true; } - bool CircularState::rotate(NATIVE_UINT_TYPE size) { + bool CircularState::rotate(FwSizeType size) { // Fail if we try to rotate too far if ((m_infinite_read + size) > m_infinite_write) { return false; @@ -95,7 +95,7 @@ namespace MockTypes { return true; } - NATIVE_UINT_TYPE CircularState::getRandomSize() const { + FwSizeType CircularState::getRandomSize() const { return m_random_size; } @@ -103,11 +103,11 @@ namespace MockTypes { return m_buffer; } - NATIVE_UINT_TYPE CircularState::getRemainingSize() const { + FwSizeType CircularState::getRemainingSize() const { return m_remaining_size; } - void CircularState::setRemainingSize(NATIVE_UINT_TYPE mRemainingSize) { + void CircularState::setRemainingSize(FwSizeType mRemainingSize) { m_remaining_size = mRemainingSize; } @@ -116,7 +116,7 @@ namespace MockTypes { } void CircularState::checkSizes() const { - const NATIVE_UINT_TYPE allocated_size = (MAX_BUFFER_SIZE - m_remaining_size); + const FwSizeType allocated_size = (MAX_BUFFER_SIZE - m_remaining_size); ASSERT_EQ(m_test_buffer.get_free_size(), m_remaining_size); ASSERT_EQ(m_test_buffer.get_allocated_size(), allocated_size); } diff --git a/Utils/Types/test/ut/CircularBuffer/CircularState.hpp b/Utils/Types/test/ut/CircularBuffer/CircularState.hpp index 535c29b569d..6ad8e307859 100644 --- a/Utils/Types/test/ut/CircularBuffer/CircularState.hpp +++ b/Utils/Types/test/ut/CircularBuffer/CircularState.hpp @@ -27,45 +27,45 @@ namespace MockTypes { * Generates a random buffer for input to various calls to the CircularBuffer. * @return size of this buffer */ - NATIVE_UINT_TYPE generateRandomBuffer(); + FwSizeType generateRandomBuffer(); /** * Sets the random settings * @param random: random size * @param peek_type: peek type (0-3) * @param peek_offset: offset size */ - void setRandom(NATIVE_UINT_TYPE random, NATIVE_UINT_TYPE peek_type, NATIVE_UINT_TYPE peek_offset); + void setRandom(FwSizeType random, FwSizeType peek_type, FwSizeType peek_offset); /** * Add to the infinite pool of data. * @return true if successful, false otherwise */ - bool addInfinite(const U8* buffer, NATIVE_UINT_TYPE size); + bool addInfinite(const U8* buffer, FwSizeType size); /** * Grab a peek buffer for given size and offset. * @return true if successful, false if cannot. */ - bool peek(U8*& buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset = 0); + bool peek(U8*& buffer, FwSizeType size, FwSizeType offset = 0); /** * Rotate the circular buffer. * @param size: size to rotate * @return true if successful, false otherwise */ - bool rotate(NATIVE_UINT_TYPE size); + bool rotate(FwSizeType size); /** * Get the size of the random buffer data. * @return size of the buffer */ - NATIVE_UINT_TYPE getRandomSize() const; + FwSizeType getRandomSize() const; /** * Get the size of the random buffer data. * @return size of the buffer */ - NATIVE_UINT_TYPE getPeekOffset() const; + FwSizeType getPeekOffset() const; /** * Get the size of the random buffer data. * @return size of the buffer */ - NATIVE_UINT_TYPE getPeekType() const; + FwSizeType getPeekType() const; /** * Gets a pointer to the random buffer. * @return random buffer storing data @@ -75,12 +75,12 @@ namespace MockTypes { * Get the remaining size of the circular buffer. This is a shadow field. * @return shadow field for circular buffer. */ - NATIVE_UINT_TYPE getRemainingSize() const; + FwSizeType getRemainingSize() const; /** * Set the remaining size shadow field input. * @param mRemainingSize: remaining size shadow field */ - void setRemainingSize(NATIVE_UINT_TYPE mRemainingSize); + void setRemainingSize(FwSizeType mRemainingSize); /** * Get the in-test circular buffer. * @return in-test circular buffer @@ -93,17 +93,17 @@ namespace MockTypes { void checkSizes() const; private: - NATIVE_UINT_TYPE m_remaining_size; - NATIVE_UINT_TYPE m_random_size; - NATIVE_UINT_TYPE m_peek_offset; - NATIVE_UINT_TYPE m_peek_type; + FwSizeType m_remaining_size; + FwSizeType m_random_size; + FwSizeType m_peek_offset; + FwSizeType m_peek_type; U8 m_buffer[MAX_BUFFER_SIZE]; // May use just under 100MB of space U8* m_infinite_store; - NATIVE_UINT_TYPE m_infinite_read; - NATIVE_UINT_TYPE m_infinite_write; - NATIVE_UINT_TYPE m_infinite_size; + FwSizeType m_infinite_read; + FwSizeType m_infinite_write; + FwSizeType m_infinite_size; Types::CircularBuffer m_test_buffer; }; diff --git a/Utils/Types/test/ut/CircularBuffer/Main.cpp b/Utils/Types/test/ut/CircularBuffer/Main.cpp index fbe7727cb84..35327ffe09b 100644 --- a/Utils/Types/test/ut/CircularBuffer/Main.cpp +++ b/Utils/Types/test/ut/CircularBuffer/Main.cpp @@ -23,7 +23,7 @@ * A random hopper for rules. Apply STEP_COUNT times. */ TEST(CircularBufferTests, RandomCircularTests) { - F64 max_addr_mem = sizeof(NATIVE_UINT_TYPE) * 8.0; + F64 max_addr_mem = sizeof(FwSizeType) * 8.0; max_addr_mem = pow(2.0, max_addr_mem); // Ensure the maximum memory use is less that the max addressable memory F64 max_used_mem = static_cast(STEP_COUNT) * static_cast(MAX_BUFFER_SIZE); @@ -107,7 +107,7 @@ TEST(CircularBufferTests, BasicPeekTest) { state.getTestBuffer().serialize(reinterpret_cast(&peek_char), sizeof(peek_char)); state.addInfinite(&peek_u8, sizeof(peek_u8)); state.getTestBuffer().serialize(&peek_u8, sizeof(peek_u8)); - for (NATIVE_UINT_TYPE i = sizeof(U32); i > 0; i--) { + for (FwSizeType i = sizeof(U32); i > 0; i--) { U8 byte = peek_u32 >> ((i - 1) * 8); state.addInfinite(&byte, sizeof(byte)); state.getTestBuffer().serialize(&byte, sizeof(byte));