Skip to content

Commit

Permalink
Fixes to accomidate Fw refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Feb 27, 2025
1 parent de98f59 commit c78b6f7
Show file tree
Hide file tree
Showing 51 changed files with 281 additions and 273 deletions.
2 changes: 1 addition & 1 deletion Drv/Ports/DataTypes/DataBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Drv {
return *this;
}

NATIVE_UINT_TYPE DataBuffer::getBuffCapacity() const {
FwSizeType DataBuffer::getBuffCapacity() const {
return sizeof(this->m_data);
}

Expand Down
2 changes: 1 addition & 1 deletion Drv/Ports/DataTypes/DataBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Fw/SerializableFile/SerializableFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Fw {

this->reset();
SerializeStatus serStatus;
serStatus = this->m_buffer.setBuffLen(length);
serStatus = this->m_buffer.setBuffLen(static_cast<FwSizeType>(length));
FW_ASSERT(FW_SERIALIZE_OK == serStatus, serStatus);
serStatus = serializable.deserialize(this->m_buffer);
if(FW_SERIALIZE_OK != serStatus) {
Expand Down
2 changes: 1 addition & 1 deletion Fw/Test/UnitTestAssert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ 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
}

Expand Down
2 changes: 1 addition & 1 deletion Fw/Types/SerialBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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) {}

FwSizeType SerialBuffer ::getBuffCapacity() const {
return m_capacity;
Expand Down
4 changes: 2 additions & 2 deletions Fw/Types/SerialBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -71,7 +71,7 @@ class SerialBuffer : public SerializeBufferBase {
U8* const m_data;

//! The capacity
const U32 m_capacity;
const FwSizeType m_capacity;
};

} // namespace Fw
Expand Down
15 changes: 7 additions & 8 deletions Os/ValidateFileCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NATIVE_INT_TYPE>(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;
Expand All @@ -44,7 +43,7 @@ namespace Os {
break;
}
// Add chunk to hash calculation:
hash.update(&buffer, static_cast<NATIVE_INT_TYPE>(size));
hash.update(&buffer, static_cast<FwSizeType>(size));
cnt++;
}
file.close();
Expand Down Expand Up @@ -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<FwSignedSizeType>(hashBuffer.getBuffCapacity());
status = hashFile.read(savedHash, size);
if( File::OP_OK != status ) {
return status;
}
if( size != static_cast<NATIVE_INT_TYPE>(hashBuffer.getBuffCapacity()) ) {
if( size != static_cast<FwSignedSizeType>(hashBuffer.getBuffCapacity()) ) {
return File::BAD_SIZE;
}
hashFile.close();

// Return the hash buffer:
Utils::HashBuffer savedHashBuffer(savedHash, static_cast<NATIVE_UINT_TYPE>(size));
Utils::HashBuffer savedHashBuffer(savedHash, static_cast<FwSizeType>(size));
hashBuffer = savedHashBuffer;

return status;
Expand All @@ -101,12 +100,12 @@ namespace Os {
}

// Write out the hash
FwSignedSizeType size = hashBuffer.getBuffLength();
FwSignedSizeType size = static_cast<FwSignedSizeType>(hashBuffer.getBuffLength());
status = hashFile.write(hashBuffer.getBuffAddr(), size, Os::File::WaitType::NO_WAIT);
if( File::OP_OK != status ) {
return status;
}
if( size != static_cast<NATIVE_INT_TYPE>(hashBuffer.getBuffLength()) ) {
if( size != static_cast<FwSignedSizeType>(hashBuffer.getBuffLength()) ) {
return File::BAD_SIZE;
}
hashFile.close();
Expand Down
2 changes: 1 addition & 1 deletion Ref/RecvBuffApp/RecvBuffComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Ref {
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast<FwAssertArgType>(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<FwAssertArgType>(stat));
// deserialize checksum
Expand Down
14 changes: 7 additions & 7 deletions Svc/ActiveTextLogger/LogFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<U32>::max() - size)) ) {
(this->m_currentFileSize > (std::numeric_limits<FwSizeType>::max() - size)) ) {

status = false;
this->m_openFile = false;
Expand All @@ -61,24 +61,24 @@ namespace Svc {
// Won't exceed max size, so write to file:
else {

FwSignedSizeType writeSize = size;
FwSignedSizeType writeSize = static_cast<FwSignedSizeType>(size);
Os::File::Status stat = this->m_file.write(reinterpret_cast<const U8*>(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 = (static_cast<FwSizeType>(writeSize) == size);

this->m_currentFileSize += static_cast<U32>(writeSize);
this->m_currentFileSize += static_cast<FwSizeType>(writeSize);
}
}

return status;
}


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);

Expand Down
8 changes: 4 additions & 4 deletions Svc/ActiveTextLogger/LogFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ 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
//!
//! \param buf The buffer of data to write
//! \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
Expand All @@ -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;
};

}
Expand Down
32 changes: 16 additions & 16 deletions Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ 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,
FwAssertArgType arg4,
FwAssertArgType arg5,
FwAssertArgType arg6,
CHAR* destBuffer,
NATIVE_INT_TYPE buffSize
FwSizeType buffSize
);

}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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<U32>(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
Expand All @@ -130,33 +130,33 @@ namespace Svc {
case 0:
this->log_FATAL_AF_ASSERT_0(
fileArg,
lineNo);
static_cast<U32>(lineNo));
break;
case 1:
this->log_FATAL_AF_ASSERT_1(
fileArg,
lineNo,
static_cast<U32>(lineNo),
static_cast<U32>(arg1));
break;
case 2:
this->log_FATAL_AF_ASSERT_2(
fileArg,
lineNo,
static_cast<U32>(lineNo),
static_cast<U32>(arg1),
static_cast<U32>(arg2));
break;
case 3:
this->log_FATAL_AF_ASSERT_3(
fileArg,
lineNo,
static_cast<U32>(lineNo),
static_cast<U32>(arg1),
static_cast<U32>(arg2),
static_cast<U32>(arg3));
break;
case 4:
this->log_FATAL_AF_ASSERT_4(
fileArg,
lineNo,
static_cast<U32>(lineNo),
static_cast<U32>(arg1),
static_cast<U32>(arg2),
static_cast<U32>(arg3),
Expand All @@ -165,7 +165,7 @@ namespace Svc {
case 5:
this->log_FATAL_AF_ASSERT_5(
fileArg,
lineNo,
static_cast<U32>(lineNo),
static_cast<U32>(arg1),
static_cast<U32>(arg2),
static_cast<U32>(arg3),
Expand All @@ -175,7 +175,7 @@ namespace Svc {
case 6:
this->log_FATAL_AF_ASSERT_6(
fileArg,
lineNo,
static_cast<U32>(lineNo),
static_cast<U32>(arg1),
static_cast<U32>(arg2),
static_cast<U32>(arg3),
Expand All @@ -184,7 +184,7 @@ namespace Svc {
static_cast<U32>(arg6));
break;
default:
this->log_FATAL_AF_UNEXPECTED_ASSERT(fileArg,lineNo,numArgs);
this->log_FATAL_AF_UNEXPECTED_ASSERT(fileArg,static_cast<U32>(lineNo),static_cast<U32>(numArgs));
break;
}

Expand Down
8 changes: 4 additions & 4 deletions Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions Svc/BufferAccumulator/BufferAccumulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ void BufferAccumulator ::allocateQueue(
) {

this->m_allocatorId = identifier;
NATIVE_UINT_TYPE memSize = static_cast<NATIVE_UINT_TYPE>(sizeof(Fw::Buffer) * maxNumBuffers);
FwSizeType memSize = static_cast<FwSizeType>(sizeof(Fw::Buffer) * maxNumBuffers);
bool recoverable = false;
this->m_bufferMemory = static_cast<Fw::Buffer*>(
allocator.allocate(static_cast<NATIVE_UINT_TYPE>(identifier), memSize, recoverable));
allocator.allocate(static_cast<FwEnumStoreType>(identifier), memSize, recoverable));
//TODO: Fail gracefully here
m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
}

void BufferAccumulator ::deallocateQueue(Fw::MemAllocator& allocator) {
allocator.deallocate(static_cast<NATIVE_UINT_TYPE>(this->m_allocatorId), this->m_bufferMemory);
allocator.deallocate(static_cast<FwEnumStoreType>(this->m_allocatorId), this->m_bufferMemory);
}

// ----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit c78b6f7

Please sign in to comment.