From a872e0cd57e44dbd97243a0d34405744e7519158 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Tue, 19 Mar 2024 23:47:26 +0100 Subject: [PATCH 01/21] Fixed conversion warnings on framework tests --- CMakeLists.txt | 1 + Drv/Ip/TcpClientSocket.cpp | 4 +- Drv/Ip/TcpServerSocket.cpp | 4 +- Drv/Ip/UdpSocket.cpp | 6 +-- .../LinuxGpioDriverComponentImpl.cpp | 8 ++-- Drv/LinuxI2cDriver/LinuxI2cDriver.cpp | 4 +- Drv/LinuxUartDriver/LinuxUartDriver.cpp | 4 +- Fw/Dp/DpContainer.cpp | 4 +- Fw/FilePacket/DataPacket.cpp | 8 ++-- Fw/FilePacket/EndPacket.cpp | 2 +- Fw/FilePacket/PathName.cpp | 2 +- Fw/FilePacket/StartPacket.cpp | 5 ++- Fw/Types/Serializable.cpp | 44 +++++++++---------- Os/File.cpp | 5 ++- Os/Posix/IntervalTimer.cpp | 4 +- Os/Pthreads/BufferQueueCommon.cpp | 8 ++-- Os/ValidateFileCommon.cpp | 4 +- Svc/ActiveTextLogger/LogFile.cpp | 2 +- Svc/BufferAccumulator/BufferAccumulator.cpp | 2 +- Svc/BufferLogger/BufferLoggerFile.cpp | 2 +- .../BufferManagerComponentImpl.cpp | 3 +- Svc/CmdSequencer/FPrimeSequence.cpp | 12 ++--- Svc/CmdSequencer/formats/AMPCSSequence.cpp | 10 ++--- Svc/ComLogger/ComLogger.cpp | 4 +- Svc/ComQueue/ComQueue.cpp | 20 ++++++--- Svc/Deframer/Deframer.cpp | 2 +- Svc/DpManager/DpManager.cpp | 2 +- Svc/FileUplink/File.cpp | 2 +- Svc/FramingProtocol/FprimeProtocol.cpp | 9 ++-- Svc/GenericHub/GenericHubComponentImpl.cpp | 4 +- Svc/GroundInterface/GroundInterface.cpp | 20 ++++++--- .../LinuxTimerComponentImplTimerFd.cpp | 2 +- Svc/PosixTime/PosixTime.cpp | 2 +- Svc/PrmDb/PrmDbImpl.cpp | 36 ++++++++++----- Utils/CRCChecker.cpp | 8 ++-- Utils/Hash/libcrc/CRC32.cpp | 4 +- Utils/Types/Queue.cpp | 30 ++++++++----- 37 files changed, 169 insertions(+), 124 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a3f0ec3de..eb5222f81f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ if (NOT BUILD_TESTING) add_compile_options( -Wshadow -pedantic + -Wconversion ) endif() diff --git a/Drv/Ip/TcpClientSocket.cpp b/Drv/Ip/TcpClientSocket.cpp index 99f7d5017c..8934cd75fd 100644 --- a/Drv/Ip/TcpClientSocket.cpp +++ b/Drv/Ip/TcpClientSocket.cpp @@ -82,11 +82,11 @@ SocketIpStatus TcpClientSocket::openProtocol(NATIVE_INT_TYPE& fd) { } I32 TcpClientSocket::sendProtocol(const U8* const data, const U32 size) { - return ::send(this->m_fd, data, size, SOCKET_IP_SEND_FLAGS); + return static_cast(::send(this->m_fd, data, size, SOCKET_IP_SEND_FLAGS)); } I32 TcpClientSocket::recvProtocol(U8* const data, const U32 size) { - return ::recv(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS); + return static_cast(::recv(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS)); } } // namespace Drv diff --git a/Drv/Ip/TcpServerSocket.cpp b/Drv/Ip/TcpServerSocket.cpp index 43fc633779..6c939db9e5 100644 --- a/Drv/Ip/TcpServerSocket.cpp +++ b/Drv/Ip/TcpServerSocket.cpp @@ -120,11 +120,11 @@ SocketIpStatus TcpServerSocket::openProtocol(NATIVE_INT_TYPE& fd) { } I32 TcpServerSocket::sendProtocol(const U8* const data, const U32 size) { - return ::send(this->m_fd, data, size, SOCKET_IP_SEND_FLAGS); + return static_cast(::send(this->m_fd, data, size, SOCKET_IP_SEND_FLAGS)); } I32 TcpServerSocket::recvProtocol(U8* const data, const U32 size) { - return ::recv(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS); + return static_cast(::recv(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS)); } } // namespace Drv diff --git a/Drv/Ip/UdpSocket.cpp b/Drv/Ip/UdpSocket.cpp index 6996e52b4b..52adf05116 100644 --- a/Drv/Ip/UdpSocket.cpp +++ b/Drv/Ip/UdpSocket.cpp @@ -155,13 +155,13 @@ SocketIpStatus UdpSocket::openProtocol(NATIVE_INT_TYPE& fd) { I32 UdpSocket::sendProtocol(const U8* const data, const U32 size) { FW_ASSERT(this->m_state->m_addr_send.sin_family != 0); // Make sure the address was previously setup - return ::sendto(this->m_fd, data, size, SOCKET_IP_SEND_FLAGS, - reinterpret_cast(&this->m_state->m_addr_send), sizeof(this->m_state->m_addr_send)); + return static_cast(::sendto(this->m_fd, data, size, SOCKET_IP_SEND_FLAGS, + reinterpret_cast(&this->m_state->m_addr_send), sizeof(this->m_state->m_addr_send))); } I32 UdpSocket::recvProtocol(U8* const data, const U32 size) { FW_ASSERT(this->m_state->m_addr_recv.sin_family != 0); // Make sure the address was previously setup - return ::recvfrom(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS, nullptr, nullptr); + return static_cast(::recvfrom(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS, nullptr, nullptr)); } } // namespace Drv diff --git a/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp b/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp index aa644de3a1..78aedc9af6 100644 --- a/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp +++ b/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp @@ -114,7 +114,7 @@ namespace Drv { } const char *dir = out_flag ? "out" : "in"; - len = strlen(dir); + len = static_cast(strlen(dir)); if (write(fd, dir, len) != len) { (void) close(fd); @@ -157,8 +157,8 @@ namespace Drv { FW_ASSERT(fd != -1); - NATIVE_INT_TYPE stat1 = lseek(fd, 0, SEEK_SET); // Must seek back to the starting - NATIVE_INT_TYPE stat2 = read(fd, &ch, 1); + NATIVE_INT_TYPE stat1 = static_cast(lseek(fd, 0, SEEK_SET)); // Must seek back to the starting + NATIVE_INT_TYPE stat2 = static_cast(read(fd, &ch, 1)); if (stat1 == -1 || stat2 != 1) { DEBUG_PRINT("GPIO read failure: %d %d!\n",stat1,stat2); @@ -199,7 +199,7 @@ namespace Drv { return -1; } - len = strlen(edge) + 1; + len = static_cast(strlen(edge) + 1); if(write(fd, edge, len) != len) { (void) close(fd); DEBUG_PRINT("gpio/set-edge error!\n"); diff --git a/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp b/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp index 8d2dcba430..be160c4eb0 100644 --- a/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp +++ b/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp @@ -99,7 +99,7 @@ namespace Drv { // make sure it isn't a null pointer FW_ASSERT(serBuffer.getData()); // write data - stat = write(this->m_fd, serBuffer.getData(), serBuffer.getSize()); + stat = static_cast(write(this->m_fd, serBuffer.getData(), serBuffer.getSize())); if (stat == -1) { #if DEBUG_PRINT Fw::Logger::logMsg("Status: %d Errno: %d\n", stat, errno); @@ -135,7 +135,7 @@ namespace Drv { // make sure it isn't a null pointer FW_ASSERT(serBuffer.getData()); // read data - stat = read(this->m_fd, serBuffer.getData(), serBuffer.getSize()); + stat = static_cast(read(this->m_fd, serBuffer.getData(), serBuffer.getSize())); if (stat == -1) { #if DEBUG_PRINT Fw::Logger::logMsg("Status: %d Errno: %d\n", stat, errno); diff --git a/Drv/LinuxUartDriver/LinuxUartDriver.cpp b/Drv/LinuxUartDriver/LinuxUartDriver.cpp index e55da58977..5c153537e7 100644 --- a/Drv/LinuxUartDriver/LinuxUartDriver.cpp +++ b/Drv/LinuxUartDriver/LinuxUartDriver.cpp @@ -326,7 +326,7 @@ Drv::SendStatus LinuxUartDriver ::send_handler(const NATIVE_INT_TYPE portNum, Fw unsigned char *data = serBuffer.getData(); NATIVE_INT_TYPE xferSize = serBuffer.getSize(); - NATIVE_INT_TYPE stat = ::write(this->m_fd, data, xferSize); + NATIVE_INT_TYPE stat = static_cast(::write(this->m_fd, data, xferSize)); if (-1 == stat || stat != xferSize) { Fw::LogStringArg _arg = this->m_device; @@ -368,7 +368,7 @@ void LinuxUartDriver ::serialReadTaskEntry(void* ptr) { // Read until something is received or an error occurs. Only loop when // stat == 0 as this is the timeout condition and the read should spin while ((stat == 0) && !comp->m_quitReadThread) { - stat = ::read(comp->m_fd, buff.getData(), buff.getSize()); + stat = static_cast(::read(comp->m_fd, buff.getData(), buff.getSize())); } buff.setSize(0); diff --git a/Fw/Dp/DpContainer.cpp b/Fw/Dp/DpContainer.cpp index 33abdedf1f..9eac97f16b 100644 --- a/Fw/Dp/DpContainer.cpp +++ b/Fw/Dp/DpContainer.cpp @@ -139,7 +139,7 @@ void DpContainer::setBuffer(const Buffer& buffer) { FW_ASSERT(bufferSize >= minBufferSize, static_cast(bufferSize), static_cast(minBufferSize)); U8* const dataAddr = &buffAddr[DATA_OFFSET]; - this->m_dataBuffer.setExtBuffer(dataAddr, dataCapacity); + this->m_dataBuffer.setExtBuffer(dataAddr, static_cast(dataCapacity)); } Utils::HashBuffer DpContainer::getHeaderHash() const { @@ -199,7 +199,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, dataSize, computedHash); + Utils::Hash::hash(dataAddr, static_cast(dataSize), computedHash); return computedHash; } diff --git a/Fw/FilePacket/DataPacket.cpp b/Fw/FilePacket/DataPacket.cpp index e08c957448..3c005f93dc 100644 --- a/Fw/FilePacket/DataPacket.cpp +++ b/Fw/FilePacket/DataPacket.cpp @@ -32,11 +32,11 @@ namespace Fw { U32 FilePacket::DataPacket :: bufferSize() const { - return + return static_cast( this->m_header.bufferSize() + sizeof(this->m_byteOffset) + sizeof(this->m_dataSize) + - this->m_dataSize; + this->m_dataSize); } SerializeStatus FilePacket::DataPacket :: @@ -76,10 +76,10 @@ namespace Fw { U32 FilePacket::DataPacket :: fixedLengthSize() const { - return + return static_cast( this->m_header.bufferSize() + sizeof(this->m_byteOffset) + - sizeof(this->m_dataSize); + sizeof(this->m_dataSize)); } SerializeStatus FilePacket::DataPacket :: diff --git a/Fw/FilePacket/EndPacket.cpp b/Fw/FilePacket/EndPacket.cpp index c0a1aa0abd..1d3b4d9de4 100644 --- a/Fw/FilePacket/EndPacket.cpp +++ b/Fw/FilePacket/EndPacket.cpp @@ -30,7 +30,7 @@ namespace Fw { U32 FilePacket::EndPacket :: bufferSize() const { - return this->m_header.bufferSize() + sizeof(this->m_checksumValue); + return static_cast(this->m_header.bufferSize() + sizeof(this->m_checksumValue)); } SerializeStatus FilePacket::EndPacket :: diff --git a/Fw/FilePacket/PathName.cpp b/Fw/FilePacket/PathName.cpp index 1b29ef1383..e6043ac91c 100644 --- a/Fw/FilePacket/PathName.cpp +++ b/Fw/FilePacket/PathName.cpp @@ -29,7 +29,7 @@ namespace Fw { U32 FilePacket::PathName :: bufferSize() const { - return sizeof(this->m_length) + this->m_length; + return static_cast(sizeof(this->m_length) + this->m_length); } SerializeStatus FilePacket::PathName :: diff --git a/Fw/FilePacket/StartPacket.cpp b/Fw/FilePacket/StartPacket.cpp index c597948f1e..ea1ed335b9 100644 --- a/Fw/FilePacket/StartPacket.cpp +++ b/Fw/FilePacket/StartPacket.cpp @@ -31,10 +31,11 @@ namespace Fw { U32 FilePacket::StartPacket :: bufferSize() const { - return this->m_header.bufferSize() + + return static_cast( + this->m_header.bufferSize() + sizeof(this->m_fileSize) + this->m_sourcePath.bufferSize() + - this->m_destinationPath.bufferSize(); + this->m_destinationPath.bufferSize()); } SerializeStatus FilePacket::StartPacket :: diff --git a/Fw/Types/Serializable.cpp b/Fw/Types/Serializable.cpp index 2cddeddca0..edfec835a9 100644 --- a/Fw/Types/Serializable.cpp +++ b/Fw/Types/Serializable.cpp @@ -70,7 +70,7 @@ namespace Fw { } FW_ASSERT(this->getBuffAddr()); this->getBuffAddr()[this->m_serLoc] = val; - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; @@ -82,7 +82,7 @@ namespace Fw { } FW_ASSERT(this->getBuffAddr()); this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -96,7 +96,7 @@ namespace Fw { // MSB first this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -109,7 +109,7 @@ namespace Fw { // MSB first this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -125,7 +125,7 @@ namespace Fw { this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -140,7 +140,7 @@ namespace Fw { this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -161,7 +161,7 @@ namespace Fw { this->getBuffAddr()[this->m_serLoc + 5] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 6] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 7] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -180,7 +180,7 @@ namespace Fw { this->getBuffAddr()[this->m_serLoc + 5] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 6] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 7] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -219,7 +219,7 @@ namespace Fw { this->getBuffAddr()[this->m_serLoc + 0] = FW_SERIALIZE_FALSE_VALUE; } - this->m_serLoc += sizeof(U8); + this->m_serLoc += static_cast(sizeof(U8)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -259,7 +259,7 @@ namespace Fw { // copy buffer to our buffer (void) memcpy(&this->getBuffAddr()[this->m_serLoc], buff, length); - this->m_serLoc += length; + this->m_serLoc += static_cast(length); this->m_deserLoc = 0; return FW_SERIALIZE_OK; @@ -316,7 +316,7 @@ namespace Fw { // read from current location FW_ASSERT(this->getBuffAddr()); val = this->getBuffAddr()[this->m_deserLoc + 0]; - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -330,7 +330,7 @@ namespace Fw { // read from current location FW_ASSERT(this->getBuffAddr()); val = static_cast(this->getBuffAddr()[this->m_deserLoc + 0]); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -349,7 +349,7 @@ namespace Fw { ((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) | ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8) ); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -367,7 +367,7 @@ namespace Fw { ((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) | ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8) ); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } #endif @@ -386,7 +386,7 @@ namespace Fw { | (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 8) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 16) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 24); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -404,7 +404,7 @@ namespace Fw { | (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 8) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 16) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 24); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } #endif @@ -430,7 +430,7 @@ namespace Fw { | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 48) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 56); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -452,7 +452,7 @@ namespace Fw { | (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 40) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 48) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 56); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } #endif @@ -492,7 +492,7 @@ namespace Fw { return FW_DESERIALIZE_FORMAT_ERROR; } - this->m_deserLoc += sizeof(U8); + this->m_deserLoc += static_cast(sizeof(U8)); return FW_SERIALIZE_OK; } @@ -563,7 +563,7 @@ namespace Fw { (void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], length); } - this->m_deserLoc += length; + this->m_deserLoc += static_cast(length); return FW_SERIALIZE_OK; } @@ -631,7 +631,7 @@ namespace Fw { // check for room if (newSerLoc <= this->getBuffCapacity()) { // update deser loc - this->m_serLoc = newSerLoc; + this->m_serLoc = static_cast(newSerLoc); } else { status = FW_SERIALIZE_NO_ROOM_LEFT; @@ -648,7 +648,7 @@ namespace Fw { return FW_DESERIALIZE_SIZE_MISMATCH; } // update location in buffer to skip the value - this->m_deserLoc += numBytesToSkip; + this->m_deserLoc += static_cast(numBytesToSkip); return FW_SERIALIZE_OK; } diff --git a/Os/File.cpp b/Os/File.cpp index 95fd8c3ff9..40ebea9ede 100644 --- a/Os/File.cpp +++ b/Os/File.cpp @@ -216,7 +216,10 @@ File::Status File::incrementalCrc(FwSignedSizeType &size) { status = this->read(this->m_crc_buffer, size, File::WaitType::NO_WAIT); if (OP_OK == status) { for (FwSignedSizeType i = 0; i < size && i < FW_FILE_CHUNK_SIZE; i++) { - this->m_crc = update_crc_32(this->m_crc, static_cast(this->m_crc_buffer[i])); + this->m_crc = + static_cast( + update_crc_32(this->m_crc, static_cast(this->m_crc_buffer[i])) + ); } } } diff --git a/Os/Posix/IntervalTimer.cpp b/Os/Posix/IntervalTimer.cpp index 0ba7245883..4893ee15ce 100644 --- a/Os/Posix/IntervalTimer.cpp +++ b/Os/Posix/IntervalTimer.cpp @@ -16,8 +16,8 @@ namespace Os { timespec t; PlatformIntType status = clock_gettime(CLOCK_REALTIME,&t); FW_ASSERT(status == 0,errno); - time.upper = t.tv_sec; - time.lower = t.tv_nsec; + time.upper = static_cast(t.tv_sec); + time.lower = static_cast(t.tv_nsec); } // Adapted from: http://www.gnu.org/software/libc/manual/html_node/Elapsed-Time.html diff --git a/Os/Pthreads/BufferQueueCommon.cpp b/Os/Pthreads/BufferQueueCommon.cpp index 742b1bd0d5..b9bbd772e8 100644 --- a/Os/Pthreads/BufferQueueCommon.cpp +++ b/Os/Pthreads/BufferQueueCommon.cpp @@ -40,7 +40,7 @@ namespace Os { if (nullptr != this->m_queue) { this->finalize(); } - FW_ASSERT(nullptr == this->m_queue, reinterpret_cast(this->m_queue)); + FW_ASSERT(nullptr == this->m_queue, static_cast(reinterpret_cast(this->m_queue))); // Set member variables: this->m_msgSize = msgSize; @@ -114,7 +114,7 @@ namespace Os { } NATIVE_UINT_TYPE BufferQueue::getBufferIndex(NATIVE_INT_TYPE index) { - return (index % this->m_depth) * (sizeof(NATIVE_INT_TYPE) + this->m_msgSize); + return static_cast((index % this->m_depth) * (sizeof(NATIVE_INT_TYPE) + this->m_msgSize)); } void BufferQueue::enqueueBuffer(const U8* buffer, NATIVE_UINT_TYPE size, U8* data, NATIVE_UINT_TYPE index) { @@ -124,7 +124,7 @@ namespace Os { FW_ASSERT(ptr == dest); // Copy buffer onto queue: - index += sizeof(size); + index += static_cast(sizeof(size)); dest = &data[index]; ptr = memcpy(dest, buffer, size); FW_ASSERT(ptr == dest); @@ -147,7 +147,7 @@ namespace Os { size = storedSize; // Copy buffer from queue: - index += sizeof(size); + index += static_cast(sizeof(size)); source = &data[index]; ptr = memcpy(buffer, source, storedSize); FW_ASSERT(ptr == buffer); diff --git a/Os/ValidateFileCommon.cpp b/Os/ValidateFileCommon.cpp index 9006e39076..673a1b3c43 100644 --- a/Os/ValidateFileCommon.cpp +++ b/Os/ValidateFileCommon.cpp @@ -44,7 +44,7 @@ namespace Os { break; } // Add chunk to hash calculation: - hash.update(&buffer, size); + hash.update(&buffer, static_cast(size)); cnt++; } file.close(); @@ -85,7 +85,7 @@ namespace Os { hashFile.close(); // Return the hash buffer: - Utils::HashBuffer savedHashBuffer(savedHash, size); + Utils::HashBuffer savedHashBuffer(savedHash, static_cast(size)); hashBuffer = savedHashBuffer; return status; diff --git a/Svc/ActiveTextLogger/LogFile.cpp b/Svc/ActiveTextLogger/LogFile.cpp index cb4cfb34b2..d53bb30664 100644 --- a/Svc/ActiveTextLogger/LogFile.cpp +++ b/Svc/ActiveTextLogger/LogFile.cpp @@ -70,7 +70,7 @@ namespace Svc { // Only return a good status if the write was valid status = (writeSize > 0); - this->m_currentFileSize += writeSize; + this->m_currentFileSize += static_cast(writeSize); } } diff --git a/Svc/BufferAccumulator/BufferAccumulator.cpp b/Svc/BufferAccumulator/BufferAccumulator.cpp index ab8a28049e..a2b744583c 100644 --- a/Svc/BufferAccumulator/BufferAccumulator.cpp +++ b/Svc/BufferAccumulator/BufferAccumulator.cpp @@ -56,7 +56,7 @@ void BufferAccumulator ::allocateQueue( ) { this->m_allocatorId = identifier; - NATIVE_UINT_TYPE memSize = sizeof(Fw::Buffer) * maxNumBuffers; + NATIVE_UINT_TYPE memSize = static_cast(sizeof(Fw::Buffer) * maxNumBuffers); bool recoverable = false; this->m_bufferMemory = static_cast( allocator.allocate(identifier, memSize, recoverable)); diff --git a/Svc/BufferLogger/BufferLoggerFile.cpp b/Svc/BufferLogger/BufferLoggerFile.cpp index 2a5c290651..997430f78e 100644 --- a/Svc/BufferLogger/BufferLoggerFile.cpp +++ b/Svc/BufferLogger/BufferLoggerFile.cpp @@ -212,7 +212,7 @@ namespace Svc { else { Fw::LogStringArg string(this->m_name.toChar()); - this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, size, length, string); + this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, static_cast(size), length, string); status = false; } return status; diff --git a/Svc/BufferManager/BufferManagerComponentImpl.cpp b/Svc/BufferManager/BufferManagerComponentImpl.cpp index 71952f2078..4f3f7203c0 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.cpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.cpp @@ -209,7 +209,8 @@ namespace Svc { U8* const CURR_PTR = bufferMem; U8* const END_PTR = static_cast(memory) + memorySize; FW_ASSERT(CURR_PTR == END_PTR, - reinterpret_cast(CURR_PTR), reinterpret_cast(END_PTR)); + static_cast(reinterpret_cast(CURR_PTR)), + static_cast(reinterpret_cast(END_PTR))); // secondary init verification FW_ASSERT(currStruct == this->m_numStructs,currStruct,this->m_numStructs); // indicate setup is done diff --git a/Svc/CmdSequencer/FPrimeSequence.cpp b/Svc/CmdSequencer/FPrimeSequence.cpp index 631bd8f1e5..4c8dff10f0 100644 --- a/Svc/CmdSequencer/FPrimeSequence.cpp +++ b/Svc/CmdSequencer/FPrimeSequence.cpp @@ -35,7 +35,7 @@ namespace Svc { { FW_ASSERT(buffer); for(NATIVE_UINT_TYPE index = 0; index < bufferSize; index++) { - this->m_computed = update_crc_32(this->m_computed, buffer[index]); + this->m_computed = static_cast(update_crc_32(this->m_computed, buffer[index])); } } @@ -164,13 +164,13 @@ namespace Svc { bool status = true; FwSignedSizeType readLen = Sequence::Header::SERIALIZED_SIZE; - FW_ASSERT(readLen >= 0, readLen); + FW_ASSERT(readLen >= 0, static_cast(readLen)); const NATIVE_UINT_TYPE capacity = buffer.getBuffCapacity(); FW_ASSERT( capacity >= static_cast(readLen), capacity, - readLen + static_cast(readLen) ); Os::File::Status fileStatus = file.read( buffer.getBuffAddr(), @@ -188,14 +188,14 @@ namespace Svc { if (status and readLen != Sequence::Header::SERIALIZED_SIZE) { this->m_events.fileInvalid( CmdSequencer_FileReadStage::READ_HEADER_SIZE, - readLen + static_cast(readLen) ); status = false; } if (status) { const Fw::SerializeStatus serializeStatus = - buffer.setBuffLen(readLen); + buffer.setBuffLen(static_cast(readLen)); FW_ASSERT( serializeStatus == Fw::FW_SERIALIZE_OK, serializeStatus @@ -280,7 +280,7 @@ namespace Svc { if (static_cast(size) != readLen) { this->m_events.fileInvalid( CmdSequencer_FileReadStage::READ_SEQ_DATA_SIZE, - readLen + static_cast(readLen) ); return false; } diff --git a/Svc/CmdSequencer/formats/AMPCSSequence.cpp b/Svc/CmdSequencer/formats/AMPCSSequence.cpp index d9957342e5..cf9c30dd98 100644 --- a/Svc/CmdSequencer/formats/AMPCSSequence.cpp +++ b/Svc/CmdSequencer/formats/AMPCSSequence.cpp @@ -202,9 +202,9 @@ namespace Svc { Fw::SerializeStatus ser_status; FwSignedSizeType readLen = sizeof(U32); - FW_ASSERT(readLen >= 0, readLen); + FW_ASSERT(readLen >= 0, static_cast(readLen)); - ser_status = buffer.setBuffLen(readLen); + ser_status = buffer.setBuffLen(static_cast(readLen)); FW_ASSERT(ser_status == Fw::FW_SERIALIZE_OK, ser_status); U8 *const addr = buffer.getBuffAddr(); @@ -290,7 +290,7 @@ namespace Svc { if (status and readLen != sizeof this->m_sequenceHeader) { this->m_events.fileInvalid( CmdSequencer_FileReadStage::READ_HEADER_SIZE, - readLen + static_cast(readLen) ); status = false; } @@ -325,11 +325,11 @@ namespace Svc { return false; } // Check read size - const NATIVE_UINT_TYPE readLenUint = readLen; + const NATIVE_UINT_TYPE readLenUint = static_cast(readLen); if (readLenUint != size) { this->m_events.fileInvalid( CmdSequencer_FileReadStage::READ_SEQ_DATA_SIZE, - readLen + static_cast(readLen) ); return false; } diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index 533d7311dd..6c651bf59b 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -125,7 +125,7 @@ namespace Svc { if( OPEN == this->m_fileMode ) { U32 projectedByteCount = this->m_byteCount + size; if( this->m_storeBufferLength ) { - projectedByteCount += sizeof(size); + projectedByteCount += static_cast(sizeof(size)); } if( projectedByteCount > this->m_maxFileSize ) { this->closeFile(); @@ -268,7 +268,7 @@ namespace Svc { if( !this->m_writeErrorOccurred ) { // throttle this event, otherwise a positive // feedback event loop can occur! Fw::LogStringArg logStringArg(this->m_fileName); - this->log_WARNING_HI_FileWriteError(ret, size, length, logStringArg); + this->log_WARNING_HI_FileWriteError(ret, static_cast(size), length, logStringArg); } this->m_writeErrorOccurred = true; return false; diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index 9f6728e635..de05ec3d72 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -84,7 +84,7 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, // Message size is determined by the type of object being stored, which in turn is determined by the // index of the entry. Those lower than COM_PORT_COUNT are Fw::ComBuffers and those larger Fw::Buffer. entry.msgSize = (entryIndex < COM_PORT_COUNT) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer); - totalAllocation += entry.depth * entry.msgSize; + totalAllocation += static_cast(entry.depth * entry.msgSize); currentPriorityIndex++; } } @@ -102,8 +102,11 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, FwSizeType allocationSize = this->m_prioritizedList[i].depth * this->m_prioritizedList[i].msgSize; FW_ASSERT(this->m_prioritizedList[i].index < static_cast(FW_NUM_ARRAY_ELEMENTS(this->m_queues)), this->m_prioritizedList[i].index); - FW_ASSERT((allocationSize + allocationOffset) <= totalAllocation, allocationSize, allocationOffset, - totalAllocation); + FW_ASSERT( + (allocationSize + allocationOffset) <= totalAllocation, + static_cast(allocationSize), + static_cast(allocationOffset), + static_cast(totalAllocation)); // Setup queue's memory allocation, depth, and message size. Setup is skipped for a depth 0 queue if (allocationSize > 0) { @@ -114,7 +117,7 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, allocationOffset += allocationSize; } // Safety check that all memory was used as expected - FW_ASSERT(allocationOffset == totalAllocation, allocationOffset, totalAllocation); + FW_ASSERT(allocationOffset == totalAllocation, static_cast(allocationOffset), totalAllocation); } // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports @@ -158,7 +161,7 @@ void ComQueue::comStatusIn_handler(const NATIVE_INT_TYPE portNum, Fw::Success& c void ComQueue::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { // Downlink the high-water marks for the Fw::ComBuffer array types ComQueueDepth comQueueDepth; - for (FwSizeType i = 0; i < comQueueDepth.SIZE; i++) { + for (U32 i = 0; i < comQueueDepth.SIZE; i++) { comQueueDepth[i] = this->m_queues[i].get_high_water_mark(); this->m_queues[i].clear_high_water_mark(); } @@ -166,7 +169,7 @@ void ComQueue::run_handler(const NATIVE_INT_TYPE portNum, U32 context) { // Downlink the high-water marks for the Fw::Buffer array types BuffQueueDepth buffQueueDepth; - for (FwSizeType i = 0; i < buffQueueDepth.SIZE; i++) { + for (U32 i = 0; i < buffQueueDepth.SIZE; i++) { buffQueueDepth[i] = this->m_queues[i + COM_PORT_COUNT].get_high_water_mark(); this->m_queues[i + COM_PORT_COUNT].clear_high_water_mark(); } @@ -182,7 +185,10 @@ void ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8 // set the appropriate throttle, and move on. Will assert if passed a message for a depth 0 queue. const FwSizeType expectedSize = (queueType == QueueType::COM_QUEUE) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer); const FwIndexType portNum = queueNum - ((queueType == QueueType::COM_QUEUE) ? 0 : COM_PORT_COUNT); - FW_ASSERT(expectedSize == size, size, expectedSize); + FW_ASSERT( + expectedSize == size, + static_cast(size), + static_cast(expectedSize)); FW_ASSERT(portNum >= 0, portNum); Fw::SerializeStatus status = this->m_queues[queueNum].enqueue(data, size); if (status == Fw::FW_SERIALIZE_NO_ROOM_LEFT && !this->m_throttle[queueNum]) { diff --git a/Svc/Deframer/Deframer.cpp b/Svc/Deframer/Deframer.cpp index 0fa2d04be3..8e1356052f 100644 --- a/Svc/Deframer/Deframer.cpp +++ b/Svc/Deframer/Deframer.cpp @@ -156,7 +156,7 @@ void Deframer ::route(Fw::Buffer& packetBuffer) { // The FileUplink component does not expect the packet // type to be there. packetBuffer.setData(packetData + sizeof(packetType)); - packetBuffer.setSize(packetSize - sizeof(packetType)); + packetBuffer.setSize(static_cast(packetSize - sizeof(packetType))); // Send the packet buffer bufferOut_out(0, packetBuffer); // Transfer ownership of the buffer to the receiver diff --git a/Svc/DpManager/DpManager.cpp b/Svc/DpManager/DpManager.cpp index 341d158166..6a36e44a41 100644 --- a/Svc/DpManager/DpManager.cpp +++ b/Svc/DpManager/DpManager.cpp @@ -77,7 +77,7 @@ Fw::Success DpManager::getBuffer(FwIndexType portNum, FwDpIdType id, FwSizeType // Set status Fw::Success status(Fw::Success::FAILURE); // Get a buffer - buffer = this->bufferGetOut_out(portNum, size); + buffer = this->bufferGetOut_out(portNum, static_cast(size)); if (buffer.isValid()) { // Buffer is valid ++this->numSuccessfulAllocations; diff --git a/Svc/FileUplink/File.cpp b/Svc/FileUplink/File.cpp index 3743295242..b50b76b17d 100644 --- a/Svc/FileUplink/File.cpp +++ b/Svc/FileUplink/File.cpp @@ -52,7 +52,7 @@ namespace Svc { return status; } - FW_ASSERT(static_cast(intLength) == length, intLength); + FW_ASSERT(static_cast(intLength) == length, static_cast(intLength)); this->m_checksum.update(data, byteOffset, length); return Os::File::OP_OK; diff --git a/Svc/FramingProtocol/FprimeProtocol.cpp b/Svc/FramingProtocol/FprimeProtocol.cpp index 459f190406..c3a626662a 100644 --- a/Svc/FramingProtocol/FprimeProtocol.cpp +++ b/Svc/FramingProtocol/FprimeProtocol.cpp @@ -23,7 +23,10 @@ void FprimeFraming::frame(const U8* const data, const U32 size, Fw::ComPacket::C FW_ASSERT(data != nullptr); FW_ASSERT(m_interface != nullptr); // Use of I32 size is explicit as ComPacketType will be specifically serialized as an I32 - FpFrameHeader::TokenType real_data_size = size + ((packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? sizeof(I32) : 0); + FpFrameHeader::TokenType real_data_size = + size + ((packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? + static_cast(sizeof(I32)) : + 0); FpFrameHeader::TokenType total = real_data_size + FpFrameHeader::SIZE + HASH_DIGEST_LENGTH; Fw::Buffer buffer = m_interface->allocate(total); Fw::SerializeBufferBase& serializer = buffer.getSerializeRepr(); @@ -33,7 +36,7 @@ void FprimeFraming::frame(const U8* const data, const U32 size, Fw::ComPacket::C Fw::SerializeStatus status; status = serializer.serialize(FpFrameHeader::START_WORD); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); - + status = serializer.serialize(real_data_size); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); @@ -42,7 +45,7 @@ void FprimeFraming::frame(const U8* const data, const U32 size, Fw::ComPacket::C status = serializer.serialize(static_cast(packet_type)); // I32 used for enum storage FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); } - + status = serializer.serialize(data, size, true); // Serialize without length FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); diff --git a/Svc/GenericHub/GenericHubComponentImpl.cpp b/Svc/GenericHub/GenericHubComponentImpl.cpp index fd606c259c..c80bf814fe 100644 --- a/Svc/GenericHub/GenericHubComponentImpl.cpp +++ b/Svc/GenericHub/GenericHubComponentImpl.cpp @@ -39,7 +39,7 @@ void GenericHubComponentImpl ::send_data(const HubType type, FW_ASSERT(data != nullptr); Fw::SerializeStatus status; // Buffer to send and a buffer used to write to it - Fw::Buffer outgoing = dataOutAllocate_out(0, size + sizeof(U32) + sizeof(U32) + sizeof(FwBuffSizeType)); + Fw::Buffer outgoing = dataOutAllocate_out(0, static_cast(size + sizeof(U32) + sizeof(U32) + sizeof(FwBuffSizeType))); Fw::SerializeBufferBase& serialize = outgoing.getSerializeRepr(); // Write data to our buffer status = serialize.serialize(static_cast(type)); @@ -86,7 +86,7 @@ void GenericHubComponentImpl ::dataIn_handler(const NATIVE_INT_TYPE portNum, Fw: // invokeSerial deserializes arguments before calling a normal invoke, this will return ownership immediately U8* rawData = fwBuffer.getData() + sizeof(U32) + sizeof(U32) + sizeof(FwBuffSizeType); - U32 rawSize = fwBuffer.getSize() - sizeof(U32) - sizeof(U32) - sizeof(FwBuffSizeType); + U32 rawSize = static_cast(fwBuffer.getSize() - sizeof(U32) - sizeof(U32) - sizeof(FwBuffSizeType)); FW_ASSERT(rawSize == static_cast(size)); if (type == HUB_TYPE_PORT) { // Com buffer representations should be copied before the call returns, so we need not "allocate" new data diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index 0e4638eb94..009f6dfc44 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -102,8 +102,11 @@ namespace Svc { // True size is supplied size plus sizeof(TOKEN_TYPE) if a packet_type other than "UNKNOWN" was supplied. // This is because if not UNKNOWN, the packet_type is serialized too. Otherwise it is assumed the PACKET_TYPE is // already the first token in the UNKNOWN typed buffer. - U32 true_size = (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? size + sizeof(TOKEN_TYPE) : size; - U32 total_size = sizeof(TOKEN_TYPE) + sizeof(TOKEN_TYPE) + true_size + sizeof(U32); + U32 true_size = + (packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? + static_cast(size + sizeof(TOKEN_TYPE)) : + static_cast(size); + U32 total_size = static_cast(sizeof(TOKEN_TYPE) + sizeof(TOKEN_TYPE) + true_size + sizeof(U32)); // Serialize data FW_ASSERT(GND_BUFFER_SIZE >= total_size, GND_BUFFER_SIZE, total_size); buffer_wrapper.serialize(START_WORD); @@ -158,8 +161,13 @@ namespace Svc { if (isConnected_fileUplinkBufferGet_OutputPort(0) && isConnected_fileDownlinkBufferSendOut_OutputPort(0)) { Fw::Buffer buffer = fileUplinkBufferGet_out(0, m_data_size); - m_in_ring.peek(buffer.getData(), m_data_size - sizeof(packet_type), HEADER_SIZE + sizeof(packet_type)); - buffer.setSize(m_data_size - sizeof(packet_type)); + + m_in_ring.peek( + buffer.getData(), + static_cast(m_data_size - sizeof(packet_type)), + HEADER_SIZE + sizeof(packet_type)); + + buffer.setSize(static_cast(m_data_size - sizeof(packet_type))); fileUplinkBufferSendOut_out(0, buffer); } break; @@ -193,11 +201,11 @@ namespace Svc { break; } // Continue with the data portion and checksum - m_in_ring.peek(checksum, HEADER_SIZE + m_data_size); + m_in_ring.peek(checksum, static_cast(HEADER_SIZE + m_data_size)); // Check checksum if (checksum == END_WORD) { routeComData(); - m_in_ring.rotate(HEADER_SIZE + m_data_size + sizeof(U32)); + m_in_ring.rotate(static_cast(HEADER_SIZE + m_data_size + sizeof(U32))); } // Failed checksum, keep looking for valid message else { diff --git a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp index acf3b58efa..fe53fa5b70 100644 --- a/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp +++ b/Svc/LinuxTimer/LinuxTimerComponentImplTimerFd.cpp @@ -36,7 +36,7 @@ namespace Svc { while (true) { unsigned long long missed; - int ret = read (fd, &missed, sizeof (missed)); + int ret = static_cast(read (fd, &missed, sizeof (missed))); if (-1 == ret) { Fw::Logger::logMsg("timer read error: %s\n", reinterpret_cast(strerror(errno))); } diff --git a/Svc/PosixTime/PosixTime.cpp b/Svc/PosixTime/PosixTime.cpp index b4ed682929..7442db5353 100644 --- a/Svc/PosixTime/PosixTime.cpp +++ b/Svc/PosixTime/PosixTime.cpp @@ -24,6 +24,6 @@ namespace Svc { ) { timespec stime; (void)clock_gettime(CLOCK_REALTIME,&stime); - time.set(TB_WORKSTATION_TIME,0, stime.tv_sec, stime.tv_nsec/1000); + time.set(TB_WORKSTATION_TIME,0, static_cast(stime.tv_sec), static_cast(stime.tv_nsec/1000)); } } diff --git a/Svc/PrmDb/PrmDbImpl.cpp b/Svc/PrmDb/PrmDbImpl.cpp index c75219266a..783cfd8851 100644 --- a/Svc/PrmDb/PrmDbImpl.cpp +++ b/Svc/PrmDb/PrmDbImpl.cpp @@ -160,12 +160,15 @@ namespace Svc { } if (writeSize != sizeof(delim)) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::DELIMITER_SIZE,numRecords,writeSize); + this->log_WARNING_HI_PrmFileWriteError( + PrmWriteError::DELIMITER_SIZE, + numRecords, + static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } // serialize record size = id field + data - U32 recordSize = sizeof(FwPrmIdType) + this->m_db[entry].val.getBuffLength(); + U32 recordSize = static_cast(sizeof(FwPrmIdType) + this->m_db[entry].val.getBuffLength()); // reset buffer buff.resetSer(); @@ -184,7 +187,10 @@ namespace Svc { } if (writeSize != sizeof(recordSize)) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::RECORD_SIZE_SIZE,numRecords,writeSize); + this->log_WARNING_HI_PrmFileWriteError( + PrmWriteError::RECORD_SIZE_SIZE, + numRecords, + static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } @@ -209,7 +215,10 @@ namespace Svc { } if (writeSize != static_cast(buff.getBuffLength())) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_ID_SIZE,numRecords,writeSize); + this->log_WARNING_HI_PrmFileWriteError( + PrmWriteError::PARAMETER_ID_SIZE, + numRecords, + static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } @@ -226,7 +235,10 @@ namespace Svc { } if (writeSize != static_cast(this->m_db[entry].val.getBuffLength())) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_VALUE_SIZE,numRecords,writeSize); + this->log_WARNING_HI_PrmFileWriteError( + PrmWriteError::PARAMETER_VALUE_SIZE, + numRecords, + static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } @@ -279,7 +291,7 @@ namespace Svc { } if (sizeof(delimiter) != readSize) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER_SIZE,recordNum,readSize); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER_SIZE,recordNum,static_cast(readSize)); return; } @@ -298,11 +310,11 @@ namespace Svc { return; } if (sizeof(recordSize) != readSize) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE_SIZE,recordNum,readSize); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE_SIZE,recordNum,static_cast(readSize)); return; } // set serialized size to read size - Fw::SerializeStatus desStat = buff.setBuffLen(readSize); + Fw::SerializeStatus desStat = buff.setBuffLen(static_cast(readSize)); // should never fail FW_ASSERT(Fw::FW_SERIALIZE_OK == desStat,static_cast(desStat)); // reset deserialization @@ -328,12 +340,12 @@ namespace Svc { return; } if (sizeof(parameterId) != static_cast(readSize)) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_ID_SIZE,recordNum,readSize); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_ID_SIZE,recordNum,static_cast(readSize)); return; } // set serialized size to read parameter ID - desStat = buff.setBuffLen(readSize); + desStat = buff.setBuffLen(static_cast(readSize)); // should never fail FW_ASSERT(Fw::FW_SERIALIZE_OK == desStat,static_cast(desStat)); // reset deserialization @@ -354,12 +366,12 @@ namespace Svc { return; } if (static_cast(readSize) != recordSize-sizeof(parameterId)) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_VALUE_SIZE,recordNum,readSize); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_VALUE_SIZE,recordNum,static_cast(readSize)); return; } // set serialized size to read size - desStat = this->m_db[entry].val.setBuffLen(readSize); + desStat = this->m_db[entry].val.setBuffLen(static_cast(readSize)); // should never fail FW_ASSERT(Fw::FW_SERIALIZE_OK == desStat,static_cast(desStat)); recordNum++; diff --git a/Utils/CRCChecker.cpp b/Utils/CRCChecker.cpp index eab300d86e..4698aee730 100644 --- a/Utils/CRCChecker.cpp +++ b/Utils/CRCChecker.cpp @@ -66,7 +66,7 @@ namespace Utils { return FAILED_FILE_READ; } - hash.update(block_data, bytes_to_read); + hash.update(block_data, static_cast(bytes_to_read)); } remaining_bytes = int_file_size % CRC_FILE_READ_BLOCK; @@ -80,7 +80,7 @@ namespace Utils { return FAILED_FILE_READ; } - hash.update(block_data, remaining_bytes); + hash.update(block_data, static_cast(remaining_bytes)); } // close file @@ -192,10 +192,10 @@ namespace Utils { return FAILED_FILE_READ; } - hash.update(block_data, bytes_to_read); + hash.update(block_data, static_cast(bytes_to_read)); } - remaining_bytes = int_file_size % CRC_FILE_READ_BLOCK; + remaining_bytes = static_cast(int_file_size % CRC_FILE_READ_BLOCK); bytes_to_read = remaining_bytes; if(remaining_bytes > 0) { diff --git a/Utils/Hash/libcrc/CRC32.cpp b/Utils/Hash/libcrc/CRC32.cpp index 0e826c4586..81e94ada5d 100644 --- a/Utils/Hash/libcrc/CRC32.cpp +++ b/Utils/Hash/libcrc/CRC32.cpp @@ -34,7 +34,7 @@ namespace Utils { char c; for(int index = 0; index < len; index++) { c = static_cast(data)[index]; - local_hash_handle = update_crc_32(local_hash_handle, c); + local_hash_handle = static_cast(update_crc_32(local_hash_handle, c)); } HashBuffer bufferOut; // For CRC32 we need to return the one's complement of the result: @@ -56,7 +56,7 @@ namespace Utils { char c; for(int index = 0; index < len; index++) { c = static_cast(data)[index]; - this->hash_handle = update_crc_32(this->hash_handle, c); + this->hash_handle = static_cast(update_crc_32(this->hash_handle, c)); } } diff --git a/Utils/Types/Queue.cpp b/Utils/Types/Queue.cpp index 9e5e25346f..1a32400de6 100644 --- a/Utils/Types/Queue.cpp +++ b/Utils/Types/Queue.cpp @@ -17,30 +17,40 @@ Queue::Queue() : m_internal(), m_message_size(0) {} void Queue::setup(U8* const storage, const FwSizeType storage_size, const FwSizeType depth, const FwSizeType message_size) { // Ensure that enough storage was supplied const FwSizeType total_needed_size = depth * message_size; - FW_ASSERT(storage_size >= total_needed_size, storage_size, depth, message_size); - m_internal.setup(storage, total_needed_size); + FW_ASSERT( + storage_size >= total_needed_size, + static_cast(storage_size), + static_cast(depth), + static_cast(message_size)); + m_internal.setup(storage, static_cast(total_needed_size)); m_message_size = message_size; } Fw::SerializeStatus Queue::enqueue(const U8* const message, const FwSizeType size) { - FW_ASSERT(m_message_size > 0, m_message_size); // Ensure initialization - FW_ASSERT(m_message_size == size, size, m_message_size); // Message size is as expected + FW_ASSERT(m_message_size > 0, static_cast(m_message_size)); // Ensure initialization + FW_ASSERT( + 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)); } Fw::SerializeStatus Queue::dequeue(U8* const message, const FwSizeType size) { FW_ASSERT(m_message_size > 0); // Ensure initialization - FW_ASSERT(m_message_size <= size, size, m_message_size); // Sufficient storage space for read message + FW_ASSERT( + 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); if (result != Fw::FW_SERIALIZE_OK) { return result; } - return m_internal.rotate(m_message_size); + return m_internal.rotate(static_cast(m_message_size)); } NATIVE_UINT_TYPE Queue::get_high_water_mark() const { - FW_ASSERT(m_message_size > 0, m_message_size); - return m_internal.get_high_water_mark() / m_message_size; + FW_ASSERT(m_message_size > 0, static_cast(m_message_size)); + return static_cast(m_internal.get_high_water_mark() / m_message_size); } void Queue::clear_high_water_mark() { @@ -48,8 +58,8 @@ void Queue::clear_high_water_mark() { } NATIVE_UINT_TYPE Queue::getQueueSize() const { - FW_ASSERT(m_message_size > 0, m_message_size); - return m_internal.get_allocated_size()/m_message_size; + FW_ASSERT(m_message_size > 0, static_cast(m_message_size)); + return static_cast(m_internal.get_allocated_size() / m_message_size); } From ebeb0de714f0fcb6ec943aab00d14bfb768e7ad8 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Thu, 28 Mar 2024 11:20:00 +0100 Subject: [PATCH 02/21] Fix conversion warnings from CI --- Os/Posix/File.cpp | 5 ++++- Os/Posix/Task.cpp | 4 ++-- Os/test/ut/file/SyntheticFileSystem.cpp | 16 ++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Os/Posix/File.cpp b/Os/Posix/File.cpp index 658cec466f..159f20dc84 100644 --- a/Os/Posix/File.cpp +++ b/Os/Posix/File.cpp @@ -206,7 +206,10 @@ PosixFile::Status PosixFile::read(U8* buffer, FwSignedSizeType &size, PosixFile: for (FwSignedSizeType i = 0; i < maximum && accumulated < size; i++) { // char* for some posix implementations - ssize_t read_size = ::read(this->m_handle.m_file_descriptor, reinterpret_cast(&buffer[accumulated]), size - accumulated); + ssize_t read_size = static_cast(::read( + this->m_handle.m_file_descriptor, + reinterpret_cast(&buffer[accumulated]), + size - accumulated)); // Non-interrupt error if (PosixFileHandle::ERROR_RETURN_VALUE == read_size) { PlatformIntType errno_store = errno; diff --git a/Os/Posix/Task.cpp b/Os/Posix/Task.cpp index a9d40e8969..92562e4df8 100644 --- a/Os/Posix/Task.cpp +++ b/Os/Posix/Task.cpp @@ -11,7 +11,7 @@ #include #include -#ifdef TGT_OS_TYPE_LINUX +#ifdef TGT_OS_TYPE_LINUX #include #endif @@ -53,7 +53,7 @@ namespace Os { // Check the stack if (stack != Task::TASK_DEFAULT and stack < PTHREAD_STACK_MIN) { Fw::Logger::logMsg("[WARNING] Stack size %d too small, setting to minimum of %d\n", stack, PTHREAD_STACK_MIN); - stack = PTHREAD_STACK_MIN; + stack = static_cast(PTHREAD_STACK_MIN); } // Check CPU affinity if (!expect_perm and affinity != Task::TASK_DEFAULT) { diff --git a/Os/test/ut/file/SyntheticFileSystem.cpp b/Os/test/ut/file/SyntheticFileSystem.cpp index 171b3fbb50..131c5d7dd1 100644 --- a/Os/test/ut/file/SyntheticFileSystem.cpp +++ b/Os/test/ut/file/SyntheticFileSystem.cpp @@ -105,15 +105,15 @@ Os::File::Status SyntheticFile::read(U8* buffer, FwSignedSizeType& size, WaitTyp } std::vector output; FwSignedSizeType original_pointer = this->m_data->m_pointer; - FwSignedSizeType original_size = this->m_data->m_data.size(); + FwSignedSizeType original_size = static_cast(this->m_data->m_data.size()); // Check expected read bytes FwSignedSizeType i = 0; for (i = 0; i < size; i++, this->m_data->m_pointer++) { // End of file - if (this->m_data->m_pointer >= static_cast(this->m_data->m_data.size())) { + if (this->m_data->m_pointer >= static_cast(this->m_data->m_data.size())) { break; } - buffer[i] = this->m_data->m_data.at(this->m_data->m_pointer); + buffer[i] = this->m_data->m_data.at(static_cast(this->m_data->m_pointer)); } size = i; // Checks on the shadow data to ensure consistency @@ -138,12 +138,12 @@ Os::File::Status SyntheticFile::write(const U8* buffer, FwSignedSizeType& size, return Os::File::Status::INVALID_MODE; } FwSignedSizeType original_position = this->m_data->m_pointer; - FwSignedSizeType original_size = this->m_data->m_data.size(); + FwSignedSizeType original_size = static_cast(this->m_data->m_data.size()); const U8* write_data = reinterpret_cast(buffer); // Appends seek to end before writing if (Os::File::Mode::OPEN_APPEND == this->m_data->m_mode) { - this->m_data->m_pointer = this->m_data->m_data.size(); + this->m_data->m_pointer = static_cast(this->m_data->m_data.size()); } // First add in zeros to account for a pointer past the end of the file @@ -157,14 +157,14 @@ Os::File::Status SyntheticFile::write(const U8* buffer, FwSignedSizeType& size, static_cast((Os::File::Mode::OPEN_APPEND == this->m_data->m_mode) ? original_size : FW_MAX(original_position, original_size))); FwSignedSizeType pre_write_position = this->m_data->m_pointer; - FwSignedSizeType pre_write_size = this->m_data->m_data.size(); + FwSignedSizeType pre_write_size = static_cast(this->m_data->m_data.size()); // Next write data FwSignedSizeType i = 0; for (i = 0; i < size; i++, this->m_data->m_pointer++) { // Overwrite case if (static_cast(this->m_data->m_pointer) < this->m_data->m_data.size()) { - this->m_data->m_data.at(this->m_data->m_pointer) = write_data[i]; + this->m_data->m_data.at(static_cast(this->m_data->m_pointer)) = write_data[i]; } // Append case else { @@ -212,7 +212,7 @@ Os::File::Status SyntheticFile::preallocate(const FwSignedSizeType offset, const } else if (Os::File::Mode::OPEN_READ == this->m_data->m_mode) { status = Os::File::Status::INVALID_MODE; } else { - const FwSignedSizeType original_size = this->m_data->m_data.size(); + const FwSignedSizeType original_size = static_cast(this->m_data->m_data.size()); const FwSignedSizeType new_length = offset + length; // Loop from existing size to new size adding zeros for (FwSignedSizeType i = static_cast(this->m_data->m_data.size()); i < new_length; i++) { From 5573b6f5f1c5b1958bde8c1ede6d43c6d6459b5a Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Thu, 28 Mar 2024 19:03:59 +0100 Subject: [PATCH 03/21] Fix static_cast in SyntheticFileSystem --- Os/test/ut/file/SyntheticFileSystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Os/test/ut/file/SyntheticFileSystem.cpp b/Os/test/ut/file/SyntheticFileSystem.cpp index 131c5d7dd1..24b8d0e503 100644 --- a/Os/test/ut/file/SyntheticFileSystem.cpp +++ b/Os/test/ut/file/SyntheticFileSystem.cpp @@ -110,7 +110,7 @@ Os::File::Status SyntheticFile::read(U8* buffer, FwSignedSizeType& size, WaitTyp FwSignedSizeType i = 0; for (i = 0; i < size; i++, this->m_data->m_pointer++) { // End of file - if (this->m_data->m_pointer >= static_cast(this->m_data->m_data.size())) { + if (this->m_data->m_pointer >= static_cast(this->m_data->m_data.size())) { break; } buffer[i] = this->m_data->m_data.at(static_cast(this->m_data->m_pointer)); @@ -164,7 +164,7 @@ Os::File::Status SyntheticFile::write(const U8* buffer, FwSignedSizeType& size, for (i = 0; i < size; i++, this->m_data->m_pointer++) { // Overwrite case if (static_cast(this->m_data->m_pointer) < this->m_data->m_data.size()) { - this->m_data->m_data.at(static_cast(this->m_data->m_pointer)) = write_data[i]; + this->m_data->m_data.at(static_cast::size_type>(this->m_data->m_pointer)) = write_data[i]; } // Append case else { From 9e6576813c8118dc4a6a9072881247592105b946 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Fri, 29 Mar 2024 00:13:28 +0100 Subject: [PATCH 04/21] Fix read and write argument conversion --- Os/Posix/File.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Os/Posix/File.cpp b/Os/Posix/File.cpp index 159f20dc84..7b92691687 100644 --- a/Os/Posix/File.cpp +++ b/Os/Posix/File.cpp @@ -206,10 +206,10 @@ PosixFile::Status PosixFile::read(U8* buffer, FwSignedSizeType &size, PosixFile: for (FwSignedSizeType i = 0; i < maximum && accumulated < size; i++) { // char* for some posix implementations - ssize_t read_size = static_cast(::read( + ssize_t read_size = ::read( this->m_handle.m_file_descriptor, reinterpret_cast(&buffer[accumulated]), - size - accumulated)); + static_cast(size - accumulated)); // Non-interrupt error if (PosixFileHandle::ERROR_RETURN_VALUE == read_size) { PlatformIntType errno_store = errno; @@ -242,7 +242,7 @@ PosixFile::Status PosixFile::write(const U8* buffer, FwSignedSizeType &size, Pos for (FwSignedSizeType i = 0; i < maximum && accumulated < size; i++) { // char* for some posix implementations - ssize_t write_size = ::write(this->m_handle.m_file_descriptor, reinterpret_cast(&buffer[accumulated]), size - accumulated); + ssize_t write_size = ::write(this->m_handle.m_file_descriptor, reinterpret_cast(&buffer[accumulated]), static_cast(size - accumulated)); // Non-interrupt error if (PosixFileHandle::ERROR_RETURN_VALUE == write_size) { PlatformIntType errno_store = errno; From 3465a16c2134b2a708028f4c759fad4cd8abb8ef Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Fri, 5 Apr 2024 23:00:53 +0200 Subject: [PATCH 05/21] Fix new CI issues --- Fw/Types/Assert.cpp | 19 ++++++++++++------- Svc/DpWriter/DpWriter.cpp | 19 ++++++++++++++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Fw/Types/Assert.cpp b/Fw/Types/Assert.cpp index be7a0a84ed..f0c71ba79b 100644 --- a/Fw/Types/Assert.cpp +++ b/Fw/Types/Assert.cpp @@ -34,12 +34,17 @@ namespace Fw { switch (numArgs) { case 0: - (void) snprintf(destBuffer, buffSize, fileIdFs, file, lineNo); + (void) snprintf( + destBuffer, + static_cast(buffSize), + fileIdFs, + file, + lineNo); break; case 1: (void) snprintf( destBuffer, - buffSize, + static_cast(buffSize), fileIdFs " %" PRI_FwAssertArgType, file, lineNo, @@ -49,7 +54,7 @@ namespace Fw { case 2: (void) snprintf( destBuffer, - buffSize, + static_cast(buffSize), fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, @@ -59,7 +64,7 @@ namespace Fw { case 3: (void) snprintf( destBuffer, - buffSize, + static_cast(buffSize), fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, @@ -70,7 +75,7 @@ namespace Fw { case 4: (void) snprintf( destBuffer, - buffSize, + static_cast(buffSize), fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, @@ -80,7 +85,7 @@ namespace Fw { case 5: (void) snprintf( destBuffer, - buffSize, + static_cast(buffSize), fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, @@ -92,7 +97,7 @@ namespace Fw { case 6: (void) snprintf( destBuffer, - buffSize, + static_cast(buffSize), fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, diff --git a/Svc/DpWriter/DpWriter.cpp b/Svc/DpWriter/DpWriter.cpp index 6bb929d761..429dbb3985 100644 --- a/Svc/DpWriter/DpWriter.cpp +++ b/Svc/DpWriter/DpWriter.cpp @@ -41,7 +41,10 @@ void DpWriter::bufferSendIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& b const FwSizeType bufferSize = buffer.getSize(); if (status == Fw::Success::SUCCESS) { if (bufferSize < Fw::DpContainer::MIN_PACKET_SIZE) { - this->log_WARNING_HI_BufferTooSmallForPacket(bufferSize, Fw::DpContainer::MIN_PACKET_SIZE); + this->log_WARNING_HI_BufferTooSmallForPacket( + static_cast(bufferSize), + Fw::DpContainer::MIN_PACKET_SIZE); + status = Fw::Success::FAILURE; } } @@ -53,8 +56,10 @@ void DpWriter::bufferSendIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& b Utils::HashBuffer computedHash; status = container.checkHeaderHash(storedHash, computedHash); if (status != Fw::Success::SUCCESS) { - this->log_WARNING_HI_InvalidHeaderHash(bufferSize, storedHash.asBigEndianU32(), - computedHash.asBigEndianU32()); + this->log_WARNING_HI_InvalidHeaderHash( + static_cast(bufferSize), + storedHash.asBigEndianU32(), + computedHash.asBigEndianU32()); } } // Deserialize the packet header @@ -65,7 +70,9 @@ void DpWriter::bufferSendIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& b if (status == Fw::Success::SUCCESS) { const FwSizeType packetSize = container.getPacketSize(); if (bufferSize < packetSize) { - this->log_WARNING_HI_BufferTooSmallForData(bufferSize, packetSize); + this->log_WARNING_HI_BufferTooSmallForData( + static_cast(bufferSize), + static_cast(packetSize)); status = Fw::Success::FAILURE; } } @@ -188,7 +195,9 @@ Fw::Success::T DpWriter::writeFile(const Fw::DpContainer& container, if ((fileStatus == Os::File::OP_OK) and (writeSize == static_cast(fileSize))) { // If the write status is success, and the number of bytes written // is the expected number, then record the success - this->log_ACTIVITY_LO_FileWritten(writeSize, fileName.toChar()); + this->log_ACTIVITY_LO_FileWritten( + static_cast(writeSize), + fileName.toChar()); } else { // Otherwise record the failure this->log_WARNING_HI_FileWriteError(static_cast(fileStatus), static_cast(writeSize), From bd774304bc5aff317dd3a4d8c0633ef728212272 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Mon, 8 Apr 2024 22:18:14 +0000 Subject: [PATCH 06/21] Fix errors from clang-tidy --- CFDP/Checksum/Checksum.cpp | 2 +- Drv/Ip/IpSocket.cpp | 7 +-- Drv/Ip/SocketReadTask.cpp | 14 ++++-- Fw/Comp/ActiveComponentBase.cpp | 2 +- Fw/Comp/PassiveComponentBase.cpp | 2 +- Fw/Comp/QueuedComponentBase.cpp | 2 +- Fw/Log/LogBuffer.cpp | 6 +-- Fw/Log/LogString.cpp | 2 +- Fw/Logger/LogAssert.cpp | 49 ++++++++++++++++--- Fw/Obj/ObjBase.cpp | 2 +- Fw/Obj/SimpleObjRegistry.cpp | 8 +-- Fw/Port/InputPortBase.cpp | 4 +- Fw/Port/InputSerializePort.cpp | 2 +- Fw/Port/OutputPortBase.cpp | 2 +- Fw/Port/OutputSerializePort.cpp | 2 +- Fw/Port/PortBase.cpp | 2 +- Fw/SerializableFile/SerializableFile.cpp | 2 +- Fw/Test/UnitTestAssert.hpp | 2 +- Fw/Time/Time.cpp | 2 +- Fw/Tlm/TlmString.cpp | 2 +- Fw/Types/PolyType.cpp | 2 +- Fw/Types/Serializable.cpp | 5 +- Fw/Types/StringType.cpp | 8 +-- Os/IPCQueueCommon.cpp | 8 +-- Os/Linux/Directory.cpp | 2 +- Os/Linux/SystemResources.cpp | 2 +- Os/Posix/IPCQueue.cpp | 15 ++++-- Os/Posix/LocklessQueue.cpp | 4 +- Os/Posix/Task.cpp | 16 +++--- Os/Pthreads/BufferQueueCommon.cpp | 2 +- Os/Pthreads/MaxHeap/MaxHeap.cpp | 34 ++++++------- Os/Pthreads/PriorityBufferQueue.cpp | 16 ++++-- Os/Pthreads/Queue.cpp | 14 +++--- Os/QueueCommon.cpp | 6 +-- Svc/ActiveRateGroup/ActiveRateGroup.cpp | 2 +- .../AssertFatalAdapterComponentImpl.cpp | 49 ++++++++++++++++--- Svc/BufferAccumulator/BufferAccumulator.cpp | 2 +- Utils/TokenBucket.cpp | 6 +-- Utils/Types/CircularBuffer.cpp | 14 +++--- 39 files changed, 212 insertions(+), 111 deletions(-) diff --git a/CFDP/Checksum/Checksum.cpp b/CFDP/Checksum/Checksum.cpp index 44adaec379..41b435f01b 100644 --- a/CFDP/Checksum/Checksum.cpp +++ b/CFDP/Checksum/Checksum.cpp @@ -136,7 +136,7 @@ namespace CFDP { ) { FW_ASSERT(offset < 4); - const U32 addend = byte << (8*(3-offset)); + const U32 addend = static_cast(byte) << (8*(3-offset)); this->m_value += addend; } diff --git a/Drv/Ip/IpSocket.cpp b/Drv/Ip/IpSocket.cpp index d589c77714..0d3f8af9d3 100644 --- a/Drv/Ip/IpSocket.cpp +++ b/Drv/Ip/IpSocket.cpp @@ -51,7 +51,7 @@ IpSocket::IpSocket() : m_fd(-1), m_timeoutSeconds(0), m_timeoutMicroseconds(0), } SocketIpStatus IpSocket::configure(const char* const hostname, const U16 port, const U32 timeout_seconds, const U32 timeout_microseconds) { - FW_ASSERT(timeout_microseconds < 1000000, timeout_microseconds); + FW_ASSERT(timeout_microseconds < 1000000, static_cast(timeout_microseconds)); FW_ASSERT(port != 0, port); this->m_timeoutSeconds = timeout_seconds; this->m_timeoutMicroseconds = timeout_microseconds; @@ -182,13 +182,14 @@ SocketIpStatus IpSocket::send(const U8* const data, const U32 size) { return SOCK_SEND_ERROR; } FW_ASSERT(sent > 0, sent); - total += sent; + total += static_cast(sent); } // Failed to retry enough to send all data if (total < size) { return SOCK_INTERRUPTED_TRY_AGAIN; } - FW_ASSERT(total == size, total, size); // Ensure we sent everything + // Ensure we sent everything + FW_ASSERT(total == size, static_cast(total), static_cast(size)); return SOCK_SUCCESS; } diff --git a/Drv/Ip/SocketReadTask.cpp b/Drv/Ip/SocketReadTask.cpp index 70adb50f64..52a405020e 100644 --- a/Drv/Ip/SocketReadTask.cpp +++ b/Drv/Ip/SocketReadTask.cpp @@ -74,7 +74,10 @@ void SocketReadTask::readTask(void* pointer) { // Open a network connection if it has not already been open if ((not self->getSocketHandler().isStarted()) and (not self->m_stop) and ((status = self->startup()) != SOCK_SUCCESS)) { - Fw::Logger::logMsg("[WARNING] Failed to open port with status %d and errno %d\n", status, errno); + Fw::Logger::logMsg( + "[WARNING] Failed to open port with status %d and errno %d\n", + static_cast(status), + static_cast(errno)); (void) Os::Task::delay(SOCKET_RETRY_INTERVAL_MS); continue; } @@ -82,7 +85,10 @@ void SocketReadTask::readTask(void* pointer) { // Open a network connection if it has not already been open if ((not self->getSocketHandler().isOpened()) and (not self->m_stop) and ((status = self->open()) != SOCK_SUCCESS)) { - Fw::Logger::logMsg("[WARNING] Failed to open port with status %d and errno %d\n", status, errno); + Fw::Logger::logMsg( + "[WARNING] Failed to open port with status %d and errno %d\n", + static_cast(status), + static_cast(errno)); (void) Os::Task::delay(SOCKET_RETRY_INTERVAL_MS); continue; } @@ -96,7 +102,9 @@ void SocketReadTask::readTask(void* pointer) { size = (size >= 0) ? size : MAXIMUM_SIZE; // Handle max U32 edge case status = self->getSocketHandler().recv(data, size); if ((status != SOCK_SUCCESS) && (status != SOCK_INTERRUPTED_TRY_AGAIN)) { - Fw::Logger::logMsg("[WARNING] Failed to recv from port with status %d and errno %d\n", status, errno); + Fw::Logger::logMsg("[WARNING] Failed to recv from port with status %d and errno %d\n", + static_cast(status), + static_cast(errno)); self->getSocketHandler().close(); buffer.setSize(0); } else { diff --git a/Fw/Comp/ActiveComponentBase.cpp b/Fw/Comp/ActiveComponentBase.cpp index fe96ad6136..bc153bb18a 100644 --- a/Fw/Comp/ActiveComponentBase.cpp +++ b/Fw/Comp/ActiveComponentBase.cpp @@ -46,7 +46,7 @@ namespace Fw { void ActiveComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) { FW_ASSERT(size > 0); FW_ASSERT(buffer != nullptr); - PlatformIntType status = snprintf(buffer, size, "ActComp: %s", this->m_objName.toChar()); + PlatformIntType status = snprintf(buffer, static_cast(size), "ActComp: %s", this->m_objName.toChar()); if (status < 0) { buffer[0] = 0; } diff --git a/Fw/Comp/PassiveComponentBase.cpp b/Fw/Comp/PassiveComponentBase.cpp index 65cc3ca9ad..1e3b504c67 100644 --- a/Fw/Comp/PassiveComponentBase.cpp +++ b/Fw/Comp/PassiveComponentBase.cpp @@ -13,7 +13,7 @@ namespace Fw { void PassiveComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) { FW_ASSERT(size > 0); FW_ASSERT(buffer != nullptr); - PlatformIntType status = snprintf(buffer, size, "Comp: %s", this->m_objName.toChar()); + PlatformIntType status = snprintf(buffer, static_cast(size), "Comp: %s", this->m_objName.toChar()); if (status < 0) { buffer[0] = 0; } diff --git a/Fw/Comp/QueuedComponentBase.cpp b/Fw/Comp/QueuedComponentBase.cpp index da94dc6ef4..22673e9974 100644 --- a/Fw/Comp/QueuedComponentBase.cpp +++ b/Fw/Comp/QueuedComponentBase.cpp @@ -23,7 +23,7 @@ namespace Fw { void QueuedComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) { FW_ASSERT(size > 0); FW_ASSERT(buffer != nullptr); - PlatformIntType status = snprintf(buffer, size, "QueueComp: %s", this->m_objName.toChar()); + PlatformIntType status = snprintf(buffer, static_cast(size), "QueueComp: %s", this->m_objName.toChar()); if (status < 0) { buffer[0] = 0; } diff --git a/Fw/Log/LogBuffer.cpp b/Fw/Log/LogBuffer.cpp index 0a3b600f16..58683d5cb1 100644 --- a/Fw/Log/LogBuffer.cpp +++ b/Fw/Log/LogBuffer.cpp @@ -5,7 +5,7 @@ namespace Fw { LogBuffer::LogBuffer(const U8 *args, NATIVE_UINT_TYPE size) { SerializeStatus stat = SerializeBufferBase::setBuff(args,size); - FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); + FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } LogBuffer::LogBuffer() { @@ -16,7 +16,7 @@ namespace Fw { LogBuffer::LogBuffer(const LogBuffer& other) : Fw::SerializeBufferBase() { SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength()); - FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); + FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); } LogBuffer& LogBuffer::operator=(const LogBuffer& other) { @@ -25,7 +25,7 @@ namespace Fw { } SerializeStatus stat = SerializeBufferBase::setBuff(other.m_bufferData,other.getBuffLength()); - FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast(stat)); + FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast(stat)); return *this; } diff --git a/Fw/Log/LogString.cpp b/Fw/Log/LogString.cpp index 67c44e8277..6b4ca14e2c 100644 --- a/Fw/Log/LogString.cpp +++ b/Fw/Log/LogString.cpp @@ -59,7 +59,7 @@ namespace Fw { } SerializeStatus LogStringArg::serialize(SerializeBufferBase& buffer, NATIVE_UINT_TYPE maxLength) const { - NATIVE_INT_TYPE len = FW_MIN(maxLength,this->length()); + NATIVE_UINT_TYPE len = FW_MIN(maxLength, static_cast(this->length())); #if FW_AMPCS_COMPATIBLE // serialize 8-bit size with null terminator removed U8 strSize = len - 1; diff --git a/Fw/Logger/LogAssert.cpp b/Fw/Logger/LogAssert.cpp index b7ea746d97..13ddb6fd47 100644 --- a/Fw/Logger/LogAssert.cpp +++ b/Fw/Logger/LogAssert.cpp @@ -46,22 +46,59 @@ namespace Fw { // Assumption is that file (when string) goes back to static macro in the code and will persist switch (numArgs) { case 0: - Fw::Logger::logMsg(fileIdFs,ASSERT_CAST(file),lineNo,0,0,0,0); + Fw::Logger::logMsg( + fileIdFs, + ASSERT_CAST(file), + lineNo, + 0, + 0, + 0, + 0); break; case 1: - Fw::Logger::logMsg(fileIdFs " %d\n",ASSERT_CAST(file),lineNo,arg1,0,0,0); + Fw::Logger::logMsg( + fileIdFs " %d\n", + ASSERT_CAST(file),lineNo, + static_cast(arg1), + 0, + 0, + 0); break; case 2: - Fw::Logger::logMsg(fileIdFs " %d %d\n",ASSERT_CAST(file),lineNo,arg1,arg2,0,0); + Fw::Logger::logMsg( + fileIdFs " %d %d\n", + ASSERT_CAST(file),lineNo, + static_cast(arg1), + static_cast(arg2), + 0, + 0); break; case 3: - Fw::Logger::logMsg(fileIdFs " %d %d %d\n",ASSERT_CAST(file),lineNo,arg1,arg2,arg3,0); + Fw::Logger::logMsg( + fileIdFs " %d %d %d\n", + ASSERT_CAST(file),lineNo, + static_cast(arg1), + static_cast(arg2), + static_cast(arg3), + 0); break; case 4: - Fw::Logger::logMsg(fileIdFs " %d %d %d %d\n",ASSERT_CAST(file),lineNo,arg1,arg2,arg3,arg4); + Fw::Logger::logMsg( + fileIdFs " %d %d %d %d\n", + ASSERT_CAST(file),lineNo, + static_cast(arg1), + static_cast(arg2), + static_cast(arg3), + static_cast(arg4)); break; default: // can't fit remainder of arguments in log message - Fw::Logger::logMsg(fileIdFs " %d %d %d %d +\n",ASSERT_CAST(file),lineNo,arg1,arg2,arg3,arg4); + Fw::Logger::logMsg( + fileIdFs " %d %d %d %d +\n", + ASSERT_CAST(file),lineNo, + static_cast(arg1), + static_cast(arg2), + static_cast(arg3), + static_cast(arg4)); break; } diff --git a/Fw/Obj/ObjBase.cpp b/Fw/Obj/ObjBase.cpp index 494f225512..161e047129 100644 --- a/Fw/Obj/ObjBase.cpp +++ b/Fw/Obj/ObjBase.cpp @@ -48,7 +48,7 @@ namespace Fw { void ObjBase::toString(char* str, NATIVE_INT_TYPE size) { FW_ASSERT(size > 0); FW_ASSERT(str != nullptr); - PlatformIntType status = snprintf(str, size, "Obj: %s", this->m_objName.toChar()); + PlatformIntType status = snprintf(str, static_cast(size), "Obj: %s", this->m_objName.toChar()); if (status < 0) { str[0] = 0; } diff --git a/Fw/Obj/SimpleObjRegistry.cpp b/Fw/Obj/SimpleObjRegistry.cpp index 12e45102c9..e743d6ea50 100644 --- a/Fw/Obj/SimpleObjRegistry.cpp +++ b/Fw/Obj/SimpleObjRegistry.cpp @@ -28,10 +28,10 @@ namespace Fw { #if FW_OBJECT_TO_STRING == 1 char objDump[FW_OBJ_SIMPLE_REG_BUFF_SIZE]; this->m_objPtrArray[obj]->toString(objDump,sizeof(objDump)); - Fw::Logger::logMsg("Entry: %d Ptr: %p Str: %s\n", obj, + Fw::Logger::logMsg("Entry: %d Ptr: %p Str: %s\n", static_cast(obj), reinterpret_cast(this->m_objPtrArray[obj]), reinterpret_cast(objDump)); #else - Fw::Logger::logMsg("Entry: %d Ptr: %p Name: %s\n",obj, + Fw::Logger::logMsg("Entry: %d Ptr: %p Name: %s\n",static_cast(obj), reinterpret_cast(this->m_objPtrArray[obj]), reinterpret_cast(this->m_objPtrArray[obj]->getObjName())); #endif // FW_OBJECT_TO_STRING @@ -48,10 +48,10 @@ namespace Fw { if (strncmp(objName,this->m_objPtrArray[obj]->getObjName(),sizeof(objDump)) == 0) { #if FW_OBJECT_TO_STRING == 1 this->m_objPtrArray[obj]->toString(objDump,sizeof(objDump)); - Fw::Logger::logMsg("Entry: %d Ptr: %p Str: %s\n", obj, + Fw::Logger::logMsg("Entry: %d Ptr: %p Str: %s\n", static_cast(obj), reinterpret_cast(this->m_objPtrArray[obj]), reinterpret_cast(objDump)); #else - Fw::Logger::logMsg("Entry: %d Ptr: %p Name: %s\n",obj, + Fw::Logger::logMsg("Entry: %d Ptr: %p Name: %s\n",static_cast(obj), reinterpret_cast(this->m_objPtrArray[obj]), reinterpret_cast(this->m_objPtrArray[obj]->getObjName())); #endif diff --git a/Fw/Port/InputPortBase.cpp b/Fw/Port/InputPortBase.cpp index eb880b9017..f60af31df6 100644 --- a/Fw/Port/InputPortBase.cpp +++ b/Fw/Port/InputPortBase.cpp @@ -27,10 +27,10 @@ namespace Fw { #if FW_OBJECT_TO_STRING == 1 void InputPortBase::toString(char* buffer, NATIVE_INT_TYPE size) { -#if FW_OBJECT_NAMES == 1 +#if FW_OBJECT_NAMES == 1 FW_ASSERT(size > 0); FW_ASSERT(buffer != nullptr); - PlatformIntType status = snprintf(buffer, size, "InputPort: %s->%s", this->m_objName.toChar(), + PlatformIntType status = snprintf(buffer, static_cast(size), "InputPort: %s->%s", this->m_objName.toChar(), this->isConnected() ? this->m_connObj->getObjName() : "None"); if (status < 0) { buffer[0] = 0; diff --git a/Fw/Port/InputSerializePort.cpp b/Fw/Port/InputSerializePort.cpp index ca2f154675..2bb7c1a61a 100644 --- a/Fw/Port/InputSerializePort.cpp +++ b/Fw/Port/InputSerializePort.cpp @@ -40,7 +40,7 @@ namespace Fw { void InputSerializePort::toString(char* buffer, NATIVE_INT_TYPE size) { #if FW_OBJECT_NAMES == 1 FW_ASSERT(size > 0); - if (snprintf(buffer, size, "Input Serial Port: %s %s->(%s)", this->m_objName.toChar(), this->isConnected() ? "C" : "NC", + if (snprintf(buffer, static_cast(size), "Input Serial Port: %s %s->(%s)", this->m_objName.toChar(), this->isConnected() ? "C" : "NC", this->isConnected() ? this->m_connObj->getObjName() : "None") < 0) { buffer[0] = 0; } diff --git a/Fw/Port/OutputPortBase.cpp b/Fw/Port/OutputPortBase.cpp index 4018eb2d06..84a05522a7 100644 --- a/Fw/Port/OutputPortBase.cpp +++ b/Fw/Port/OutputPortBase.cpp @@ -38,7 +38,7 @@ namespace Fw { void OutputPortBase::toString(char* buffer, NATIVE_INT_TYPE size) { #if FW_OBJECT_NAMES == 1 FW_ASSERT(size > 0); - if (snprintf(buffer, size, "OutputPort: %s %s->(%s)", this->m_objName.toChar(), this->isConnected() ? "C" : "NC", + if (snprintf(buffer, static_cast(size), "OutputPort: %s %s->(%s)", this->m_objName.toChar(), this->isConnected() ? "C" : "NC", this->isConnected() ? this->m_connObj->getObjName() : "None") < 0) { buffer[0] = 0; } diff --git a/Fw/Port/OutputSerializePort.cpp b/Fw/Port/OutputSerializePort.cpp index 477784009c..a6c61b54df 100644 --- a/Fw/Port/OutputSerializePort.cpp +++ b/Fw/Port/OutputSerializePort.cpp @@ -22,7 +22,7 @@ namespace Fw { void OutputSerializePort::toString(char* buffer, NATIVE_INT_TYPE size) { #if FW_OBJECT_NAMES == 1 FW_ASSERT(size > 0); - if (snprintf(buffer, size, "Output Serial Port: %s %s->(%s)", this->m_objName.toChar(), this->isConnected() ? "C" : "NC", + if (snprintf(buffer, static_cast(size), "Output Serial Port: %s %s->(%s)", this->m_objName.toChar(), this->isConnected() ? "C" : "NC", this->isConnected() ? this->m_connObj->getObjName() : "None") < 0) { buffer[0] = 0; } diff --git a/Fw/Port/PortBase.cpp b/Fw/Port/PortBase.cpp index 4a13b47bc2..e53242c0f5 100644 --- a/Fw/Port/PortBase.cpp +++ b/Fw/Port/PortBase.cpp @@ -79,7 +79,7 @@ namespace Fw { #if FW_OBJECT_TO_STRING == 1 void PortBase::toString(char* buffer, NATIVE_INT_TYPE size) { FW_ASSERT(size > 0); - if (snprintf(buffer, size, "Port: %s %s->(%s)", this->m_objName.toChar(), this->m_connObj ? "C" : "NC", + if (snprintf(buffer, static_cast(size), "Port: %s %s->(%s)", this->m_objName.toChar(), this->m_connObj ? "C" : "NC", this->m_connObj ? this->m_connObj->getObjName() : "None") < 0) { buffer[0] = 0; } diff --git a/Fw/SerializableFile/SerializableFile.cpp b/Fw/SerializableFile/SerializableFile.cpp index 9d469a3ca2..35e79b3f62 100644 --- a/Fw/SerializableFile/SerializableFile.cpp +++ b/Fw/SerializableFile/SerializableFile.cpp @@ -23,7 +23,7 @@ namespace Fw { m_buffer(static_cast(this->m_allocator->allocate(0, m_actualSize, m_recoverable)), m_actualSize) { // assert if allocator returns smaller size - FW_ASSERT(maxSerializedSize == m_actualSize,maxSerializedSize,m_actualSize); + FW_ASSERT(maxSerializedSize == m_actualSize, static_cast(maxSerializedSize), static_cast(m_actualSize)); FW_ASSERT(nullptr != m_buffer.getBuffAddr()); } diff --git a/Fw/Test/UnitTestAssert.hpp b/Fw/Test/UnitTestAssert.hpp index 8e1b5059e3..07d1620a6b 100644 --- a/Fw/Test/UnitTestAssert.hpp +++ b/Fw/Test/UnitTestAssert.hpp @@ -63,7 +63,7 @@ namespace Test { private: File m_file; NATIVE_UINT_TYPE m_lineNo; - NATIVE_INT_TYPE m_numArgs; + NATIVE_UINT_TYPE m_numArgs; FwAssertArgType m_arg1; FwAssertArgType m_arg2; FwAssertArgType m_arg3; diff --git a/Fw/Time/Time.cpp b/Fw/Time/Time.cpp index 5314f29b9d..7f3dfb72ec 100644 --- a/Fw/Time/Time.cpp +++ b/Fw/Time/Time.cpp @@ -241,7 +241,7 @@ namespace Fw { void Time::add(U32 seconds, U32 useconds) { this->m_seconds += seconds; this->m_useconds += useconds; - FW_ASSERT(this->m_useconds < 1999999,this->m_useconds); + FW_ASSERT(this->m_useconds < 1999999, static_cast(this->m_useconds)); if (this->m_useconds >= 1000000) { ++this->m_seconds; this->m_useconds -= 1000000; diff --git a/Fw/Tlm/TlmString.cpp b/Fw/Tlm/TlmString.cpp index 7e3307c335..79fe2e2185 100644 --- a/Fw/Tlm/TlmString.cpp +++ b/Fw/Tlm/TlmString.cpp @@ -58,7 +58,7 @@ namespace Fw { } SerializeStatus TlmString::serialize(SerializeBufferBase& buffer, NATIVE_UINT_TYPE maxLength) const { - NATIVE_INT_TYPE len = FW_MIN(maxLength,this->length()); + NATIVE_UINT_TYPE len = FW_MIN(maxLength, static_cast(this->length())); #if FW_AMPCS_COMPATIBLE // serialize 8-bit size with null terminator removed U8 strSize = len - 1; diff --git a/Fw/Types/PolyType.cpp b/Fw/Types/PolyType.cpp index d7fc44646a..ebaf037f9a 100644 --- a/Fw/Types/PolyType.cpp +++ b/Fw/Types/PolyType.cpp @@ -211,7 +211,7 @@ namespace Fw { PolyType::PolyType(I64 val) { this->m_dataType = TYPE_I64; - this->m_val.u64Val = val; + this->m_val.i64Val = val; } PolyType::operator I64() { diff --git a/Fw/Types/Serializable.cpp b/Fw/Types/Serializable.cpp index edfec835a9..647aa6eddd 100644 --- a/Fw/Types/Serializable.cpp +++ b/Fw/Types/Serializable.cpp @@ -51,7 +51,10 @@ namespace Fw { FW_ASSERT(src.getBuffAddr()); FW_ASSERT(this->getBuffAddr()); // destination has to be same or bigger - FW_ASSERT(src.getBuffLength() <= this->getBuffCapacity(),src.getBuffLength(),this->getBuffLength()); + FW_ASSERT( + src.getBuffLength() <= this->getBuffCapacity(), + static_cast(src.getBuffLength()), + static_cast(this->getBuffLength())); (void) memcpy(this->getBuffAddr(),src.getBuffAddr(),this->m_serLoc); } diff --git a/Fw/Types/StringType.cpp b/Fw/Types/StringType.cpp index 423c05733e..2ca1432fa1 100644 --- a/Fw/Types/StringType.cpp +++ b/Fw/Types/StringType.cpp @@ -52,7 +52,7 @@ namespace Fw { } const SizeType capacity = this->getCapacity(); - const size_t result = strncmp(us, other, capacity); + const size_t result = static_cast(strncmp(us, other, capacity)); return (result == 0); } @@ -110,13 +110,13 @@ namespace Fw { void StringBase::appendBuff(const CHAR* buff, SizeType size) { const SizeType capacity = this->getCapacity(); const SizeType length = this->length(); - FW_ASSERT(capacity > length, capacity, length); + FW_ASSERT(capacity > length, static_cast(capacity), static_cast(length)); // Subtract 1 to leave space for null terminator SizeType remaining = capacity - length - 1; if(size < remaining) { remaining = size; } - FW_ASSERT(remaining < capacity, remaining, capacity); + FW_ASSERT(remaining < capacity, static_cast(remaining), static_cast(capacity)); (void) strncat(const_cast(this->toChar()), buff, remaining); } @@ -129,7 +129,7 @@ namespace Fw { } SerializeStatus StringBase::serialize(SerializeBufferBase& buffer, SizeType maxLength) const { - SizeType len = FW_MIN(maxLength,this->length()); + SizeType len = FW_MIN(maxLength, static_cast(this->length())); return buffer.serialize(reinterpret_cast(this->toChar()), len); } diff --git a/Os/IPCQueueCommon.cpp b/Os/IPCQueueCommon.cpp index bbe06cb30c..b8790a8682 100644 --- a/Os/IPCQueueCommon.cpp +++ b/Os/IPCQueueCommon.cpp @@ -6,22 +6,22 @@ namespace Os { Queue::QueueStatus IPCQueue::send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block) { const U8* msgBuff = buffer.getBuffAddr(); - NATIVE_INT_TYPE buffLength = buffer.getBuffLength(); + NATIVE_INT_TYPE buffLength = static_cast(buffer.getBuffLength()); return this->send(msgBuff,buffLength,priority, block); - + } Queue::QueueStatus IPCQueue::receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block) { U8* msgBuff = buffer.getBuffAddr(); - NATIVE_INT_TYPE buffCapacity = buffer.getBuffCapacity(); + NATIVE_INT_TYPE buffCapacity = static_cast(buffer.getBuffCapacity()); NATIVE_INT_TYPE recvSize = 0; Queue::QueueStatus recvStat = this->receive(msgBuff, buffCapacity, recvSize, priority, block); if (QUEUE_OK == recvStat) { - if (buffer.setBuffLen(recvSize) == Fw::FW_SERIALIZE_OK) { + if (buffer.setBuffLen(static_cast(recvSize)) == Fw::FW_SERIALIZE_OK) { return QUEUE_OK; } else { return QUEUE_SIZE_MISMATCH; diff --git a/Os/Linux/Directory.cpp b/Os/Linux/Directory.cpp index 6794e56e40..d1f5b832cf 100644 --- a/Os/Linux/Directory.cpp +++ b/Os/Linux/Directory.cpp @@ -92,7 +92,7 @@ namespace Os { // Skip hidden files if (direntData->d_name[0] != '.') { strncpy(fileNameBuffer, direntData->d_name, bufSize); - inode = direntData->d_ino; + inode = static_cast(direntData->d_ino); break; } } diff --git a/Os/Linux/SystemResources.cpp b/Os/Linux/SystemResources.cpp index f0d9efd746..439bc37c94 100644 --- a/Os/Linux/SystemResources.cpp +++ b/Os/Linux/SystemResources.cpp @@ -23,7 +23,7 @@ char proc_stat_line[LINE_SIZE]; namespace Os { SystemResources::SystemResourcesStatus SystemResources::getCpuCount(U32& cpuCount) { - cpuCount = get_nprocs(); + cpuCount = static_cast(get_nprocs()); return SYSTEM_RESOURCES_OK; } diff --git a/Os/Posix/IPCQueue.cpp b/Os/Posix/IPCQueue.cpp index 4920ac699c..b5f043e6ed 100644 --- a/Os/Posix/IPCQueue.cpp +++ b/Os/Posix/IPCQueue.cpp @@ -130,7 +130,14 @@ namespace Os { if (block == QUEUE_BLOCKING) { wait.tv_sec += IPC_QUEUE_TIMEOUT_SEC; } - NATIVE_INT_TYPE stat = mq_timedsend(handle, reinterpret_cast(buffer), size, priority, &wait); + + NATIVE_INT_TYPE stat = mq_timedsend( + handle, + reinterpret_cast(buffer), + static_cast(size), + static_cast(priority), + &wait); + if (-1 == stat) { switch (errno) { case EINTR: @@ -229,7 +236,7 @@ namespace Os { struct mq_attr attr; int status = mq_getattr(handle, &attr); FW_ASSERT(status == 0); - return static_cast(attr.mq_curmsgs); + return static_cast(attr.mq_curmsgs); } NATIVE_INT_TYPE IPCQueue::getMaxMsgs() const { @@ -244,7 +251,7 @@ namespace Os { struct mq_attr attr; int status = mq_getattr(handle, &attr); FW_ASSERT(status == 0); - return static_cast(attr.mq_maxmsg); + return static_cast(attr.mq_maxmsg); } NATIVE_INT_TYPE IPCQueue::getMsgSize() const { @@ -254,7 +261,7 @@ namespace Os { struct mq_attr attr; int status = mq_getattr(handle, &attr); FW_ASSERT(status == 0); - return static_cast(attr.mq_msgsize); + return static_cast(attr.mq_msgsize); } } diff --git a/Os/Posix/LocklessQueue.cpp b/Os/Posix/LocklessQueue.cpp index f7c6801b47..bb93d90f73 100644 --- a/Os/Posix/LocklessQueue.cpp +++ b/Os/Posix/LocklessQueue.cpp @@ -105,7 +105,7 @@ namespace Os { } // Copy the data into the buffer - memcpy(my_node->data, buffer, size); + memcpy(my_node->data, buffer, static_cast(size)); my_node->size = size; my_node->next = nullptr; @@ -150,7 +150,7 @@ namespace Os { PushFree(old_node); // Copy the data from the buffer - memcpy(buffer, my_node->data, my_node->size); + memcpy(buffer, my_node->data, static_cast(my_node->size)); size = my_node->size; return Queue::QUEUE_OK; diff --git a/Os/Posix/Task.cpp b/Os/Posix/Task.cpp index 92562e4df8..816373cde5 100644 --- a/Os/Posix/Task.cpp +++ b/Os/Posix/Task.cpp @@ -43,16 +43,16 @@ namespace Os { priority = Task::TASK_DEFAULT; //Action: use constant } if (priority != Task::TASK_DEFAULT and priority < static_cast(min_priority)) { - Fw::Logger::logMsg("[WARNING] Low task priority of %d being clamped to %d\n", priority, min_priority); - priority = min_priority; + Fw::Logger::logMsg("[WARNING] Low task priority of %d being clamped to %d\n", priority, static_cast(min_priority)); + priority = static_cast(min_priority); } if (priority != Task::TASK_DEFAULT and priority > static_cast(max_priority)) { - Fw::Logger::logMsg("[WARNING] High task priority of %d being clamped to %d\n", priority, max_priority); - priority = max_priority; + Fw::Logger::logMsg("[WARNING] High task priority of %d being clamped to %d\n", priority, static_cast(max_priority)); + priority = static_cast(max_priority); } // Check the stack if (stack != Task::TASK_DEFAULT and stack < PTHREAD_STACK_MIN) { - Fw::Logger::logMsg("[WARNING] Stack size %d too small, setting to minimum of %d\n", stack, PTHREAD_STACK_MIN); + Fw::Logger::logMsg("[WARNING] Stack size %d too small, setting to minimum of %d\n", stack, static_cast(PTHREAD_STACK_MIN)); stack = static_cast(PTHREAD_STACK_MIN); } // Check CPU affinity @@ -91,7 +91,7 @@ namespace Os { sched_param schedParam; memset(&schedParam, 0, sizeof(sched_param)); - schedParam.sched_priority = priority; + schedParam.sched_priority =static_cast(priority); stat = pthread_attr_setschedparam(&att, &schedParam); if (stat != 0) { Fw::Logger::logMsg("pthread_attr_setschedparam: %s\n", reinterpret_cast(strerror(stat))); @@ -132,7 +132,7 @@ namespace Os { I32 stat = pthread_attr_init(&att); if (stat != 0) { - Fw::Logger::logMsg("pthread_attr_init: (%d): %s\n", stat, reinterpret_cast(strerror(stat))); + Fw::Logger::logMsg("pthread_attr_init: (%d): %s\n", static_cast(stat), reinterpret_cast(strerror(stat))); return Task::TASK_INVALID_PARAMS; } @@ -198,7 +198,7 @@ namespace Os { this->m_name = "TP_"; this->m_name += name; - this->m_identifier = identifier; + this->m_identifier = static_cast(identifier); // Setup functor wrapper parameters this->m_routineWrapper.routine = routine; this->m_routineWrapper.arg = arg; diff --git a/Os/Pthreads/BufferQueueCommon.cpp b/Os/Pthreads/BufferQueueCommon.cpp index b9bbd772e8..74fad09fc5 100644 --- a/Os/Pthreads/BufferQueueCommon.cpp +++ b/Os/Pthreads/BufferQueueCommon.cpp @@ -114,7 +114,7 @@ namespace Os { } NATIVE_UINT_TYPE BufferQueue::getBufferIndex(NATIVE_INT_TYPE index) { - return static_cast((index % this->m_depth) * (sizeof(NATIVE_INT_TYPE) + this->m_msgSize)); + return static_cast((static_cast(index) % this->m_depth) * (sizeof(NATIVE_INT_TYPE) + this->m_msgSize)); } void BufferQueue::enqueueBuffer(const U8* buffer, NATIVE_UINT_TYPE size, U8* data, NATIVE_UINT_TYPE index) { diff --git a/Os/Pthreads/MaxHeap/MaxHeap.cpp b/Os/Pthreads/MaxHeap/MaxHeap.cpp index a309f7a031..347566f95a 100644 --- a/Os/Pthreads/MaxHeap/MaxHeap.cpp +++ b/Os/Pthreads/MaxHeap/MaxHeap.cpp @@ -81,7 +81,7 @@ namespace Os { parent = PARENT(index); // The parent index should ALWAYS be less than the // current index. Let's verify that. - FW_ASSERT(parent < index, parent, index); + FW_ASSERT(parent < index, static_cast(parent), static_cast(index)); // If the current value is less than the parent, // then the current index is in the correct place, // so break out of the loop: @@ -95,8 +95,8 @@ namespace Os { } // Check for programming errors or bit flips: - FW_ASSERT(maxCount < maxIter, maxCount, maxIter); - FW_ASSERT(index <= this->m_size, index); + FW_ASSERT(maxCount < maxIter, static_cast(maxCount), static_cast(maxIter)); + FW_ASSERT(index <= this->m_size, static_cast(index)); // Set the values of the new element: this->m_heap[index].value = value; @@ -169,8 +169,8 @@ namespace Os { // Get the children indexes for this node: left = LCHILD(index); right = RCHILD(index); - FW_ASSERT(left > index, left, index); - FW_ASSERT(right > left, right, left); + FW_ASSERT(left > index, static_cast(left), static_cast(index)); + FW_ASSERT(right > left, static_cast(right), static_cast(left)); // If the left node is bigger than the heap // size, we have reached the end of the heap @@ -212,15 +212,15 @@ namespace Os { } // Check for programming errors or bit flips: - FW_ASSERT(maxCount < maxIter, maxCount, maxIter); - FW_ASSERT(index <= this->m_size, index); + FW_ASSERT(maxCount < maxIter, static_cast(maxCount), static_cast(maxIter)); + FW_ASSERT(index <= this->m_size, static_cast(index)); } // Return the maximum priority index between two nodes. If their // priorities are equal, return the oldest to keep the heap stable NATIVE_UINT_TYPE MaxHeap::max(NATIVE_UINT_TYPE a, NATIVE_UINT_TYPE b) { - FW_ASSERT(a < this->m_size, a, this->m_size); - FW_ASSERT(b < this->m_size, b, this->m_size); + FW_ASSERT(a < this->m_size, static_cast(a), static_cast(this->m_size)); + FW_ASSERT(b < this->m_size, static_cast(b), static_cast(this->m_size)); // Extract the priorities: NATIVE_INT_TYPE aValue = this->m_heap[a].value; @@ -251,8 +251,8 @@ namespace Os { // Swap two nodes in the heap: void MaxHeap::swap(NATIVE_UINT_TYPE a, NATIVE_UINT_TYPE b) { - FW_ASSERT(a < this->m_size, a, this->m_size); - FW_ASSERT(b < this->m_size, b, this->m_size); + FW_ASSERT(a < this->m_size, static_cast(a), static_cast(this->m_size)); + FW_ASSERT(b < this->m_size, static_cast(b), static_cast(this->m_size)); Node temp = this->m_heap[a]; this->m_heap[a] = this->m_heap[b]; this->m_heap[b] = temp; @@ -270,18 +270,18 @@ namespace Os { if( left >= m_size && index == 0) { Fw::Logger::logMsg("i: %u v: %d d: %u -> (NULL, NULL)\n", - index, this->m_heap[index].value, this->m_heap[index].id); + index, static_cast(this->m_heap[index].value), this->m_heap[index].id); } else if( right >= m_size && left < m_size ) { Fw::Logger::logMsg("i: %u v: %d d: %u -> (i: %u v: %d d: %u, NULL)\n", - index, this->m_heap[index].value, this->m_heap[index].id, - left, this->m_heap[left].value, this->m_heap[left].id); + index, static_cast(this->m_heap[index].value), this->m_heap[index].id, + left, static_cast(this->m_heap[left].value), this->m_heap[left].id); } else if( right < m_size && left < m_size ) { Fw::Logger::logMsg("i: %u v: %d d: %u -> (i: %u v: %d d: %u, i: %u v: %d d: %u)\n", - index, this->m_heap[index].value, this->m_heap[index].id, - left, this->m_heap[left].value,this->m_heap[left].id, - right, this->m_heap[right].value, this->m_heap[right].id); + index, static_cast(this->m_heap[index].value), this->m_heap[index].id, + left, static_cast(this->m_heap[left].value),this->m_heap[left].id, + right, static_cast(this->m_heap[right].value), this->m_heap[right].id); } ++index; diff --git a/Os/Pthreads/PriorityBufferQueue.cpp b/Os/Pthreads/PriorityBufferQueue.cpp index 8e9c88ddf6..2eb70ba8ee 100644 --- a/Os/Pthreads/PriorityBufferQueue.cpp +++ b/Os/Pthreads/PriorityBufferQueue.cpp @@ -48,7 +48,12 @@ namespace Os { NATIVE_UINT_TYPE index = indexes[pQueue->startIndex % depth]; ++pQueue->startIndex; NATIVE_UINT_TYPE diff = pQueue->stopIndex - pQueue->startIndex; - FW_ASSERT(diff <= depth, diff, depth, pQueue->stopIndex, pQueue->startIndex); + FW_ASSERT( + diff <= depth, + static_cast(diff), + static_cast(depth), + static_cast(pQueue->stopIndex), + static_cast(pQueue->startIndex)); return index; } @@ -59,7 +64,12 @@ namespace Os { indexes[pQueue->stopIndex % depth] = index; ++pQueue->stopIndex; NATIVE_UINT_TYPE diff = pQueue->stopIndex - pQueue->startIndex; - FW_ASSERT(diff <= depth, diff, depth, pQueue->stopIndex, pQueue->startIndex); + FW_ASSERT( + diff <= depth, + static_cast(diff), + static_cast(depth), + static_cast(pQueue->stopIndex), + static_cast(pQueue->startIndex)); } ///////////////////////////////////////////////////// @@ -88,7 +98,7 @@ namespace Os { return false; } for(NATIVE_UINT_TYPE ii = 0; ii < depth; ++ii) { - indexes[ii] = getBufferIndex(ii); + indexes[ii] = getBufferIndex(static_cast(ii)); } PriorityQueue* priorityQueue = new(std::nothrow) PriorityQueue; if (nullptr == priorityQueue) { diff --git a/Os/Pthreads/Queue.cpp b/Os/Pthreads/Queue.cpp index 0e91ae2563..0a46fda2d9 100644 --- a/Os/Pthreads/Queue.cpp +++ b/Os/Pthreads/Queue.cpp @@ -43,7 +43,7 @@ namespace Os { (void) pthread_mutex_destroy(&this->queueLock); } bool create(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize) { - return queue.create(depth, msgSize); + return queue.create(static_cast(depth), static_cast(msgSize)); } BufferQueue queue; pthread_cond_t queueNotEmpty; @@ -108,7 +108,7 @@ namespace Os { /////////////////////////////// // Push item onto queue: - bool pushSucceeded = queue->push(buffer, size, priority); + bool pushSucceeded = queue->push(buffer, static_cast(size), priority); if(pushSucceeded) { // Push worked - wake up a thread that might be waiting on @@ -152,7 +152,7 @@ namespace Os { } // Push item onto queue: - bool pushSucceeded = queue->push(buffer, size, priority); + bool pushSucceeded = queue->push(buffer, static_cast(size), priority); // The only reason push would not succeed is if the queue // was full. Since we waited for the queue to NOT be full @@ -347,7 +347,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getCount(); + return static_cast(queue->getCount()); } NATIVE_INT_TYPE Queue::getMaxMsgs() const { @@ -356,7 +356,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getMaxCount(); + return static_cast(queue->getMaxCount()); } NATIVE_INT_TYPE Queue::getQueueSize() const { @@ -365,7 +365,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getDepth(); + return static_cast(queue->getDepth()); } NATIVE_INT_TYPE Queue::getMsgSize() const { @@ -374,7 +374,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getMsgSize(); + return static_cast(queue->getMsgSize()); } } diff --git a/Os/QueueCommon.cpp b/Os/QueueCommon.cpp index 0ccddd46f3..904713de00 100644 --- a/Os/QueueCommon.cpp +++ b/Os/QueueCommon.cpp @@ -13,7 +13,7 @@ namespace Os { Queue::QueueStatus Queue::send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block) { const U8* msgBuff = buffer.getBuffAddr(); - NATIVE_INT_TYPE buffLength = buffer.getBuffLength(); + NATIVE_INT_TYPE buffLength = static_cast(buffer.getBuffLength()); return this->send(msgBuff,buffLength,priority, block); @@ -22,13 +22,13 @@ namespace Os { Queue::QueueStatus Queue::receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block) { U8* msgBuff = buffer.getBuffAddr(); - NATIVE_INT_TYPE buffCapacity = buffer.getBuffCapacity(); + NATIVE_INT_TYPE buffCapacity = static_cast(buffer.getBuffCapacity()); NATIVE_INT_TYPE recvSize = 0; Queue::QueueStatus recvStat = this->receive(msgBuff, buffCapacity, recvSize, priority, block); if (QUEUE_OK == recvStat) { - if (buffer.setBuffLen(recvSize) == Fw::FW_SERIALIZE_OK) { + if (buffer.setBuffLen(static_cast(recvSize)) == Fw::FW_SERIALIZE_OK) { return QUEUE_OK; } else { return QUEUE_SIZE_MISMATCH; diff --git a/Svc/ActiveRateGroup/ActiveRateGroup.cpp b/Svc/ActiveRateGroup/ActiveRateGroup.cpp index 772b8ecca6..2d94b7e030 100644 --- a/Svc/ActiveRateGroup/ActiveRateGroup.cpp +++ b/Svc/ActiveRateGroup/ActiveRateGroup.cpp @@ -68,7 +68,7 @@ namespace Svc { // invoke any members of the rate group for (NATIVE_INT_TYPE port = 0; port < this->m_numContexts; port++) { if (this->isConnected_RateGroupMemberOut_OutputPort(port)) { - this->RateGroupMemberOut_out(port,this->m_contexts[port]); + this->RateGroupMemberOut_out(port, static_cast(this->m_contexts[port])); } } diff --git a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp index 1e1ff8d54d..ee0d47b9cc 100644 --- a/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp +++ b/Svc/AssertFatalAdapter/AssertFatalAdapterComponentImpl.cpp @@ -138,25 +138,60 @@ namespace Svc { switch (numArgs) { case 0: - this->log_FATAL_AF_ASSERT_0(fileArg,lineNo); + this->log_FATAL_AF_ASSERT_0( + fileArg, + lineNo); break; case 1: - this->log_FATAL_AF_ASSERT_1(fileArg,lineNo,arg1); + this->log_FATAL_AF_ASSERT_1( + fileArg, + lineNo, + static_cast(arg1)); break; case 2: - this->log_FATAL_AF_ASSERT_2(fileArg,lineNo,arg1,arg2); + this->log_FATAL_AF_ASSERT_2( + fileArg, + lineNo, + static_cast(arg1), + static_cast(arg2)); break; case 3: - this->log_FATAL_AF_ASSERT_3(fileArg,lineNo,arg1,arg2,arg3); + this->log_FATAL_AF_ASSERT_3( + fileArg, + lineNo, + static_cast(arg1), + static_cast(arg2), + static_cast(arg3)); break; case 4: - this->log_FATAL_AF_ASSERT_4(fileArg,lineNo,arg1,arg2,arg3,arg4); + this->log_FATAL_AF_ASSERT_4( + fileArg, + lineNo, + static_cast(arg1), + static_cast(arg2), + static_cast(arg3), + static_cast(arg4)); break; case 5: - this->log_FATAL_AF_ASSERT_5(fileArg,lineNo,arg1,arg2,arg3,arg4,arg5); + this->log_FATAL_AF_ASSERT_5( + fileArg, + lineNo, + static_cast(arg1), + static_cast(arg2), + static_cast(arg3), + static_cast(arg4), + static_cast(arg5)); break; case 6: - this->log_FATAL_AF_ASSERT_6(fileArg,lineNo,arg1,arg2,arg3,arg4,arg5,arg6); + this->log_FATAL_AF_ASSERT_6( + fileArg, + lineNo, + static_cast(arg1), + static_cast(arg2), + static_cast(arg3), + static_cast(arg4), + static_cast(arg5), + static_cast(arg6)); break; default: this->log_FATAL_AF_UNEXPECTED_ASSERT(fileArg,lineNo,numArgs); diff --git a/Svc/BufferAccumulator/BufferAccumulator.cpp b/Svc/BufferAccumulator/BufferAccumulator.cpp index a2b744583c..41ce70ad68 100644 --- a/Svc/BufferAccumulator/BufferAccumulator.cpp +++ b/Svc/BufferAccumulator/BufferAccumulator.cpp @@ -59,7 +59,7 @@ void BufferAccumulator ::allocateQueue( NATIVE_UINT_TYPE memSize = static_cast(sizeof(Fw::Buffer) * maxNumBuffers); bool recoverable = false; this->m_bufferMemory = static_cast( - allocator.allocate(identifier, memSize, recoverable)); + allocator.allocate(static_cast(identifier), memSize, recoverable)); //TODO: Fail gracefully here m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers); } diff --git a/Utils/TokenBucket.cpp b/Utils/TokenBucket.cpp index 9583afae3c..15037e6644 100644 --- a/Utils/TokenBucket.cpp +++ b/Utils/TokenBucket.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title TokenBucket.cpp // \author vwong // \brief cpp file for a rate limiter utility class @@ -9,7 +9,7 @@ // // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// ====================================================================== +// ====================================================================== #include @@ -42,7 +42,7 @@ namespace Utils { m_tokens(maxTokens), m_time(0, 0) { - FW_ASSERT(this->m_maxTokens <= MAX_TOKEN_BUCKET_TOKENS, this->m_maxTokens); + FW_ASSERT(this->m_maxTokens <= MAX_TOKEN_BUCKET_TOKENS, static_cast(this->m_maxTokens)); } void TokenBucket :: diff --git a/Utils/Types/CircularBuffer.cpp b/Utils/Types/CircularBuffer.cpp index b835f58585..b4fe9daec4 100644 --- a/Utils/Types/CircularBuffer.cpp +++ b/Utils/Types/CircularBuffer.cpp @@ -61,12 +61,12 @@ NATIVE_UINT_TYPE CircularBuffer :: get_allocated_size() const { NATIVE_UINT_TYPE 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, m_allocated_size); + 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 { - FW_ASSERT(idx < m_store_size, idx); + FW_ASSERT(idx < m_store_size, static_cast(idx)); return (idx + amount) % m_store_size; } @@ -80,12 +80,12 @@ Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const NA // Copy in all the supplied data NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, m_allocated_size); for (U32 i = 0; i < size; i++) { - FW_ASSERT(idx < m_store_size, idx); + FW_ASSERT(idx < m_store_size, static_cast(idx)); m_store[idx] = buffer[i]; idx = advance_idx(idx); } m_allocated_size += size; - FW_ASSERT(m_allocated_size <= this->get_capacity(), m_allocated_size); + FW_ASSERT(m_allocated_size <= this->get_capacity(), static_cast(m_allocated_size)); m_high_water_mark = (m_high_water_mark > m_allocated_size) ? m_high_water_mark : m_allocated_size; return Fw::FW_SERIALIZE_OK; } @@ -102,7 +102,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U8& value, NATIVE_UINT_TYPE offset) c return Fw::FW_DESERIALIZE_BUFFER_EMPTY; } const NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset); - FW_ASSERT(idx < m_store_size, idx); + FW_ASSERT(idx < m_store_size, static_cast(idx)); value = m_store[idx]; return Fw::FW_SERIALIZE_OK; } @@ -118,7 +118,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U32& value, NATIVE_UINT_TYPE offset) // Deserialize all the bytes from network format for (NATIVE_UINT_TYPE i = 0; i < sizeof(U32); i++) { - FW_ASSERT(idx < m_store_size, idx); + FW_ASSERT(idx < m_store_size, static_cast(idx)); value = (value << 8) | static_cast(m_store[idx]); idx = advance_idx(idx); } @@ -135,7 +135,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, NATIVE_UINT_TYPE size, NA NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset); // Deserialize all the bytes from network format for (NATIVE_UINT_TYPE i = 0; i < size; i++) { - FW_ASSERT(idx < m_store_size, idx); + FW_ASSERT(idx < m_store_size, static_cast(idx)); buffer[i] = m_store[idx]; idx = advance_idx(idx); } From 3c2103d4a17b0d40e6f1176472c599ca34d1aded Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Tue, 9 Apr 2024 00:55:56 +0200 Subject: [PATCH 07/21] Fix last errors from clang --- Drv/Ip/IpSocket.cpp | 2 +- Drv/Ip/SocketReadTask.cpp | 2 +- .../LinuxGpioDriverComponentImpl.cpp | 20 ++++----- Drv/LinuxUartDriver/LinuxUartDriver.cpp | 16 ++++---- Svc/BufferAccumulator/ArrayFIFOBuffer.cpp | 4 +- Svc/BufferAccumulator/BufferAccumulator.cpp | 2 +- Svc/BufferLogger/BufferLoggerFile.cpp | 4 +- .../BufferManagerComponentImpl.cpp | 41 +++++++++++++++---- Svc/CmdDispatcher/CommandDispatcherImpl.cpp | 14 ++++--- Svc/CmdSequencer/FPrimeSequence.cpp | 8 ++-- Svc/CmdSequencer/Sequence.cpp | 4 +- Svc/CmdSequencer/formats/AMPCSSequence.cpp | 9 ++-- Svc/ComLogger/ComLogger.cpp | 28 +++++++++---- Svc/ComQueue/ComQueue.cpp | 15 ++++--- Svc/Deframer/Deframer.cpp | 34 +++++++++------ Svc/DpWriter/DpWriter.cpp | 4 +- Svc/FileDownlink/FileDownlink.cpp | 7 +++- Svc/FileManager/FileManager.cpp | 2 +- Svc/FramingProtocol/FprimeProtocol.cpp | 4 +- Svc/GenericHub/GenericHubComponentImpl.cpp | 8 ++-- Svc/Health/HealthComponentImpl.cpp | 13 +++--- Svc/PassiveRateGroup/PassiveRateGroup.cpp | 2 +- Svc/PrmDb/PrmDbImpl.cpp | 36 ++++++++-------- Svc/RateGroupDriver/RateGroupDriver.cpp | 4 +- .../StaticMemoryComponentImpl.cpp | 5 ++- Svc/TlmPacketizer/TlmPacketizer.cpp | 12 +++--- 26 files changed, 184 insertions(+), 116 deletions(-) diff --git a/Drv/Ip/IpSocket.cpp b/Drv/Ip/IpSocket.cpp index 0d3f8af9d3..64b43f4dd0 100644 --- a/Drv/Ip/IpSocket.cpp +++ b/Drv/Ip/IpSocket.cpp @@ -203,7 +203,7 @@ SocketIpStatus IpSocket::recv(U8* data, I32& req_read) { // Try to read until we fail to receive data for (U32 i = 0; (i < SOCKET_MAX_ITERATIONS) && (size <= 0); i++) { // Attempt to recv out data - size = this->recvProtocol(data, req_read); + size = this->recvProtocol(data, static_cast(req_read)); // Error is EINTR, just try again if (size == -1 && ((errno == EINTR) || errno == EAGAIN)) { continue; diff --git a/Drv/Ip/SocketReadTask.cpp b/Drv/Ip/SocketReadTask.cpp index 52a405020e..bffb40199b 100644 --- a/Drv/Ip/SocketReadTask.cpp +++ b/Drv/Ip/SocketReadTask.cpp @@ -109,7 +109,7 @@ void SocketReadTask::readTask(void* pointer) { buffer.setSize(0); } else { // Send out received data - buffer.setSize(size); + buffer.setSize(static_cast(size)); } self->sendBuffer(buffer, status); } diff --git a/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp b/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp index 78aedc9af6..7af221c06e 100644 --- a/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp +++ b/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp @@ -50,7 +50,7 @@ namespace Drv { // TODO check value of len len = snprintf(buf, sizeof(buf), "%u", gpio); - if(write(fd, buf, len) != len) { + if(write(fd, buf, static_cast(len)) != len) { (void) close(fd); DEBUG_PRINT("gpio/export error!\n"); return -1; @@ -81,7 +81,7 @@ namespace Drv { // TODO check value of len len = snprintf(buf, sizeof(buf), "%u", gpio); - if(write(fd, buf, len) != len) { + if(write(fd, buf, static_cast(len)) != len) { (void) close(fd); DEBUG_PRINT("gpio/unexport error!\n"); return -1; @@ -116,7 +116,7 @@ namespace Drv { const char *dir = out_flag ? "out" : "in"; len = static_cast(strlen(dir)); - if (write(fd, dir, len) != len) { + if (write(fd, dir, static_cast(len)) != len) { (void) close(fd); DEBUG_PRINT("gpio/direction error!\n"); return -1; @@ -200,7 +200,7 @@ namespace Drv { } len = static_cast(strlen(edge) + 1); - if(write(fd, edge, len) != len) { + if(write(fd, edge, static_cast(len)) != len) { (void) close(fd); DEBUG_PRINT("gpio/set-edge error!\n"); return -1; @@ -292,13 +292,13 @@ namespace Drv { NATIVE_INT_TYPE stat; // Configure: - stat = gpio_export(gpio); + stat = gpio_export(static_cast(gpio)); if (-1 == stat) { Fw::LogStringArg arg = strerror(errno); this->log_WARNING_HI_GP_OpenError(gpio,stat,arg); return false; } - stat = gpio_set_dir(gpio, direction == GPIO_OUT ? 1 : 0); + stat = gpio_set_dir(static_cast(gpio), direction == GPIO_OUT ? 1 : 0); if (-1 == stat) { Fw::LogStringArg arg = strerror(errno); this->log_WARNING_HI_GP_OpenError(gpio,stat,arg); @@ -308,7 +308,7 @@ namespace Drv { // If needed, set edge to rising in intTaskEntry() // Open: - this->m_fd = gpio_fd_open(gpio); + this->m_fd = gpio_fd_open(static_cast(gpio)); if (-1 == this->m_fd) { Fw::LogStringArg arg = strerror(errno); this->log_WARNING_HI_GP_OpenError(gpio,errno,arg); @@ -330,7 +330,7 @@ namespace Drv { // start GPIO interrupt NATIVE_INT_TYPE stat; - stat = gpio_set_edge(compPtr->m_gpio, "rising"); + stat = gpio_set_edge(static_cast(compPtr->m_gpio), "rising"); if (-1 == stat) { compPtr->log_WARNING_HI_GP_IntStartError(compPtr->m_gpio); return; @@ -346,7 +346,7 @@ namespace Drv { fdset[0].fd = compPtr->m_fd; fdset[0].events = POLLPRI; - stat = poll(fdset, nfds, timeout); + stat = poll(fdset, static_cast(nfds), timeout); /* * According to this link, poll will always have POLLERR set for the sys/class/gpio subsystem @@ -422,7 +422,7 @@ namespace Drv { { if (this->m_fd != -1) { DEBUG_PRINT("Closing GPIO %d fd %d\n",this->m_gpio, this->m_fd); - (void) gpio_fd_close(this->m_fd, this->m_gpio); + (void) gpio_fd_close(this->m_fd, static_cast(this->m_gpio)); } } diff --git a/Drv/LinuxUartDriver/LinuxUartDriver.cpp b/Drv/LinuxUartDriver/LinuxUartDriver.cpp index 5c153537e7..f04f0cbd4f 100644 --- a/Drv/LinuxUartDriver/LinuxUartDriver.cpp +++ b/Drv/LinuxUartDriver/LinuxUartDriver.cpp @@ -207,7 +207,7 @@ bool LinuxUartDriver::open(const char* const device, #endif #endif default: - FW_ASSERT(0, baud); + FW_ASSERT(0, static_cast(baud)); break; } @@ -248,7 +248,7 @@ bool LinuxUartDriver::open(const char* const device, newtio.c_cflag |= PARENB; break; case PARITY_NONE: - newtio.c_cflag &= ~PARENB; + newtio.c_cflag &= static_cast(~PARENB); break; default: FW_ASSERT(0, parity); @@ -256,7 +256,7 @@ bool LinuxUartDriver::open(const char* const device, } // Set baud rate: - stat = cfsetispeed(&newtio, relayRate); + stat = cfsetispeed(&newtio, static_cast(relayRate)); if (stat) { DEBUG_PRINT("cfsetispeed failed\n"); close(fd); @@ -265,7 +265,7 @@ bool LinuxUartDriver::open(const char* const device, this->log_WARNING_HI_OpenError(_arg, fd, _err); return false; } - stat = cfsetospeed(&newtio, relayRate); + stat = cfsetospeed(&newtio, static_cast(relayRate)); if (stat) { DEBUG_PRINT("cfsetospeed failed\n"); close(fd); @@ -324,9 +324,9 @@ Drv::SendStatus LinuxUartDriver ::send_handler(const NATIVE_INT_TYPE portNum, Fw status = Drv::SendStatus::SEND_ERROR; } else { unsigned char *data = serBuffer.getData(); - NATIVE_INT_TYPE xferSize = serBuffer.getSize(); + NATIVE_INT_TYPE xferSize = static_cast(serBuffer.getSize()); - NATIVE_INT_TYPE stat = static_cast(::write(this->m_fd, data, xferSize)); + NATIVE_INT_TYPE stat = static_cast(::write(this->m_fd, data, static_cast(xferSize))); if (-1 == stat || stat != xferSize) { Fw::LogStringArg _arg = this->m_device; @@ -346,7 +346,7 @@ void LinuxUartDriver ::serialReadTaskEntry(void* ptr) { Drv::RecvStatus status = RecvStatus::RECV_ERROR; // added by m.chase 03.06.2017 LinuxUartDriver* comp = reinterpret_cast(ptr); while (!comp->m_quitReadThread) { - Fw::Buffer buff = comp->allocate_out(0, comp->m_allocationSize); + Fw::Buffer buff = comp->allocate_out(0, static_cast(comp->m_allocationSize)); // On failed allocation, error and deallocate if (buff.getData() == nullptr) { @@ -380,7 +380,7 @@ void LinuxUartDriver ::serialReadTaskEntry(void* ptr) { comp->log_WARNING_HI_ReadError(_arg, stat); status = RecvStatus::RECV_ERROR; } else if (stat > 0) { - buff.setSize(stat); + buff.setSize(static_cast(stat)); status = RecvStatus::RECV_OK; // added by m.chase 03.06.2017 } else { status = RecvStatus::RECV_ERROR; // Simply to return the buffer diff --git a/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp b/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp index 90203ca722..53a3d660e3 100644 --- a/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp +++ b/Svc/BufferAccumulator/ArrayFIFOBuffer.cpp @@ -56,7 +56,7 @@ bool BufferAccumulator::ArrayFIFOBuffer ::enqueue(const Fw::Buffer& e) { bool status; if (this->m_size < this->m_capacity) { // enqueueIndex is unsigned, no need to compare with 0 - FW_ASSERT(m_enqueueIndex < this->m_capacity, m_enqueueIndex); + FW_ASSERT(m_enqueueIndex < this->m_capacity, static_cast(m_enqueueIndex)); this->m_elements[this->m_enqueueIndex] = e; this->m_enqueueIndex = (this->m_enqueueIndex + 1) % this->m_capacity; status = true; @@ -79,7 +79,7 @@ bool BufferAccumulator::ArrayFIFOBuffer ::dequeue(Fw::Buffer& e) { if (this->m_size > 0) { // dequeueIndex is unsigned, no need to compare with 0 - FW_ASSERT(m_dequeueIndex < this->m_capacity, m_dequeueIndex); + FW_ASSERT(m_dequeueIndex < this->m_capacity, static_cast(m_dequeueIndex)); e = this->m_elements[this->m_dequeueIndex]; this->m_dequeueIndex = (this->m_dequeueIndex + 1) % this->m_capacity; this->m_size--; diff --git a/Svc/BufferAccumulator/BufferAccumulator.cpp b/Svc/BufferAccumulator/BufferAccumulator.cpp index 41ce70ad68..bbd84c92e5 100644 --- a/Svc/BufferAccumulator/BufferAccumulator.cpp +++ b/Svc/BufferAccumulator/BufferAccumulator.cpp @@ -65,7 +65,7 @@ void BufferAccumulator ::allocateQueue( } void BufferAccumulator ::deallocateQueue(Fw::MemAllocator& allocator) { - allocator.deallocate(this->m_allocatorId, this->m_bufferMemory); + allocator.deallocate(static_cast(this->m_allocatorId), this->m_bufferMemory); } // ---------------------------------------------------------------------- diff --git a/Svc/BufferLogger/BufferLoggerFile.cpp b/Svc/BufferLogger/BufferLoggerFile.cpp index 997430f78e..84b5698ab8 100644 --- a/Svc/BufferLogger/BufferLoggerFile.cpp +++ b/Svc/BufferLogger/BufferLoggerFile.cpp @@ -63,7 +63,7 @@ namespace Svc { this->m_sizeOfSize = sizeOfSize; FW_ASSERT(sizeOfSize <= sizeof(U32), sizeOfSize); - FW_ASSERT(m_maxSize > sizeOfSize, m_maxSize); + FW_ASSERT(m_maxSize > sizeOfSize, static_cast(m_maxSize)); } void BufferLogger::File :: @@ -201,7 +201,7 @@ namespace Svc { const U32 length ) { - FW_ASSERT(length > 0, length); + FW_ASSERT(length > 0, static_cast(length)); FwSignedSizeType size = length; const Os::File::Status fileStatus = this->m_osFile.write(reinterpret_cast(data), size); bool status; diff --git a/Svc/BufferManager/BufferManagerComponentImpl.cpp b/Svc/BufferManager/BufferManagerComponentImpl.cpp index 4f3f7203c0..192bcf0d59 100644 --- a/Svc/BufferManager/BufferManagerComponentImpl.cpp +++ b/Svc/BufferManager/BufferManagerComponentImpl.cpp @@ -102,13 +102,32 @@ namespace Svc { U32 id = context & 0xFFFF; U32 mgrId = context >> 16; // check some things - FW_ASSERT(id < this->m_numStructs,id,this->m_numStructs); - FW_ASSERT(mgrId == this->m_mgrId,mgrId,id,this->m_mgrId); - FW_ASSERT(true == this->m_buffers[id].allocated,id,this->m_mgrId); - FW_ASSERT(reinterpret_cast(fwBuffer.getData()) >= this->m_buffers[id].memory,id,this->m_mgrId); - FW_ASSERT(reinterpret_cast(fwBuffer.getData()) < (this->m_buffers[id].memory + this->m_buffers[id].size),id,this->m_mgrId); + FW_ASSERT( + id < this->m_numStructs, + static_cast(id), + static_cast(this->m_numStructs)); + FW_ASSERT( + mgrId == this->m_mgrId, + static_cast(mgrId), + static_cast(id), + static_cast(this->m_mgrId)); + FW_ASSERT( + true == this->m_buffers[id].allocated, + static_cast(id), + static_cast(this->m_mgrId)); + FW_ASSERT( + reinterpret_cast(fwBuffer.getData()) >= this->m_buffers[id].memory, + static_cast(id), + static_cast(this->m_mgrId)); + FW_ASSERT( + reinterpret_cast(fwBuffer.getData()) < (this->m_buffers[id].memory + this->m_buffers[id].size), + static_cast(id), + static_cast(this->m_mgrId)); // user can make smaller for their own purposes, but it shouldn't be bigger - FW_ASSERT(fwBuffer.getSize() <= this->m_buffers[id].size,id,this->m_mgrId); + FW_ASSERT( + fwBuffer.getSize() <= this->m_buffers[id].size, + static_cast(id), + static_cast(this->m_mgrId)); // clear the allocated flag this->m_buffers[id].allocated = false; this->m_currBuffs--; @@ -180,7 +199,10 @@ namespace Svc { void *memory = allocator.allocate(memId,allocatedSize,recoverable); // make sure the memory returns was non-zero and the size requested FW_ASSERT(memory); - FW_ASSERT(memorySize == allocatedSize,memorySize,allocatedSize); + FW_ASSERT( + memorySize == allocatedSize, + static_cast(memorySize), + static_cast(allocatedSize)); // structs will be at beginning of memory this->m_buffers = static_cast(memory); // memory buffers will be at end of structs in memory, so compute that memory as the beginning of the @@ -212,7 +234,10 @@ namespace Svc { static_cast(reinterpret_cast(CURR_PTR)), static_cast(reinterpret_cast(END_PTR))); // secondary init verification - FW_ASSERT(currStruct == this->m_numStructs,currStruct,this->m_numStructs); + FW_ASSERT( + currStruct == this->m_numStructs, + static_cast(currStruct), + static_cast(this->m_numStructs)); // indicate setup is done this->m_setup = true; } diff --git a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp index 4d5fe2b69c..19c9657e68 100644 --- a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp +++ b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp @@ -39,7 +39,7 @@ namespace Svc { this->m_entryTable[slot].opcode = opCode; this->m_entryTable[slot].port = portNum; this->m_entryTable[slot].used = true; - this->log_DIAGNOSTIC_OpCodeRegistered(opCode,portNum,slot); + this->log_DIAGNOSTIC_OpCodeRegistered(opCode,portNum,static_cast(slot)); slotFound = true; } else if ((this->m_entryTable[slot].used) && (this->m_entryTable[slot].opcode == opCode) && @@ -48,10 +48,10 @@ namespace Svc { slotFound = true; this->log_DIAGNOSTIC_OpCodeReregistered(opCode,portNum); } else if (this->m_entryTable[slot].used) { // make sure no duplicates - FW_ASSERT(this->m_entryTable[slot].opcode != opCode, opCode); + FW_ASSERT(this->m_entryTable[slot].opcode != opCode, static_cast(opCode)); } } - FW_ASSERT(slotFound,opCode); + FW_ASSERT(slotFound,static_cast(opCode)); } void CommandDispatcherImpl::compCmdStat_handler(NATIVE_INT_TYPE portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) { @@ -123,7 +123,7 @@ namespace Svc { pendingFound = true; this->m_sequenceTracker[pending].used = true; this->m_sequenceTracker[pending].opCode = cmdPkt.getOpCode(); - this->m_sequenceTracker[pending].seq = this->m_seq; + this->m_sequenceTracker[pending].seq = static_cast(this->m_seq); this->m_sequenceTracker[pending].context = context; this->m_sequenceTracker[pending].callerPort = portNum; break; @@ -140,7 +140,11 @@ namespace Svc { } } // end if status port connected // pass arguments to argument buffer - this->compCmdSend_out(this->m_entryTable[entry].port,cmdPkt.getOpCode(),this->m_seq,cmdPkt.getArgBuffer()); + this->compCmdSend_out( + this->m_entryTable[entry].port, + cmdPkt.getOpCode(), + static_cast(this->m_seq), + cmdPkt.getArgBuffer()); // log dispatched command this->log_COMMAND_OpCodeDispatched(cmdPkt.getOpCode(),this->m_entryTable[entry].port); diff --git a/Svc/CmdSequencer/FPrimeSequence.cpp b/Svc/CmdSequencer/FPrimeSequence.cpp index 4c8dff10f0..a94624f8f3 100644 --- a/Svc/CmdSequencer/FPrimeSequence.cpp +++ b/Svc/CmdSequencer/FPrimeSequence.cpp @@ -35,7 +35,7 @@ namespace Svc { { FW_ASSERT(buffer); for(NATIVE_UINT_TYPE index = 0; index < bufferSize; index++) { - this->m_computed = static_cast(update_crc_32(this->m_computed, buffer[index])); + this->m_computed = static_cast(update_crc_32(this->m_computed, static_cast(buffer[index]))); } } @@ -169,7 +169,7 @@ namespace Svc { const NATIVE_UINT_TYPE capacity = buffer.getBuffCapacity(); FW_ASSERT( capacity >= static_cast(readLen), - capacity, + static_cast(capacity), static_cast(readLen) ); Os::File::Status fileStatus = file.read( @@ -304,11 +304,11 @@ namespace Svc { if (buffSize < crcSize) { this->m_events.fileInvalid( CmdSequencer_FileReadStage::READ_SEQ_CRC, - buffSize + static_cast(buffSize) ); return false; } - FW_ASSERT(buffSize >= crcSize, buffSize, crcSize); + FW_ASSERT(buffSize >= crcSize, static_cast(buffSize), crcSize); const NATIVE_UINT_TYPE dataSize = buffSize - crcSize; // Create a CRC buffer pointing at the CRC in the main buffer, after the data Fw::ExternalSerializeBuffer crcBuff(&buffAddr[dataSize], crcSize); diff --git a/Svc/CmdSequencer/Sequence.cpp b/Svc/CmdSequencer/Sequence.cpp index 5a0ec53d48..4f905d5567 100644 --- a/Svc/CmdSequencer/Sequence.cpp +++ b/Svc/CmdSequencer/Sequence.cpp @@ -85,7 +85,7 @@ namespace Svc { bool recoverable; this->m_allocatorId = identifier; this->m_buffer.setExtBuffer( - static_cast(allocator.allocate(identifier,bytes,recoverable)), + static_cast(allocator.allocate(static_cast(identifier),bytes,recoverable)), bytes ); } @@ -94,7 +94,7 @@ namespace Svc { deallocateBuffer(Fw::MemAllocator& allocator) { allocator.deallocate( - this->m_allocatorId, + static_cast(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 cf9c30dd98..051f90b853 100644 --- a/Svc/CmdSequencer/formats/AMPCSSequence.cpp +++ b/Svc/CmdSequencer/formats/AMPCSSequence.cpp @@ -88,7 +88,8 @@ namespace Svc { fileStatus == Os::FileSystem::OP_OK and fileSize >= static_cast(sizeof(this->m_sequenceHeader)) ) { - this->m_header.m_fileSize = static_cast(fileSize - sizeof(this->m_sequenceHeader)); + this->m_header.m_fileSize = + static_cast(fileSize - static_cast(sizeof(this->m_sequenceHeader))); } else { this->m_events.fileInvalid( @@ -256,8 +257,8 @@ namespace Svc { const NATIVE_UINT_TYPE buffLen = this->m_buffer.getBuffLength(); FW_ASSERT( buffLen == this->m_header.m_fileSize, - buffLen, - this->m_header.m_fileSize + static_cast(buffLen), + static_cast(this->m_header.m_fileSize) ); this->m_crc.update(buffAddr, buffLen); this->m_crc.finalize(); @@ -435,7 +436,7 @@ namespace Svc { const U32 fixedBuffLen = comBuffer.getBuffLength(); FW_ASSERT( fixedBuffLen == sizeof(cmdDescriptor) + sizeof(zeros), - fixedBuffLen + static_cast(fixedBuffLen) ); const U32 totalBuffLen = fixedBuffLen + cmdLength; status = comBuffer.setBuffLen(totalBuffLen); diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index 6c651bf59b..9f121f9be4 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -64,11 +64,12 @@ namespace Svc { this->m_maxFileSize = maxFileSize; this->m_storeBufferLength = storeBufferLength; if( this->m_storeBufferLength ) { - FW_ASSERT(maxFileSize > sizeof(U16), maxFileSize); + FW_ASSERT(maxFileSize > sizeof(U16), static_cast(maxFileSize)); } FW_ASSERT(Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix)) < sizeof(this->m_filePrefix), - Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix)), sizeof(this->m_filePrefix)); // ensure that file prefix is not too big + static_cast(Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix))), + sizeof(this->m_filePrefix)); // ensure that file prefix is not too big (void)Fw::StringUtils::string_copy(this->m_filePrefix, incomingFilePrefix, sizeof(this->m_filePrefix)); @@ -118,7 +119,7 @@ namespace Svc { U32 size32 = data.getBuffLength(); // ComLogger only writes 16-bit sizes to save space // on disk: - FW_ASSERT(size32 < 65536, size32); + FW_ASSERT(size32 < 65536, static_cast(size32)); U16 size = size32 & 0xFFFF; // Close the file if it will be too big: @@ -179,16 +180,29 @@ namespace Svc { // Create filename: Fw::Time timestamp = getTime(); memset(this->m_fileName, 0, sizeof(this->m_fileName)); - bytesCopied = snprintf(this->m_fileName, sizeof(this->m_fileName), "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com", - this->m_filePrefix, static_cast(timestamp.getTimeBase()), timestamp.getSeconds(), timestamp.getUSeconds()); + bytesCopied = static_cast(snprintf( + this->m_fileName, + sizeof(this->m_fileName), + "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com", + this->m_filePrefix, + static_cast(timestamp.getTimeBase()), + timestamp.getSeconds(), + timestamp.getUSeconds())); // "A return value of size or more means that the output was truncated" // See here: http://linux.die.net/man/3/snprintf FW_ASSERT( bytesCopied < sizeof(this->m_fileName) ); // Create sha filename: - bytesCopied = snprintf(this->m_hashFileName, sizeof(this->m_hashFileName), "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com%s", - this->m_filePrefix, static_cast(timestamp.getTimeBase()), timestamp.getSeconds(), timestamp.getUSeconds(), Utils::Hash::getFileExtensionString()); + bytesCopied = static_cast(snprintf( + this->m_hashFileName, + sizeof(this->m_hashFileName), + "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com%s", + this->m_filePrefix, + static_cast(timestamp.getTimeBase()), + timestamp.getSeconds(), + timestamp.getUSeconds(), + Utils::Hash::getFileExtensionString())); FW_ASSERT( bytesCopied < sizeof(this->m_hashFileName) ); Os::File::Status ret = m_file.open(this->m_fileName, Os::File::OPEN_WRITE); diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index de05ec3d72..a76a5be38b 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(-1), + m_allocationId(static_cast(-1)), m_allocator(nullptr), m_allocation(nullptr) { // Initialize throttles to "off" @@ -71,7 +71,9 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, for (NATIVE_UINT_TYPE entryIndex = 0; entryIndex < FW_NUM_ARRAY_ELEMENTS(queueConfig.entries); entryIndex++) { // Check for valid configuration entry FW_ASSERT(queueConfig.entries[entryIndex].priority < TOTAL_PORT_COUNT, - queueConfig.entries[entryIndex].priority, TOTAL_PORT_COUNT, entryIndex); + queueConfig.entries[entryIndex].priority, + TOTAL_PORT_COUNT, + static_cast(entryIndex)); if (currentPriority == queueConfig.entries[entryIndex].priority) { // Set up the queue metadata object in order to track priority, depth, index into the queue list of the @@ -80,7 +82,7 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, QueueMetadata& entry = this->m_prioritizedList[currentPriorityIndex]; entry.priority = queueConfig.entries[entryIndex].priority; entry.depth = queueConfig.entries[entryIndex].depth; - entry.index = entryIndex; + entry.index = static_cast(entryIndex); // Message size is determined by the type of object being stored, which in turn is determined by the // index of the entry. Those lower than COM_PORT_COUNT are Fw::ComBuffers and those larger Fw::Buffer. entry.msgSize = (entryIndex < COM_PORT_COUNT) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer); @@ -117,7 +119,10 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, allocationOffset += allocationSize; } // Safety check that all memory was used as expected - FW_ASSERT(allocationOffset == totalAllocation, static_cast(allocationOffset), totalAllocation); + FW_ASSERT( + allocationOffset == totalAllocation, + static_cast(allocationOffset), + static_cast(totalAllocation)); } // ---------------------------------------------------------------------- // Handler implementations for user-defined typed input ports @@ -192,7 +197,7 @@ void ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8 FW_ASSERT(portNum >= 0, portNum); Fw::SerializeStatus status = this->m_queues[queueNum].enqueue(data, size); if (status == Fw::FW_SERIALIZE_NO_ROOM_LEFT && !this->m_throttle[queueNum]) { - this->log_WARNING_HI_QueueOverflow(queueType, portNum); + this->log_WARNING_HI_QueueOverflow(queueType, static_cast(portNum)); this->m_throttle[queueNum] = true; } // When the component is already in READY state process the queue to send out the next available message immediately diff --git a/Svc/Deframer/Deframer.cpp b/Svc/Deframer/Deframer.cpp index 8e1356052f..782ffe682a 100644 --- a/Svc/Deframer/Deframer.cpp +++ b/Svc/Deframer/Deframer.cpp @@ -209,7 +209,11 @@ void Deframer ::processBuffer(Fw::Buffer& buffer) { const Fw::SerializeStatus status = m_inRing.serialize(&bufferData[offset], serSize); // If data does not fit, there is a coding error - FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status, offset, serSize); + FW_ASSERT( + status == Fw::FW_SERIALIZE_OK, + status, + static_cast(offset), + static_cast(serSize)); // Process the data processRing(); // Update buffer offset and remaining @@ -220,7 +224,7 @@ void Deframer ::processBuffer(Fw::Buffer& buffer) { // In every iteration, either remaining == 0 and we break out // of the loop, or we consume at least one byte from the buffer. // So there should be no data left in the buffer. - FW_ASSERT(remaining == 0, remaining); + FW_ASSERT(remaining == 0, static_cast(remaining)); } @@ -253,28 +257,34 @@ void Deframer ::processRing() { // Deframing protocol must not consume data in the ring buffer FW_ASSERT( m_inRing.get_allocated_size() == remaining, - m_inRing.get_allocated_size(), - remaining + static_cast(m_inRing.get_allocated_size()), + static_cast(remaining) ); // On successful deframing, consume data from the ring buffer now if (status == DeframingProtocol::DEFRAMING_STATUS_SUCCESS) { // If deframing succeeded, protocol should set needed // to a non-zero value FW_ASSERT(needed != 0); - FW_ASSERT(needed <= remaining, needed, remaining); + FW_ASSERT( + needed <= remaining, + static_cast(needed), + static_cast(remaining)); m_inRing.rotate(needed); FW_ASSERT( m_inRing.get_allocated_size() == remaining - needed, - m_inRing.get_allocated_size(), - remaining, - needed + static_cast(m_inRing.get_allocated_size()), + static_cast(remaining), + static_cast(needed) ); } // More data needed else if (status == DeframingProtocol::DEFRAMING_MORE_NEEDED) { // Deframing protocol should not report "more is needed" // unless more is needed - FW_ASSERT(needed > remaining, needed, remaining); + FW_ASSERT( + needed > remaining, + static_cast(needed), + static_cast(remaining)); // Break out of loop: suspend deframing until we receive // another buffer break; @@ -285,8 +295,8 @@ void Deframer ::processRing() { m_inRing.rotate(1); FW_ASSERT( m_inRing.get_allocated_size() == remaining - 1, - m_inRing.get_allocated_size(), - remaining + static_cast(m_inRing.get_allocated_size()), + static_cast(remaining) ); // Log checksum errors // This is likely a real error, not an artifact of other data corruption @@ -298,7 +308,7 @@ void Deframer ::processRing() { // If more not needed, circular buffer should be empty if (status != DeframingProtocol::DEFRAMING_MORE_NEEDED) { - FW_ASSERT(remaining == 0, remaining); + FW_ASSERT(remaining == 0, static_cast(remaining)); } } diff --git a/Svc/DpWriter/DpWriter.cpp b/Svc/DpWriter/DpWriter.cpp index 429dbb3985..435bd56266 100644 --- a/Svc/DpWriter/DpWriter.cpp +++ b/Svc/DpWriter/DpWriter.cpp @@ -186,11 +186,11 @@ Fw::Success::T DpWriter::writeFile(const Fw::DpContainer& container, // Set write size to file size // On entry to the write call, this is the number of bytes to write // On return from the write call, this is the number of bytes written - FwSignedSizeType writeSize = fileSize; + FwSignedSizeType writeSize = static_cast(fileSize); fileStatus = file.write(buffer.getData(), writeSize); // If a successful write occurred, then update the number of bytes written if (fileStatus == Os::File::OP_OK) { - this->m_numBytesWritten += writeSize; + this->m_numBytesWritten += static_cast(writeSize); } if ((fileStatus == Os::File::OP_OK) and (writeSize == static_cast(fileSize))) { // If the write status is success, and the number of bytes written diff --git a/Svc/FileDownlink/FileDownlink.cpp b/Svc/FileDownlink/FileDownlink.cpp index 9fe8363254..47cb420f19 100644 --- a/Svc/FileDownlink/FileDownlink.cpp +++ b/Svc/FileDownlink/FileDownlink.cpp @@ -67,7 +67,7 @@ namespace Svc { Os::Queue::QueueStatus stat = m_fileQueue.create( Os::QueueString("fileDownlinkQueue"), - fileQueueDepth, + static_cast(fileQueueDepth), sizeof(struct FileEntry) ); FW_ASSERT(stat == Os::Queue::QUEUE_OK, stat); @@ -477,7 +477,10 @@ namespace Svc { { const U32 bufferSize = filePacket.bufferSize(); FW_ASSERT(this->m_buffer.getData() != nullptr); - FW_ASSERT(this->m_buffer.getSize() >= bufferSize, bufferSize, this->m_buffer.getSize()); + FW_ASSERT( + this->m_buffer.getSize() >= bufferSize, + static_cast(bufferSize), + static_cast(this->m_buffer.getSize())); const Fw::SerializeStatus status = filePacket.toBuffer(this->m_buffer); FW_ASSERT(status == Fw::FW_SERIALIZE_OK); // set the buffer size to the packet size diff --git a/Svc/FileManager/FileManager.cpp b/Svc/FileManager/FileManager.cpp index 09823c19d4..583056237d 100644 --- a/Svc/FileManager/FileManager.cpp +++ b/Svc/FileManager/FileManager.cpp @@ -180,7 +180,7 @@ namespace Svc { ); } else { this->log_WARNING_HI_ShellCommandFailed( - logStringCommand, status + logStringCommand, static_cast(status) ); } this->emitTelemetry( diff --git a/Svc/FramingProtocol/FprimeProtocol.cpp b/Svc/FramingProtocol/FprimeProtocol.cpp index c3a626662a..14f1d5b4be 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(), 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); @@ -73,7 +73,7 @@ bool FprimeDeframing::validate(Types::CircularBuffer& ring, U32 size) { hash.final(hashBuffer); // Now loop through the hash digest bytes and check for equality for (U32 i = 0; i < HASH_DIGEST_LENGTH; i++) { - U8 calc = static_cast(hashBuffer.getBuffAddr()[i]); + U8 calc = static_cast(hashBuffer.getBuffAddr()[i]); U8 sent = 0; const Fw::SerializeStatus status = ring.peek(sent, size + i); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status); diff --git a/Svc/GenericHub/GenericHubComponentImpl.cpp b/Svc/GenericHub/GenericHubComponentImpl.cpp index c80bf814fe..9a21b04184 100644 --- a/Svc/GenericHub/GenericHubComponentImpl.cpp +++ b/Svc/GenericHub/GenericHubComponentImpl.cpp @@ -93,13 +93,13 @@ void GenericHubComponentImpl ::dataIn_handler(const NATIVE_INT_TYPE portNum, Fw: Fw::ExternalSerializeBuffer wrapper(rawData, rawSize); status = wrapper.setBuffLen(rawSize); FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); - portOut_out(port, wrapper); + portOut_out(static_cast(port), wrapper); // Deallocate the existing buffer dataInDeallocate_out(0, fwBuffer); } else if (type == HUB_TYPE_BUFFER) { // Fw::Buffers can reuse the existing data buffer as the storage type! No deallocation done. fwBuffer.set(rawData, rawSize, fwBuffer.getContext()); - buffersOut_out(port, fwBuffer); + buffersOut_out(static_cast(port), fwBuffer); } else if (type == HUB_TYPE_EVENT) { FwEventIdType id; Fw::Time timeTag; @@ -117,7 +117,7 @@ void GenericHubComponentImpl ::dataIn_handler(const NATIVE_INT_TYPE portNum, Fw: FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); // Send it! - this->LogSend_out(port, id, timeTag, severity, args); + this->LogSend_out(static_cast(port), id, timeTag, severity, args); // Deallocate the existing buffer dataInDeallocate_out(0, fwBuffer); @@ -135,7 +135,7 @@ void GenericHubComponentImpl ::dataIn_handler(const NATIVE_INT_TYPE portNum, Fw: FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast(status)); // Send it! - this->TlmSend_out(port, id, timeTag, val); + this->TlmSend_out(static_cast(port), id, timeTag, val); // Deallocate the existing buffer dataInDeallocate_out(0, fwBuffer); diff --git a/Svc/Health/HealthComponentImpl.cpp b/Svc/Health/HealthComponentImpl.cpp index ac920e5e24..01f1cb4bfd 100644 --- a/Svc/Health/HealthComponentImpl.cpp +++ b/Svc/Health/HealthComponentImpl.cpp @@ -38,7 +38,7 @@ namespace Svc { void HealthImpl::init(const NATIVE_INT_TYPE queueDepth, const NATIVE_INT_TYPE instance) { HealthComponentBase::init(queueDepth, instance); - this->queue_depth = queueDepth; + this->queue_depth = static_cast(queueDepth); } @@ -48,12 +48,15 @@ namespace Svc { // make sure not asking for more pings than ports FW_ASSERT(numPingEntries <= NUM_PINGSEND_OUTPUT_PORTS); - this->m_numPingEntries = numPingEntries; + this->m_numPingEntries = static_cast(numPingEntries); this->m_watchDogCode = watchDogCode; // copy entries to private data for (NATIVE_INT_TYPE entry = 0; entry < numPingEntries; entry++) { - FW_ASSERT(pingEntries[entry].warnCycles <= pingEntries[entry].fatalCycles, pingEntries[entry].warnCycles, pingEntries[entry].fatalCycles); + FW_ASSERT( + pingEntries[entry].warnCycles <= pingEntries[entry].fatalCycles, + static_cast(pingEntries[entry].warnCycles), + static_cast(pingEntries[entry].fatalCycles)); this->m_pingTrackerEntries[entry].entry = pingEntries[entry]; this->m_pingTrackerEntries[entry].cycleCount = 0; this->m_pingTrackerEntries[entry].enabled = Fw::Enabled::ENABLED; @@ -104,7 +107,7 @@ namespace Svc { // start a ping this->m_pingTrackerEntries[entry].key = this->m_key; // send ping - this->PingSend_out(entry, this->m_pingTrackerEntries[entry].key); + this->PingSend_out(static_cast(entry), this->m_pingTrackerEntries[entry].key); // increment key this->m_key++; // increment cycles for the entry @@ -205,7 +208,7 @@ namespace Svc { // walk through entries for (NATIVE_UINT_TYPE tableEntry = 0; tableEntry < NUM_PINGSEND_OUTPUT_PORTS; tableEntry++) { if (entry == this->m_pingTrackerEntries[tableEntry].entry.entryName) { - return tableEntry; + return static_cast(tableEntry); } } Fw::LogStringArg arg = entry; diff --git a/Svc/PassiveRateGroup/PassiveRateGroup.cpp b/Svc/PassiveRateGroup/PassiveRateGroup.cpp index c04212ba98..d9e62107d8 100644 --- a/Svc/PassiveRateGroup/PassiveRateGroup.cpp +++ b/Svc/PassiveRateGroup/PassiveRateGroup.cpp @@ -33,7 +33,7 @@ void PassiveRateGroup::configure(NATIVE_INT_TYPE contexts[], NATIVE_INT_TYPE num this->m_numContexts = numContexts; // copy context values for (NATIVE_INT_TYPE entry = 0; entry < this->m_numContexts; entry++) { - this->m_contexts[entry] = contexts[entry]; + this->m_contexts[entry] = static_cast(contexts[entry]); } } diff --git a/Svc/PrmDb/PrmDbImpl.cpp b/Svc/PrmDb/PrmDbImpl.cpp index 783cfd8851..8b6b0b11ee 100644 --- a/Svc/PrmDb/PrmDbImpl.cpp +++ b/Svc/PrmDb/PrmDbImpl.cpp @@ -154,7 +154,7 @@ namespace Svc { stat = paramFile.write(&delim,writeSize,Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::DELIMITER,numRecords,stat); + this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::DELIMITER,static_cast(numRecords),stat); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } @@ -162,7 +162,7 @@ namespace Svc { this->unLock(); this->log_WARNING_HI_PrmFileWriteError( PrmWriteError::DELIMITER_SIZE, - numRecords, + static_cast(numRecords), static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; @@ -181,7 +181,7 @@ namespace Svc { stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::RECORD_SIZE,numRecords,stat); + this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::RECORD_SIZE,static_cast(numRecords),stat); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } @@ -189,7 +189,7 @@ namespace Svc { this->unLock(); this->log_WARNING_HI_PrmFileWriteError( PrmWriteError::RECORD_SIZE_SIZE, - numRecords, + static_cast(numRecords), static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; @@ -209,7 +209,7 @@ namespace Svc { stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_ID,numRecords,stat); + this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_ID,static_cast(numRecords),stat); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } @@ -217,7 +217,7 @@ namespace Svc { this->unLock(); this->log_WARNING_HI_PrmFileWriteError( PrmWriteError::PARAMETER_ID_SIZE, - numRecords, + static_cast(numRecords), static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; @@ -229,7 +229,7 @@ namespace Svc { stat = paramFile.write(this->m_db[entry].val.getBuffAddr(),writeSize,Os::File::WaitType::WAIT); if (stat != Os::File::OP_OK) { this->unLock(); - this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_VALUE,numRecords,stat); + this->log_WARNING_HI_PrmFileWriteError(PrmWriteError::PARAMETER_VALUE,static_cast(numRecords),stat); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; } @@ -237,7 +237,7 @@ namespace Svc { this->unLock(); this->log_WARNING_HI_PrmFileWriteError( PrmWriteError::PARAMETER_VALUE_SIZE, - numRecords, + static_cast(numRecords), static_cast(writeSize)); this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::EXECUTION_ERROR); return; @@ -286,17 +286,17 @@ namespace Svc { } if (fStat != Os::File::OP_OK) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER,recordNum,fStat); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER,static_cast(recordNum),fStat); return; } if (sizeof(delimiter) != readSize) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER_SIZE,recordNum,static_cast(readSize)); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER_SIZE,static_cast(recordNum),static_cast(readSize)); return; } if (PRMDB_ENTRY_DELIMITER != delimiter) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER_VALUE,recordNum,delimiter); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::DELIMITER_VALUE,static_cast(recordNum),delimiter); return; } @@ -306,11 +306,11 @@ namespace Svc { fStat = paramFile.read(buff.getBuffAddr(),readSize,Os::File::WaitType::WAIT); if (fStat != Os::File::OP_OK) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE,recordNum,fStat); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE,static_cast(recordNum),fStat); return; } if (sizeof(recordSize) != readSize) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE_SIZE,recordNum,static_cast(readSize)); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE_SIZE,static_cast(recordNum),static_cast(readSize)); return; } // set serialized size to read size @@ -326,7 +326,7 @@ namespace Svc { // sanity check value. It can't be larger than the maximum parameter buffer size + id // or smaller than the record id if ((recordSize > FW_PARAM_BUFFER_MAX_SIZE + sizeof(U32)) or (recordSize < sizeof(U32))) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE_VALUE,recordNum,recordSize); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::RECORD_SIZE_VALUE,static_cast(recordNum),static_cast(recordSize)); return; } @@ -336,11 +336,11 @@ namespace Svc { fStat = paramFile.read(buff.getBuffAddr(),readSize,Os::File::WaitType::WAIT); if (fStat != Os::File::OP_OK) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_ID,recordNum,fStat); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_ID,static_cast(recordNum),fStat); return; } if (sizeof(parameterId) != static_cast(readSize)) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_ID_SIZE,recordNum,static_cast(readSize)); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_ID_SIZE,static_cast(recordNum),static_cast(readSize)); return; } @@ -362,11 +362,11 @@ namespace Svc { fStat = paramFile.read(this->m_db[entry].val.getBuffAddr(),readSize); if (fStat != Os::File::OP_OK) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_VALUE,recordNum,fStat); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_VALUE,static_cast(recordNum),fStat); return; } if (static_cast(readSize) != recordSize-sizeof(parameterId)) { - this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_VALUE_SIZE,recordNum,static_cast(readSize)); + this->log_WARNING_HI_PrmFileReadError(PrmReadError::PARAMETER_VALUE_SIZE,static_cast(recordNum),static_cast(readSize)); return; } diff --git a/Svc/RateGroupDriver/RateGroupDriver.cpp b/Svc/RateGroupDriver/RateGroupDriver.cpp index cc9e3515d1..6875019534 100644 --- a/Svc/RateGroupDriver/RateGroupDriver.cpp +++ b/Svc/RateGroupDriver/RateGroupDriver.cpp @@ -52,9 +52,9 @@ namespace Svc { // it would be called every fourth invocation of the CycleIn port. for (NATIVE_UINT_TYPE entry = 0; entry < RateGroupDriver::DIVIDER_SIZE; entry++) { if (this->m_dividers[entry].divisor != 0) { - if (this->isConnected_CycleOut_OutputPort(entry)) { + if (this->isConnected_CycleOut_OutputPort(static_cast(entry))) { if ((this->m_ticks % this->m_dividers[entry].divisor) == this->m_dividers[entry].offset) { - this->CycleOut_out(entry,cycleStart); + this->CycleOut_out(static_cast(entry),cycleStart); } } } diff --git a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp index a50b8de30b..d7f6e1312c 100644 --- a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp +++ b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp @@ -42,7 +42,10 @@ void StaticMemoryComponentImpl ::bufferDeallocate_handler(const NATIVE_INT_TYPE FW_ASSERT(m_allocated[portNum], portNum); // It is also an error to deallocate before returning // Check the memory returned is within the region FW_ASSERT(fwBuffer.getData() >= m_static_memory[portNum]); - FW_ASSERT((fwBuffer.getData() + fwBuffer.getSize()) <= (m_static_memory[portNum] + sizeof(m_static_memory[0])), fwBuffer.getSize(), sizeof(m_static_memory[0])); + FW_ASSERT( + (fwBuffer.getData() + fwBuffer.getSize()) <= (m_static_memory[portNum] + sizeof(m_static_memory[0])), + static_cast(fwBuffer.getSize()), + sizeof(m_static_memory[0])); m_allocated[portNum] = false; } diff --git a/Svc/TlmPacketizer/TlmPacketizer.cpp b/Svc/TlmPacketizer/TlmPacketizer.cpp index 9274d1bc4e..4c2d693828 100644 --- a/Svc/TlmPacketizer/TlmPacketizer.cpp +++ b/Svc/TlmPacketizer/TlmPacketizer.cpp @@ -58,14 +58,14 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, const NATIVE_UINT_TYPE startLevel) { FW_ASSERT(packetList.list); FW_ASSERT(ignoreList.list); - FW_ASSERT(packetList.numEntries <= MAX_PACKETIZER_PACKETS, packetList.numEntries); + FW_ASSERT(packetList.numEntries <= MAX_PACKETIZER_PACKETS, static_cast(packetList.numEntries)); // validate packet sizes against maximum com buffer size and populate hash // table for (NATIVE_UINT_TYPE pktEntry = 0; pktEntry < packetList.numEntries; pktEntry++) { // Initial size is packetized telemetry descriptor + size of time tag + sizeof packet ID NATIVE_UINT_TYPE packetLen = sizeof(FwPacketDescriptorType) + Fw::Time::SERIALIZED_SIZE + sizeof(FwTlmPacketizeIdType); - FW_ASSERT(packetList.list[pktEntry]->list, pktEntry); + FW_ASSERT(packetList.list[pktEntry]->list, static_cast(pktEntry)); // add up entries for each defined packet for (NATIVE_UINT_TYPE tlmEntry = 0; tlmEntry < packetList.list[pktEntry]->numEntries; tlmEntry++) { // get hash value for id @@ -78,12 +78,12 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList, entryToUse->ignored = false; entryToUse->id = id; // the offset into the buffer will be the current packet length - entryToUse->packetOffset[pktEntry] = packetLen; + entryToUse->packetOffset[pktEntry] = static_cast(packetLen); packetLen += packetList.list[pktEntry]->list[tlmEntry].size; } // end channel in packet - FW_ASSERT(packetLen <= FW_COM_BUFFER_MAX_SIZE, packetLen, pktEntry); + FW_ASSERT(packetLen <= FW_COM_BUFFER_MAX_SIZE, static_cast(packetLen), static_cast(pktEntry)); // clear contents memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(), 0, packetLen); // serialize packet descriptor and packet ID now since it will always be the same @@ -149,7 +149,7 @@ TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(FwChanIdType id) { } } else { // Make sure that we haven't run out of buckets - FW_ASSERT(this->m_tlmEntries.free < TLMPACKETIZER_HASH_BUCKETS, this->m_tlmEntries.free); + FW_ASSERT(this->m_tlmEntries.free < TLMPACKETIZER_HASH_BUCKETS, static_cast(this->m_tlmEntries.free)); // add new bucket from free list entryToUse = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++]; // Coverity warning about null dereference - see if it happens @@ -166,7 +166,7 @@ TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(FwChanIdType id) { } } else { // Make sure that we haven't run out of buckets - FW_ASSERT(this->m_tlmEntries.free < TLMPACKETIZER_HASH_BUCKETS, this->m_tlmEntries.free); + FW_ASSERT(this->m_tlmEntries.free < TLMPACKETIZER_HASH_BUCKETS, static_cast(this->m_tlmEntries.free)); // create new entry at slot head this->m_tlmEntries.slots[index] = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++]; entryToUse = this->m_tlmEntries.slots[index]; From 402053f4ce089dc3b6a7bc1f297b26a0bfbc4b9a Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Tue, 9 Apr 2024 20:23:54 +0200 Subject: [PATCH 08/21] Fix macOS issue --- Os/MacOs/IPCQueueStub.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Os/MacOs/IPCQueueStub.cpp b/Os/MacOs/IPCQueueStub.cpp index 1de3515eae..d7aa27b0f5 100644 --- a/Os/MacOs/IPCQueueStub.cpp +++ b/Os/MacOs/IPCQueueStub.cpp @@ -43,7 +43,7 @@ namespace Os { (void) pthread_mutex_destroy(&this->queueLock); } bool create(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize) { - return queue.create(depth, msgSize); + return queue.create(static_cast(depth), msgSize); } BufferQueue queue; pthread_cond_t queueNotEmpty; @@ -107,7 +107,7 @@ namespace Os { /////////////////////////////// // Push item onto queue: - bool pushSucceeded = queue->push(buffer, size, priority); + bool pushSucceeded = queue->push(buffer, static_cast(size), priority); if(pushSucceeded) { // Push worked - wake up a thread that might be waiting on @@ -151,7 +151,7 @@ namespace Os { } // Push item onto queue: - bool pushSucceeded = queue->push(buffer, size, priority); + bool pushSucceeded = queue->push(buffer, static_cast(size), priority); // The only reason push would not succeed is if the queue // was full. Since we waited for the queue to NOT be full @@ -262,7 +262,7 @@ namespace Os { pthread_mutex_t* queueLock = &queueHandle->queueLock; NATIVE_INT_TYPE ret; - NATIVE_UINT_TYPE size = capacity; + NATIVE_UINT_TYPE size = static_cast(capacity); NATIVE_INT_TYPE pri = 0; Queue::QueueStatus status = Queue::QUEUE_OK; @@ -346,7 +346,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getCount(); + return static_cast(queue->getCount()); } NATIVE_INT_TYPE IPCQueue::getMaxMsgs() const { @@ -355,7 +355,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getMaxCount(); + return static_cast(queue->getMaxCount()); } NATIVE_INT_TYPE IPCQueue::getQueueSize() const { @@ -364,7 +364,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getDepth(); + return static_cast(queue->getDepth()); } NATIVE_INT_TYPE IPCQueue::getMsgSize() const { @@ -373,7 +373,7 @@ namespace Os { return 0; } BufferQueue* queue = &queueHandle->queue; - return queue->getMsgSize(); + return static_cast(queue->getMsgSize()); } } From cc9abc1447f24d0a160a5d2dc7cd673900b4e3f5 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Tue, 9 Apr 2024 23:22:05 +0200 Subject: [PATCH 09/21] Fix last macOS IPCQueueStub warning --- Os/MacOs/IPCQueueStub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Os/MacOs/IPCQueueStub.cpp b/Os/MacOs/IPCQueueStub.cpp index d7aa27b0f5..83a947829f 100644 --- a/Os/MacOs/IPCQueueStub.cpp +++ b/Os/MacOs/IPCQueueStub.cpp @@ -43,7 +43,7 @@ namespace Os { (void) pthread_mutex_destroy(&this->queueLock); } bool create(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize) { - return queue.create(static_cast(depth), msgSize); + return queue.create(static_cast(depth), static_cast(msgSize)); } BufferQueue queue; pthread_cond_t queueNotEmpty; From e206b6d354ae5d5a25313228d73765a1b0cfa373 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Wed, 10 Apr 2024 22:06:55 +0200 Subject: [PATCH 10/21] Last Os-MacOs warning fix --- Os/MacOs/SystemResources.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Os/MacOs/SystemResources.cpp b/Os/MacOs/SystemResources.cpp index 500ba129c7..7df6634af5 100644 --- a/Os/MacOs/SystemResources.cpp +++ b/Os/MacOs/SystemResources.cpp @@ -88,7 +88,7 @@ kern_return_t cpu_by_index(U32 cpu_index, FwSizeType& used, FwSizeType& total) { if (cpu_count <= cpu_index) { stat = KERN_FAILURE; } else if (KERN_SUCCESS == stat) { - FW_ASSERT(cpu_count > cpu_index, cpu_count, cpu_index); // Will fail if the CPU count changes while running + FW_ASSERT(cpu_count > cpu_index, static_cast(cpu_count), static_cast(cpu_index)); // Will fail if the CPU count changes while running processor_cpu_load_info per_cpu_info = cpu_load_info[(cpu_count > cpu_index) ? cpu_index : 0]; // Total the ticks across the different states: idle, system, user, etc... From a4b7f84369bdb6ba195ddac5a6f90f5b45e5f097 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Mon, 15 Apr 2024 23:42:33 +0200 Subject: [PATCH 11/21] Fix merge conflict --- Fw/Types/Serializable.cpp | 351 -------------------------------------- 1 file changed, 351 deletions(-) diff --git a/Fw/Types/Serializable.cpp b/Fw/Types/Serializable.cpp index f3f6d70d93..9fad99ba74 100644 --- a/Fw/Types/Serializable.cpp +++ b/Fw/Types/Serializable.cpp @@ -40,27 +40,6 @@ SerializeBufferBase::SerializeBufferBase() : m_serLoc(0), m_deserLoc(0) {} SerializeBufferBase::~SerializeBufferBase() {} -<<<<<<< HEAD - void SerializeBufferBase::copyFrom(const SerializeBufferBase& src) { - this->m_serLoc = src.m_serLoc; - this->m_deserLoc = src.m_deserLoc; - FW_ASSERT(src.getBuffAddr()); - FW_ASSERT(this->getBuffAddr()); - // destination has to be same or bigger - FW_ASSERT( - src.getBuffLength() <= this->getBuffCapacity(), - static_cast(src.getBuffLength()), - static_cast(this->getBuffLength())); - (void) memcpy(this->getBuffAddr(),src.getBuffAddr(),this->m_serLoc); - } - - // Copy constructor doesn't make sense in this virtual class as there is nothing to copy. Derived classes should - // call the empty constructor and then call their own copy function - SerializeBufferBase& SerializeBufferBase::operator=(const SerializeBufferBase &src) { // lgtm[cpp/rule-of-two] - this->copyFrom(src); - return *this; - } -======= void SerializeBufferBase::copyFrom(const SerializeBufferBase& src) { this->m_serLoc = src.m_serLoc; this->m_deserLoc = src.m_deserLoc; @@ -70,7 +49,6 @@ void SerializeBufferBase::copyFrom(const SerializeBufferBase& src) { FW_ASSERT(src.getBuffLength() <= this->getBuffCapacity(), src.getBuffLength(), this->getBuffLength()); (void)memcpy(this->getBuffAddr(), src.getBuffAddr(), this->m_serLoc); } ->>>>>>> origin/devel // Copy constructor doesn't make sense in this virtual class as there is nothing to copy. Derived classes should // call the empty constructor and then call their own copy function @@ -79,18 +57,7 @@ SerializeBufferBase& SerializeBufferBase::operator=(const SerializeBufferBase& s return *this; } -<<<<<<< HEAD - SerializeStatus SerializeBufferBase::serialize(U8 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - this->getBuffAddr()[this->m_serLoc] = val; - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; -======= // serialization routines ->>>>>>> origin/devel SerializeStatus SerializeBufferBase::serialize(U8 val) { if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { @@ -101,38 +68,12 @@ SerializeStatus SerializeBufferBase::serialize(U8 val) { this->m_serLoc += sizeof(val); this->m_deserLoc = 0; -<<<<<<< HEAD - SerializeStatus SerializeBufferBase::serialize(I8 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val); - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; - } - -#if FW_HAS_16_BIT==1 - SerializeStatus SerializeBufferBase::serialize(U16 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - // MSB first - this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 8); - this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val); - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; -======= return FW_SERIALIZE_OK; } SerializeStatus SerializeBufferBase::serialize(I8 val) { if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; ->>>>>>> origin/devel } FW_ASSERT(this->getBuffAddr()); this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val); @@ -141,91 +82,6 @@ SerializeStatus SerializeBufferBase::serialize(I8 val) { return FW_SERIALIZE_OK; } -<<<<<<< HEAD - SerializeStatus SerializeBufferBase::serialize(I16 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - // MSB first - this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 8); - this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val); - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; - } -#endif -#if FW_HAS_32_BIT==1 - SerializeStatus SerializeBufferBase::serialize(U32 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - // MSB first - this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 24); - this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 16); - this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 8); - this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val); - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; - } - - SerializeStatus SerializeBufferBase::serialize(I32 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - // MSB first - this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 24); - this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 16); - this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 8); - this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val); - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; - } -#endif - -#if FW_HAS_64_BIT==1 - SerializeStatus SerializeBufferBase::serialize(U64 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - // MSB first - this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 56); - this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 48); - this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 40); - this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val >> 32); - this->getBuffAddr()[this->m_serLoc + 4] = static_cast(val >> 24); - this->getBuffAddr()[this->m_serLoc + 5] = static_cast(val >> 16); - this->getBuffAddr()[this->m_serLoc + 6] = static_cast(val >> 8); - this->getBuffAddr()[this->m_serLoc + 7] = static_cast(val); - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; - } - - SerializeStatus SerializeBufferBase::serialize(I64 val) { - if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { - return FW_SERIALIZE_NO_ROOM_LEFT; - } - FW_ASSERT(this->getBuffAddr()); - // MSB first - this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 56); - this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 48); - this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 40); - this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val >> 32); - this->getBuffAddr()[this->m_serLoc + 4] = static_cast(val >> 24); - this->getBuffAddr()[this->m_serLoc + 5] = static_cast(val >> 16); - this->getBuffAddr()[this->m_serLoc + 6] = static_cast(val >> 8); - this->getBuffAddr()[this->m_serLoc + 7] = static_cast(val); - this->m_serLoc += static_cast(sizeof(val)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; - } -======= #if FW_HAS_16_BIT == 1 SerializeStatus SerializeBufferBase::serialize(U16 val) { if (this->m_serLoc + static_cast(sizeof(val)) - 1 >= this->getBuffCapacity()) { @@ -323,7 +179,6 @@ SerializeStatus SerializeBufferBase::serialize(I64 val) { this->m_deserLoc = 0; return FW_SERIALIZE_OK; } ->>>>>>> origin/devel #endif #if FW_HAS_F64 && FW_HAS_64_BIT @@ -361,15 +216,9 @@ SerializeStatus SerializeBufferBase::serialize(bool val) { return FW_SERIALIZE_OK; } -<<<<<<< HEAD - this->m_serLoc += static_cast(sizeof(U8)); - this->m_deserLoc = 0; - return FW_SERIALIZE_OK; -======= SerializeStatus SerializeBufferBase::serialize(const void* val) { if (this->m_serLoc + static_cast(sizeof(void*)) - 1 >= this->getBuffCapacity()) { return FW_SERIALIZE_NO_ROOM_LEFT; ->>>>>>> origin/devel } return this->serialize(reinterpret_cast(val)); @@ -407,16 +256,9 @@ SerializeStatus SerializeBufferBase::serialize(const U8* buff, FwSizeType length return FW_SERIALIZE_OK; } -<<<<<<< HEAD - // copy buffer to our buffer - (void) memcpy(&this->getBuffAddr()[this->m_serLoc], buff, length); - this->m_serLoc += static_cast(length); - this->m_deserLoc = 0; -======= SerializeStatus SerializeBufferBase::serialize(const Serializable& val) { return val.serialize(*this); } ->>>>>>> origin/devel SerializeStatus SerializeBufferBase::serialize(const SerializeBufferBase& val) { Serializable::SizeType size = val.getBuffLength(); @@ -454,27 +296,12 @@ SerializeStatus SerializeBufferBase::serializeSize(const FwSizeType size) { // deserialization routines -<<<<<<< HEAD - SerializeStatus SerializeBufferBase::deserialize(U8 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - val = this->getBuffAddr()[this->m_deserLoc + 0]; - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; -======= SerializeStatus SerializeBufferBase::deserialize(U8& val) { // check for room if (this->getBuffLength() == this->m_deserLoc) { return FW_DESERIALIZE_BUFFER_EMPTY; } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { return FW_DESERIALIZE_SIZE_MISMATCH; ->>>>>>> origin/devel } // read from current location FW_ASSERT(this->getBuffAddr()); @@ -483,143 +310,6 @@ SerializeStatus SerializeBufferBase::deserialize(U8& val) { return FW_SERIALIZE_OK; } -<<<<<<< HEAD - SerializeStatus SerializeBufferBase::deserialize(I8 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - val = static_cast(this->getBuffAddr()[this->m_deserLoc + 0]); - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; - } - -#if FW_HAS_16_BIT==1 - SerializeStatus SerializeBufferBase::deserialize(U16 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - // MSB first - val = static_cast( - ((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) | - ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8) - ); - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; - } - - SerializeStatus SerializeBufferBase::deserialize(I16 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - // MSB first - val = static_cast( - ((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) | - ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8) - ); - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; - } -#endif -#if FW_HAS_32_BIT==1 - SerializeStatus SerializeBufferBase::deserialize(U32 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - // MSB first - val = (static_cast(this->getBuffAddr()[this->m_deserLoc + 3]) << 0) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 8) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 16) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 24); - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; - } - - SerializeStatus SerializeBufferBase::deserialize(I32 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - // MSB first - val = (static_cast(this->getBuffAddr()[this->m_deserLoc + 3]) << 0) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 8) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 16) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 24); - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; - } -#endif - -#if FW_HAS_64_BIT==1 - - SerializeStatus SerializeBufferBase::deserialize(U64 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - // MSB first - val = (static_cast(this->getBuffAddr()[this->m_deserLoc + 7]) << 0) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 6]) << 8) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 5]) << 16) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 4]) << 24) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 3]) << 32) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 40) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 48) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 56); - - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; - } - - SerializeStatus SerializeBufferBase::deserialize(I64 &val) { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < static_cast(sizeof(val))) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // read from current location - FW_ASSERT(this->getBuffAddr()); - // MSB first - val = (static_cast(this->getBuffAddr()[this->m_deserLoc + 7]) << 0) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 6]) << 8) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 5]) << 16) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 4]) << 24) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 3]) << 32) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 40) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 48) - | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 56); - this->m_deserLoc += static_cast(sizeof(val)); - return FW_SERIALIZE_OK; - } -======= SerializeStatus SerializeBufferBase::deserialize(I8& val) { // check for room if (this->getBuffLength() == this->m_deserLoc) { @@ -751,7 +441,6 @@ SerializeStatus SerializeBufferBase::deserialize(I64& val) { this->m_deserLoc += sizeof(val); return FW_SERIALIZE_OK; } ->>>>>>> origin/devel #endif #if FW_HAS_F64 @@ -792,17 +481,12 @@ SerializeStatus SerializeBufferBase::deserialize(bool& val) { return FW_SERIALIZE_OK; } -<<<<<<< HEAD - this->m_deserLoc += static_cast(sizeof(U8)); - return FW_SERIALIZE_OK; -======= SerializeStatus SerializeBufferBase::deserialize(void*& val) { // Deserialize as pointer cast, then convert to void* PlatformPointerCastType pointerCastVal = 0; const SerializeStatus stat = this->deserialize(pointerCastVal); if (stat == FW_SERIALIZE_OK) { val = reinterpret_cast(pointerCastVal); ->>>>>>> origin/devel } return stat; } @@ -876,13 +560,7 @@ SerializeStatus SerializeBufferBase::deserialize(SerializeBufferBase& val) { FW_ASSERT(val.getBuffAddr()); SerializeStatus stat = FW_SERIALIZE_OK; -<<<<<<< HEAD - this->m_deserLoc += static_cast(length); - return FW_SERIALIZE_OK; - } -======= FwSizeStoreType storedLength; ->>>>>>> origin/devel stat = this->deserialize(storedLength); @@ -984,41 +662,12 @@ SerializeStatus SerializeBufferBase::setBuff(const U8* src, Serializable::SizeTy } } -<<<<<<< HEAD - SerializeStatus SerializeBufferBase::serializeSkip(FwSizeType numBytesToSkip) - { - Fw::SerializeStatus status = FW_SERIALIZE_OK; - // compute new deser loc - const FwSizeType newSerLoc = this->m_serLoc + numBytesToSkip; - // check for room - if (newSerLoc <= this->getBuffCapacity()) { - // update deser loc - this->m_serLoc = static_cast(newSerLoc); - } - else { - status = FW_SERIALIZE_NO_ROOM_LEFT; - } - return status; - } - - SerializeStatus SerializeBufferBase::deserializeSkip(FwSizeType numBytesToSkip) - { - // check for room - if (this->getBuffLength() == this->m_deserLoc) { - return FW_DESERIALIZE_BUFFER_EMPTY; - } else if (this->getBuffLength() - this->m_deserLoc < numBytesToSkip) { - return FW_DESERIALIZE_SIZE_MISMATCH; - } - // update location in buffer to skip the value - this->m_deserLoc += static_cast(numBytesToSkip); -======= SerializeStatus SerializeBufferBase::setBuffLen(Serializable::SizeType length) { if (this->getBuffCapacity() < length) { return FW_SERIALIZE_NO_ROOM_LEFT; } else { this->m_serLoc = length; this->m_deserLoc = 0; ->>>>>>> origin/devel return FW_SERIALIZE_OK; } } From 618689be0d337ed6b0612cecaf9cfdc3c5ae4868 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Mon, 15 Apr 2024 23:50:19 +0200 Subject: [PATCH 12/21] Fix new warnings and merge conflicts --- Fw/Types/Serializable.cpp | 49 +++++++++++++++++++++------------------ Fw/Types/StringType.cpp | 16 +------------ 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/Fw/Types/Serializable.cpp b/Fw/Types/Serializable.cpp index 9fad99ba74..dfba70881f 100644 --- a/Fw/Types/Serializable.cpp +++ b/Fw/Types/Serializable.cpp @@ -46,7 +46,10 @@ void SerializeBufferBase::copyFrom(const SerializeBufferBase& src) { FW_ASSERT(src.getBuffAddr()); FW_ASSERT(this->getBuffAddr()); // destination has to be same or bigger - FW_ASSERT(src.getBuffLength() <= this->getBuffCapacity(), src.getBuffLength(), this->getBuffLength()); + FW_ASSERT( + src.getBuffLength() <= this->getBuffCapacity(), + static_cast(src.getBuffLength()), + static_cast(this->getBuffLength())); (void)memcpy(this->getBuffAddr(), src.getBuffAddr(), this->m_serLoc); } @@ -65,7 +68,7 @@ SerializeStatus SerializeBufferBase::serialize(U8 val) { } FW_ASSERT(this->getBuffAddr()); this->getBuffAddr()[this->m_serLoc] = val; - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; @@ -77,7 +80,7 @@ SerializeStatus SerializeBufferBase::serialize(I8 val) { } FW_ASSERT(this->getBuffAddr()); this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -91,7 +94,7 @@ SerializeStatus SerializeBufferBase::serialize(U16 val) { // MSB first this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -104,7 +107,7 @@ SerializeStatus SerializeBufferBase::serialize(I16 val) { // MSB first this->getBuffAddr()[this->m_serLoc + 0] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -120,7 +123,7 @@ SerializeStatus SerializeBufferBase::serialize(U32 val) { this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -135,7 +138,7 @@ SerializeStatus SerializeBufferBase::serialize(I32 val) { this->getBuffAddr()[this->m_serLoc + 1] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 2] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 3] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -156,7 +159,7 @@ SerializeStatus SerializeBufferBase::serialize(U64 val) { this->getBuffAddr()[this->m_serLoc + 5] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 6] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 7] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -175,7 +178,7 @@ SerializeStatus SerializeBufferBase::serialize(I64 val) { this->getBuffAddr()[this->m_serLoc + 5] = static_cast(val >> 16); this->getBuffAddr()[this->m_serLoc + 6] = static_cast(val >> 8); this->getBuffAddr()[this->m_serLoc + 7] = static_cast(val); - this->m_serLoc += sizeof(val); + this->m_serLoc += static_cast(sizeof(val)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -211,7 +214,7 @@ SerializeStatus SerializeBufferBase::serialize(bool val) { this->getBuffAddr()[this->m_serLoc + 0] = FW_SERIALIZE_FALSE_VALUE; } - this->m_serLoc += sizeof(U8); + this->m_serLoc += static_cast(sizeof(U8)); this->m_deserLoc = 0; return FW_SERIALIZE_OK; } @@ -250,7 +253,7 @@ SerializeStatus SerializeBufferBase::serialize(const U8* buff, FwSizeType length // copy buffer to our buffer (void)memcpy(&this->getBuffAddr()[this->m_serLoc], buff, length); - this->m_serLoc += length; + this->m_serLoc += static_cast(length); this->m_deserLoc = 0; return FW_SERIALIZE_OK; @@ -306,7 +309,7 @@ SerializeStatus SerializeBufferBase::deserialize(U8& val) { // read from current location FW_ASSERT(this->getBuffAddr()); val = this->getBuffAddr()[this->m_deserLoc + 0]; - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -320,7 +323,7 @@ SerializeStatus SerializeBufferBase::deserialize(I8& val) { // read from current location FW_ASSERT(this->getBuffAddr()); val = static_cast(this->getBuffAddr()[this->m_deserLoc + 0]); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -337,7 +340,7 @@ SerializeStatus SerializeBufferBase::deserialize(U16& val) { // MSB first val = static_cast(((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) | ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8)); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -353,7 +356,7 @@ SerializeStatus SerializeBufferBase::deserialize(I16& val) { // MSB first val = static_cast(((this->getBuffAddr()[this->m_deserLoc + 1]) << 0) | ((this->getBuffAddr()[this->m_deserLoc + 0]) << 8)); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } #endif @@ -372,7 +375,7 @@ SerializeStatus SerializeBufferBase::deserialize(U32& val) { (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 8) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 16) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 24); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -390,7 +393,7 @@ SerializeStatus SerializeBufferBase::deserialize(I32& val) { (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 8) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 16) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 24); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } #endif @@ -416,7 +419,7 @@ SerializeStatus SerializeBufferBase::deserialize(U64& val) { (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 48) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 56); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } @@ -438,7 +441,7 @@ SerializeStatus SerializeBufferBase::deserialize(I64& val) { (static_cast(this->getBuffAddr()[this->m_deserLoc + 2]) << 40) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 1]) << 48) | (static_cast(this->getBuffAddr()[this->m_deserLoc + 0]) << 56); - this->m_deserLoc += sizeof(val); + this->m_deserLoc += static_cast(sizeof(val)); return FW_SERIALIZE_OK; } #endif @@ -477,7 +480,7 @@ SerializeStatus SerializeBufferBase::deserialize(bool& val) { return FW_DESERIALIZE_FORMAT_ERROR; } - this->m_deserLoc += sizeof(U8); + this->m_deserLoc += static_cast(sizeof(U8)); return FW_SERIALIZE_OK; } @@ -548,7 +551,7 @@ SerializeStatus SerializeBufferBase::deserialize(U8* buff, FwSizeType& length, S (void)memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], length); } - this->m_deserLoc += length; + this->m_deserLoc += static_cast(length); return FW_SERIALIZE_OK; } @@ -613,7 +616,7 @@ SerializeStatus SerializeBufferBase::serializeSkip(FwSizeType numBytesToSkip) { // check for room if (newSerLoc <= this->getBuffCapacity()) { // update deser loc - this->m_serLoc = newSerLoc; + this->m_serLoc = static_cast(newSerLoc); } else { status = FW_SERIALIZE_NO_ROOM_LEFT; } @@ -628,7 +631,7 @@ SerializeStatus SerializeBufferBase::deserializeSkip(FwSizeType numBytesToSkip) return FW_DESERIALIZE_SIZE_MISMATCH; } // update location in buffer to skip the value - this->m_deserLoc += numBytesToSkip; + this->m_deserLoc += static_cast(numBytesToSkip); return FW_SERIALIZE_OK; } diff --git a/Fw/Types/StringType.cpp b/Fw/Types/StringType.cpp index b291fdd554..8dee0f94bd 100644 --- a/Fw/Types/StringType.cpp +++ b/Fw/Types/StringType.cpp @@ -42,28 +42,14 @@ bool StringBase::operator==(const StringBase& other) const { } } -<<<<<<< HEAD - bool StringBase::operator==(const CHAR* other) const { - - const CHAR *const us = this->toChar(); - if ((us == nullptr) or (other == nullptr)) { - return false; - } - - const SizeType capacity = this->getCapacity(); - const size_t result = static_cast(strncmp(us, other, capacity)); - return (result == 0); - -======= bool StringBase::operator==(const CHAR* other) const { const CHAR* const us = this->toChar(); if ((us == nullptr) or (other == nullptr)) { return false; ->>>>>>> origin/devel } const SizeType capacity = this->getCapacity(); - const size_t result = strncmp(us, other, capacity); + const size_t result = static_cast(strncmp(us, other, capacity)); return (result == 0); } From 383f7b09ac0cd2ab4319846a030817f4fdb6b1b6 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Mon, 15 Apr 2024 23:52:38 +0200 Subject: [PATCH 13/21] Reverse issues from merge conflict --- Fw/Types/StringType.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Fw/Types/StringType.cpp b/Fw/Types/StringType.cpp index 8dee0f94bd..ede8d04904 100644 --- a/Fw/Types/StringType.cpp +++ b/Fw/Types/StringType.cpp @@ -86,6 +86,15 @@ std::ostream& operator<<(std::ostream& os, const StringBase& str) { } #endif +StringBase& StringBase::operator=(const StringBase& other) { + if (this == &other) { + return *this; + } + + (void)Fw::StringUtils::string_copy(const_cast(this->toChar()), other.toChar(), this->getCapacity()); + return *this; +} + // Copy constructor doesn't make sense in this virtual class as there is nothing to copy. Derived classes should // call the empty constructor and then call their own copy function StringBase& StringBase::operator=(const CHAR* other) { // lgtm[cpp/rule-of-two] From e00c7e8c79f1e6e045b0beabf785060499552fdc Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Wed, 17 Apr 2024 22:46:41 +0200 Subject: [PATCH 14/21] Fix unit tests and one more macOS error --- Os/test/ut/file/SyntheticFileSystem.cpp | 2 +- Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Os/test/ut/file/SyntheticFileSystem.cpp b/Os/test/ut/file/SyntheticFileSystem.cpp index 24b8d0e503..b81f7c6eae 100644 --- a/Os/test/ut/file/SyntheticFileSystem.cpp +++ b/Os/test/ut/file/SyntheticFileSystem.cpp @@ -113,7 +113,7 @@ Os::File::Status SyntheticFile::read(U8* buffer, FwSignedSizeType& size, WaitTyp if (this->m_data->m_pointer >= static_cast(this->m_data->m_data.size())) { break; } - buffer[i] = this->m_data->m_data.at(static_cast(this->m_data->m_pointer)); + buffer[i] = this->m_data->m_data.at(static_cast::size_type>(this->m_data->m_pointer)); } size = i; // Checks on the shadow data to ensure consistency diff --git a/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp b/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp index c0cc750674..4ae15d9365 100644 --- a/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp +++ b/Svc/LinuxTimer/LinuxTimerComponentImplTaskDelay.cpp @@ -19,7 +19,7 @@ namespace Svc { void LinuxTimerComponentImpl::startTimer(NATIVE_INT_TYPE interval) { while (true) { - Os::Task::delay(interval); + Os::Task::delay(static_cast(interval)); this->m_mutex.lock(); bool quit = this->m_quit; this->m_mutex.unLock(); From dd983a175e921b5bed67767456e426abd7e072cd Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Wed, 17 Apr 2024 15:52:35 -0700 Subject: [PATCH 15/21] Fix macOS errors - pt 1 --- Drv/Ip/IpSocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Drv/Ip/IpSocket.cpp b/Drv/Ip/IpSocket.cpp index 64b43f4dd0..39b8e3171e 100644 --- a/Drv/Ip/IpSocket.cpp +++ b/Drv/Ip/IpSocket.cpp @@ -67,8 +67,8 @@ SocketIpStatus IpSocket::setupTimeouts(NATIVE_INT_TYPE socketFd) { #else // Set timeout socket option struct timeval timeout; - timeout.tv_sec = this->m_timeoutSeconds; - timeout.tv_usec = this->m_timeoutMicroseconds; + timeout.tv_sec = static_cast(this->m_timeoutSeconds); + timeout.tv_usec = static_cast(this->m_timeoutMicroseconds); // set socket write to timeout after 1 sec if (setsockopt(socketFd, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast(&timeout), sizeof(timeout)) < 0) { return SOCK_FAILED_TO_SET_SOCKET_OPTIONS; From af5be5b7874cc32dd16f7cb76537632c68154133 Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Wed, 17 Apr 2024 15:56:48 -0700 Subject: [PATCH 16/21] sp --- .github/actions/spelling/expect.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 0711a2f2ee..7922d56a7f 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -991,6 +991,7 @@ subgrouping subhist subhistory subpage +suseconds subseconds subtargets suppr From 2b0ee7d599f41a44a185e2763a1c21f66ce4676a Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Sun, 28 Apr 2024 11:54:23 +0200 Subject: [PATCH 17/21] Fix warnings from development --- Fw/Types/StringBase.cpp | 2 +- Svc/DpCatalog/DpCatalog.cpp | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Fw/Types/StringBase.cpp b/Fw/Types/StringBase.cpp index 9c27ad26de..4cf1a95f8d 100644 --- a/Fw/Types/StringBase.cpp +++ b/Fw/Types/StringBase.cpp @@ -122,7 +122,7 @@ StringBase::SizeType StringBase::serializedSize() const { } StringBase::SizeType StringBase::serializedTruncatedSize(FwSizeType maxLength) const { - return static_cast(sizeof(FwSizeStoreType)) + FW_MIN(this->length(), maxLength); + return static_cast(sizeof(FwSizeStoreType)) + static_cast(FW_MIN(this->length(), maxLength)); } SerializeStatus StringBase::serialize(SerializeBufferBase& buffer) const { diff --git a/Svc/DpCatalog/DpCatalog.cpp b/Svc/DpCatalog/DpCatalog.cpp index 73fe468e17..c306dc2773 100644 --- a/Svc/DpCatalog/DpCatalog.cpp +++ b/Svc/DpCatalog/DpCatalog.cpp @@ -53,7 +53,7 @@ namespace Svc { ) { // Do some assertion checks - FW_ASSERT(numDirs <= DP_MAX_DIRECTORIES, numDirs); + FW_ASSERT(numDirs <= DP_MAX_DIRECTORIES, static_cast(numDirs)); // request memory for catalog this->m_memSize = DP_MAX_FILES * (sizeof(DpStateEntry) + sizeof(DpSortedList)); @@ -61,7 +61,7 @@ namespace Svc { // request memory this->m_memPtr = allocator.allocate(memId, this->m_memSize, notUsed); // adjust to actual size if less allocated and only initialize - // if there is enough room for at least one record and memory + // if there is enough room for at least one record and memory // was allocated if ( (this->m_memSize >= (sizeof(DpSortedList) + sizeof(DpStateEntry))) and @@ -85,7 +85,7 @@ namespace Svc { } } else { - // if we don't have enough memory, set the number of records + // if we don't have enough memory, set the number of records // to zero for later detection this->m_numDpSlots = 0; } @@ -131,12 +131,12 @@ namespace Svc { this->log_ACTIVITY_LO_ProcessingDirectory(this->m_directories[dir]); U32 filesRead = 0; U32 pendingFiles = 0; - F64 pendingDpBytes = 0; + U64 pendingDpBytes = 0; Os::FileSystem::Status fsStat = Os::FileSystem::readDirectory( this->m_directories[dir].toChar(), - this->m_numDpSlots - totalFiles, + static_cast(this->m_numDpSlots - totalFiles), this->m_fileList, filesRead ); @@ -149,7 +149,10 @@ namespace Svc { } // Assert number of files isn't more than asked - FW_ASSERT(filesRead <= this->m_numDpSlots - totalFiles, filesRead, this->m_numDpSlots - totalFiles); + FW_ASSERT( + filesRead <= this->m_numDpSlots - totalFiles, + static_cast(filesRead), + static_cast(this->m_numDpSlots - totalFiles)); // extract metadata for each file for (FwNativeUIntType file = 0; file < filesRead; file++) { @@ -204,15 +207,15 @@ namespace Svc { this->log_WARNING_HI_FileHdrDesError(fullFile, desStat); } - // add entry to catalog. + // add entry to catalog. DpStateEntry entry; - entry.dir = dir; + entry.dir = static_cast(dir); entry.record.setid(container.getId()); entry.record.setpriority(container.getPriority()); entry.record.setstate(container.getState()); entry.record.settSec(container.getTimeTag().getSeconds()); entry.record.settSub(container.getTimeTag().getUSeconds()); - entry.record.setsize(fileSize); + entry.record.setsize(static_cast(fileSize)); entry.entry = true; // assign the entry to the stored list @@ -227,7 +230,7 @@ namespace Svc { if (entry.record.getstate() == Fw::DpState::UNTRANSMITTED) { pendingFiles++; pendingDpBytes += entry.record.getsize(); - } + } // make sure we haven't exceeded the limit if (this->m_numDpRecords > this->m_numDpSlots) { @@ -241,7 +244,7 @@ namespace Svc { this->log_ACTIVITY_HI_ProcessingDirectoryComplete( this->m_directories[dir], - totalFiles, + static_cast(totalFiles), pendingFiles, pendingDpBytes ); @@ -295,7 +298,7 @@ namespace Svc { ); this->log_ACTIVITY_LO_SendingProduct( this->m_currXmitFileName, - this->m_sortedDpList[record].recPtr->record.getsize(), + static_cast(this->m_sortedDpList[record].recPtr->record.getsize()), this->m_sortedDpList[record].recPtr->record.getpriority() ); this->fileOut_out(0, this->m_currXmitFileName, this->m_currXmitFileName, 0, 0); @@ -358,7 +361,7 @@ namespace Svc { if (this->m_currXmitRecord) { this->m_currXmitRecord->sent = true; this->log_ACTIVITY_LO_ProductComplete(this->m_currXmitFileName); - } + } this->sendNextEntry(); } @@ -369,7 +372,7 @@ namespace Svc { U32 key ) { - // return code for health ping + // return code for health ping this->pingOut_out(0, key); } From 310bb577803a66419aeab19c7dbda62f76175197 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Sun, 28 Apr 2024 12:00:27 +0200 Subject: [PATCH 18/21] Fixes from review --- Svc/ComLogger/ComLogger.cpp | 2 +- Svc/ComQueue/ComQueue.cpp | 4 ++-- Svc/Deframer/Deframer.cpp | 2 +- Svc/StaticMemory/StaticMemoryComponentImpl.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index 9f121f9be4..c6b8c27c81 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -69,7 +69,7 @@ namespace Svc { FW_ASSERT(Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix)) < sizeof(this->m_filePrefix), static_cast(Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix))), - sizeof(this->m_filePrefix)); // ensure that file prefix is not too big + static_cast(sizeof(this->m_filePrefix))); // ensure that file prefix is not too big (void)Fw::StringUtils::string_copy(this->m_filePrefix, incomingFilePrefix, sizeof(this->m_filePrefix)); diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index a76a5be38b..8ccb03f577 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -71,8 +71,8 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, for (NATIVE_UINT_TYPE entryIndex = 0; entryIndex < FW_NUM_ARRAY_ELEMENTS(queueConfig.entries); entryIndex++) { // Check for valid configuration entry FW_ASSERT(queueConfig.entries[entryIndex].priority < TOTAL_PORT_COUNT, - queueConfig.entries[entryIndex].priority, - TOTAL_PORT_COUNT, + static_cast(queueConfig.entries[entryIndex].priority), + static_cast(TOTAL_PORT_COUNT), static_cast(entryIndex)); if (currentPriority == queueConfig.entries[entryIndex].priority) { diff --git a/Svc/Deframer/Deframer.cpp b/Svc/Deframer/Deframer.cpp index 782ffe682a..3005aa6f99 100644 --- a/Svc/Deframer/Deframer.cpp +++ b/Svc/Deframer/Deframer.cpp @@ -211,7 +211,7 @@ void Deframer ::processBuffer(Fw::Buffer& buffer) { // If data does not fit, there is a coding error FW_ASSERT( status == Fw::FW_SERIALIZE_OK, - status, + static_cast(status), static_cast(offset), static_cast(serSize)); // Process the data diff --git a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp index d7f6e1312c..978152f6cf 100644 --- a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp +++ b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp @@ -45,7 +45,7 @@ void StaticMemoryComponentImpl ::bufferDeallocate_handler(const NATIVE_INT_TYPE FW_ASSERT( (fwBuffer.getData() + fwBuffer.getSize()) <= (m_static_memory[portNum] + sizeof(m_static_memory[0])), static_cast(fwBuffer.getSize()), - sizeof(m_static_memory[0])); + static_cast(sizeof(m_static_memory[0]))); m_allocated[portNum] = false; } From b0cf15f6463e1a960ac04b817a8643efe73624dd Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Mon, 29 Apr 2024 12:21:07 -0700 Subject: [PATCH 19/21] Further fixes from review - WIP --- Drv/Ip/IpSocket.cpp | 10 +++++----- Drv/Ip/IpSocket.hpp | 2 +- Drv/Ip/SocketReadTask.cpp | 4 ++-- Drv/LinuxUartDriver/LinuxUartDriver.cpp | 6 +++--- Drv/LinuxUartDriver/LinuxUartDriver.hpp | 4 ++-- Svc/ComQueue/ComQueue.cpp | 4 ++-- Svc/StaticMemory/StaticMemoryComponentImpl.cpp | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Drv/Ip/IpSocket.cpp b/Drv/Ip/IpSocket.cpp index 39b8e3171e..9262fa1fca 100644 --- a/Drv/Ip/IpSocket.cpp +++ b/Drv/Ip/IpSocket.cpp @@ -193,7 +193,7 @@ SocketIpStatus IpSocket::send(const U8* const data, const U32 size) { return SOCK_SUCCESS; } -SocketIpStatus IpSocket::recv(U8* data, I32& req_read) { +SocketIpStatus IpSocket::recv(U8* data, U32& req_read) { I32 size = 0; // Check for previously disconnected socket if (m_fd == -1) { @@ -203,7 +203,7 @@ SocketIpStatus IpSocket::recv(U8* data, I32& req_read) { // Try to read until we fail to receive data for (U32 i = 0; (i < SOCKET_MAX_ITERATIONS) && (size <= 0); i++) { // Attempt to recv out data - size = this->recvProtocol(data, static_cast(req_read)); + size = this->recvProtocol(data, req_read); // Error is EINTR, just try again if (size == -1 && ((errno == EINTR) || errno == EAGAIN)) { continue; @@ -211,16 +211,16 @@ SocketIpStatus IpSocket::recv(U8* data, I32& req_read) { // Zero bytes read reset or bad ef means we've disconnected else if (size == 0 || ((size == -1) && ((errno == ECONNRESET) || (errno == EBADF)))) { this->close(); - req_read = size; + req_read = static_cast(size); return SOCK_DISCONNECTED; } // Error returned, and it wasn't an interrupt, nor a disconnect else if (size == -1) { - req_read = size; + req_read = static_cast(size); return SOCK_READ_ERROR; // Stop recv task on error } } - req_read = size; + req_read = static_cast(size); // Prevent interrupted socket being viewed as success if (size == -1) { return SOCK_INTERRUPTED_TRY_AGAIN; diff --git a/Drv/Ip/IpSocket.hpp b/Drv/Ip/IpSocket.hpp index d813445045..b3024917d8 100644 --- a/Drv/Ip/IpSocket.hpp +++ b/Drv/Ip/IpSocket.hpp @@ -145,7 +145,7 @@ class IpSocket { * \param size: maximum size of data buffer to fill * \return status of the send, SOCK_DISCONNECTED to reopen, SOCK_SUCCESS on success, something else on error */ - SocketIpStatus recv(U8* const data, I32& size); + SocketIpStatus recv(U8* const data, U32& size); /** * \brief closes the socket * diff --git a/Drv/Ip/SocketReadTask.cpp b/Drv/Ip/SocketReadTask.cpp index bffb40199b..03539b9db1 100644 --- a/Drv/Ip/SocketReadTask.cpp +++ b/Drv/Ip/SocketReadTask.cpp @@ -98,7 +98,7 @@ void SocketReadTask::readTask(void* pointer) { Fw::Buffer buffer = self->getBuffer(); U8* data = buffer.getData(); FW_ASSERT(data); - I32 size = static_cast(buffer.getSize()); + U32 size = buffer.getSize(); size = (size >= 0) ? size : MAXIMUM_SIZE; // Handle max U32 edge case status = self->getSocketHandler().recv(data, size); if ((status != SOCK_SUCCESS) && (status != SOCK_INTERRUPTED_TRY_AGAIN)) { @@ -109,7 +109,7 @@ void SocketReadTask::readTask(void* pointer) { buffer.setSize(0); } else { // Send out received data - buffer.setSize(static_cast(size)); + buffer.setSize(size); } self->sendBuffer(buffer, status); } diff --git a/Drv/LinuxUartDriver/LinuxUartDriver.cpp b/Drv/LinuxUartDriver/LinuxUartDriver.cpp index f04f0cbd4f..2965e455e4 100644 --- a/Drv/LinuxUartDriver/LinuxUartDriver.cpp +++ b/Drv/LinuxUartDriver/LinuxUartDriver.cpp @@ -32,7 +32,7 @@ namespace Drv { // ---------------------------------------------------------------------- LinuxUartDriver ::LinuxUartDriver(const char* const compName) - : LinuxUartDriverComponentBase(compName), m_fd(-1), m_allocationSize(-1), m_device("NOT_EXIST"), m_quitReadThread(false) { + : LinuxUartDriverComponentBase(compName), m_fd(-1), m_allocationSize(0), m_device("NOT_EXIST"), m_quitReadThread(false) { } void LinuxUartDriver ::init(const NATIVE_INT_TYPE instance) { @@ -43,7 +43,7 @@ bool LinuxUartDriver::open(const char* const device, UartBaudRate baud, UartFlowControl fc, UartParity parity, - NATIVE_INT_TYPE allocationSize) { + U32 allocationSize) { FW_ASSERT(device != nullptr); NATIVE_INT_TYPE fd = -1; NATIVE_INT_TYPE stat = -1; @@ -346,7 +346,7 @@ void LinuxUartDriver ::serialReadTaskEntry(void* ptr) { Drv::RecvStatus status = RecvStatus::RECV_ERROR; // added by m.chase 03.06.2017 LinuxUartDriver* comp = reinterpret_cast(ptr); while (!comp->m_quitReadThread) { - Fw::Buffer buff = comp->allocate_out(0, static_cast(comp->m_allocationSize)); + Fw::Buffer buff = comp->allocate_out(0,comp->m_allocationSize); // On failed allocation, error and deallocate if (buff.getData() == nullptr) { diff --git a/Drv/LinuxUartDriver/LinuxUartDriver.hpp b/Drv/LinuxUartDriver/LinuxUartDriver.hpp index 7f70f608eb..d5a77b2dc0 100644 --- a/Drv/LinuxUartDriver/LinuxUartDriver.hpp +++ b/Drv/LinuxUartDriver/LinuxUartDriver.hpp @@ -72,7 +72,7 @@ class LinuxUartDriver : public LinuxUartDriverComponentBase { enum UartParity { PARITY_NONE, PARITY_ODD, PARITY_EVEN }; // Open device with specified baud and flow control. - bool open(const char* const device, UartBaudRate baud, UartFlowControl fc, UartParity parity, NATIVE_INT_TYPE allocationSize); + bool open(const char* const device, UartBaudRate baud, UartFlowControl fc, UartParity parity, U32 allocationSize); //! start the serial poll thread. //! buffSize is the max receive buffer size @@ -103,7 +103,7 @@ class LinuxUartDriver : public LinuxUartDriverComponentBase { NATIVE_INT_TYPE m_fd; //!< file descriptor returned for I/O device - NATIVE_INT_TYPE m_allocationSize; //!< size of allocation request to memory manager + U32 m_allocationSize; //!< size of allocation request to memory manager const char* m_device; //!< original device path //! This method will be called by the new thread to wait for input on the serial port. diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index a76a5be38b..8ccb03f577 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -71,8 +71,8 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, for (NATIVE_UINT_TYPE entryIndex = 0; entryIndex < FW_NUM_ARRAY_ELEMENTS(queueConfig.entries); entryIndex++) { // Check for valid configuration entry FW_ASSERT(queueConfig.entries[entryIndex].priority < TOTAL_PORT_COUNT, - queueConfig.entries[entryIndex].priority, - TOTAL_PORT_COUNT, + static_cast(queueConfig.entries[entryIndex].priority), + static_cast(TOTAL_PORT_COUNT), static_cast(entryIndex)); if (currentPriority == queueConfig.entries[entryIndex].priority) { diff --git a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp index d7f6e1312c..978152f6cf 100644 --- a/Svc/StaticMemory/StaticMemoryComponentImpl.cpp +++ b/Svc/StaticMemory/StaticMemoryComponentImpl.cpp @@ -45,7 +45,7 @@ void StaticMemoryComponentImpl ::bufferDeallocate_handler(const NATIVE_INT_TYPE FW_ASSERT( (fwBuffer.getData() + fwBuffer.getSize()) <= (m_static_memory[portNum] + sizeof(m_static_memory[0])), static_cast(fwBuffer.getSize()), - sizeof(m_static_memory[0])); + static_cast(sizeof(m_static_memory[0]))); m_allocated[portNum] = false; } From 9ca89e9dd33f19648c4f3b0d84be6fb6bc61116b Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Mon, 29 Apr 2024 12:51:24 -0700 Subject: [PATCH 20/21] Finished review fixes --- Svc/CmdDispatcher/CommandDispatcherImpl.cpp | 4 ++-- Svc/CmdDispatcher/CommandDispatcherImpl.hpp | 2 +- Svc/ComQueue/ComQueue.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp index 19c9657e68..c9c7e8e7a9 100644 --- a/Svc/CmdDispatcher/CommandDispatcherImpl.cpp +++ b/Svc/CmdDispatcher/CommandDispatcherImpl.cpp @@ -123,7 +123,7 @@ namespace Svc { pendingFound = true; this->m_sequenceTracker[pending].used = true; this->m_sequenceTracker[pending].opCode = cmdPkt.getOpCode(); - this->m_sequenceTracker[pending].seq = static_cast(this->m_seq); + this->m_sequenceTracker[pending].seq = this->m_seq; this->m_sequenceTracker[pending].context = context; this->m_sequenceTracker[pending].callerPort = portNum; break; @@ -143,7 +143,7 @@ namespace Svc { this->compCmdSend_out( this->m_entryTable[entry].port, cmdPkt.getOpCode(), - static_cast(this->m_seq), + this->m_seq, cmdPkt.getArgBuffer()); // log dispatched command this->log_COMMAND_OpCodeDispatched(cmdPkt.getOpCode(),this->m_entryTable[entry].port); diff --git a/Svc/CmdDispatcher/CommandDispatcherImpl.hpp b/Svc/CmdDispatcher/CommandDispatcherImpl.hpp index 67679936f8..cf96027df2 100644 --- a/Svc/CmdDispatcher/CommandDispatcherImpl.hpp +++ b/Svc/CmdDispatcher/CommandDispatcherImpl.hpp @@ -167,7 +167,7 @@ namespace Svc { NATIVE_INT_TYPE callerPort; //!< port command source port } m_sequenceTracker[CMD_DISPATCHER_SEQUENCER_TABLE_SIZE]; //!< sequence tracking port for command completions; - I32 m_seq; //!< current command sequence number + U32 m_seq; //!< current command sequence number U32 m_numCmdsDispatched; //!< number of commands dispatched U32 m_numCmdErrors; //!< number of commands with an error diff --git a/Svc/ComQueue/ComQueue.cpp b/Svc/ComQueue/ComQueue.cpp index 8ccb03f577..a1fb1c40c2 100644 --- a/Svc/ComQueue/ComQueue.cpp +++ b/Svc/ComQueue/ComQueue.cpp @@ -68,7 +68,7 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, for (FwIndexType currentPriority = 0; currentPriority < TOTAL_PORT_COUNT; currentPriority++) { // Walk each queue configuration entry and add them into the prioritized metadata list when matching the current // priority value - for (NATIVE_UINT_TYPE entryIndex = 0; entryIndex < FW_NUM_ARRAY_ELEMENTS(queueConfig.entries); entryIndex++) { + for (FwIndexType entryIndex = 0; entryIndex < static_cast(FW_NUM_ARRAY_ELEMENTS(queueConfig.entries)); entryIndex++) { // Check for valid configuration entry FW_ASSERT(queueConfig.entries[entryIndex].priority < TOTAL_PORT_COUNT, static_cast(queueConfig.entries[entryIndex].priority), @@ -82,7 +82,7 @@ void ComQueue::configure(QueueConfigurationTable queueConfig, QueueMetadata& entry = this->m_prioritizedList[currentPriorityIndex]; entry.priority = queueConfig.entries[entryIndex].priority; entry.depth = queueConfig.entries[entryIndex].depth; - entry.index = static_cast(entryIndex); + entry.index = entryIndex; // Message size is determined by the type of object being stored, which in turn is determined by the // index of the entry. Those lower than COM_PORT_COUNT are Fw::ComBuffers and those larger Fw::Buffer. entry.msgSize = (entryIndex < COM_PORT_COUNT) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer); From bbb29e9b3604449d38be37f7accbde293cfc6667 Mon Sep 17 00:00:00 2001 From: Michael D Starch Date: Mon, 29 Apr 2024 16:04:31 -0700 Subject: [PATCH 21/21] Fixing =CI issues --- Drv/Ip/SocketReadTask.cpp | 1 - Drv/Ip/test/ut/SocketTestHelper.cpp | 4 ++-- Drv/TcpClient/test/ut/TcpClientTester.cpp | 2 +- Drv/TcpServer/test/ut/TcpServerTester.cpp | 2 +- Drv/Udp/test/ut/UdpTester.cpp | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Drv/Ip/SocketReadTask.cpp b/Drv/Ip/SocketReadTask.cpp index 03539b9db1..58b414aa33 100644 --- a/Drv/Ip/SocketReadTask.cpp +++ b/Drv/Ip/SocketReadTask.cpp @@ -99,7 +99,6 @@ void SocketReadTask::readTask(void* pointer) { U8* data = buffer.getData(); FW_ASSERT(data); U32 size = buffer.getSize(); - size = (size >= 0) ? size : MAXIMUM_SIZE; // Handle max U32 edge case status = self->getSocketHandler().recv(data, size); if ((status != SOCK_SUCCESS) && (status != SOCK_INTERRUPTED_TRY_AGAIN)) { Fw::Logger::logMsg("[WARNING] Failed to recv from port with status %d and errno %d\n", diff --git a/Drv/Ip/test/ut/SocketTestHelper.cpp b/Drv/Ip/test/ut/SocketTestHelper.cpp index 3af7b73a81..aabb532ec9 100644 --- a/Drv/Ip/test/ut/SocketTestHelper.cpp +++ b/Drv/Ip/test/ut/SocketTestHelper.cpp @@ -48,7 +48,7 @@ void fill_random_buffer(Fw::Buffer &buffer) { } void send_recv(Drv::IpSocket& sender, Drv::IpSocket& receiver) { - I32 size = MAX_DRV_TEST_MESSAGE_SIZE; + U32 size = MAX_DRV_TEST_MESSAGE_SIZE; U8 buffer_out[MAX_DRV_TEST_MESSAGE_SIZE] = {0}; U8 buffer_in[MAX_DRV_TEST_MESSAGE_SIZE] = {0}; @@ -56,7 +56,7 @@ void send_recv(Drv::IpSocket& sender, Drv::IpSocket& receiver) { Drv::Test::fill_random_data(buffer_out, MAX_DRV_TEST_MESSAGE_SIZE); EXPECT_EQ(sender.send(buffer_out, MAX_DRV_TEST_MESSAGE_SIZE), Drv::SOCK_SUCCESS); EXPECT_EQ(receiver.recv(buffer_in, size), Drv::SOCK_SUCCESS); - EXPECT_EQ(size, static_cast(MAX_DRV_TEST_MESSAGE_SIZE)); + EXPECT_EQ(size, static_cast(MAX_DRV_TEST_MESSAGE_SIZE)); Drv::Test::validate_random_data(buffer_out, buffer_in, MAX_DRV_TEST_MESSAGE_SIZE); } diff --git a/Drv/TcpClient/test/ut/TcpClientTester.cpp b/Drv/TcpClient/test/ut/TcpClientTester.cpp index c12ec70310..097afa0f60 100644 --- a/Drv/TcpClient/test/ut/TcpClientTester.cpp +++ b/Drv/TcpClient/test/ut/TcpClientTester.cpp @@ -46,7 +46,7 @@ void TcpClientTester ::test_with_loop(U32 iterations, bool recv_thread) { // Loop through a bunch of client disconnects for (U32 i = 0; i < iterations; i++) { - I32 size = sizeof(m_data_storage); + U32 size = sizeof(m_data_storage); // Not testing with reconnect thread, we will need to open ourselves if (not recv_thread) { diff --git a/Drv/TcpServer/test/ut/TcpServerTester.cpp b/Drv/TcpServer/test/ut/TcpServerTester.cpp index 2797c3b3d2..05388b687a 100644 --- a/Drv/TcpServer/test/ut/TcpServerTester.cpp +++ b/Drv/TcpServer/test/ut/TcpServerTester.cpp @@ -51,7 +51,7 @@ void TcpServerTester ::test_with_loop(U32 iterations, bool recv_thread) { client.configure("127.0.0.1", port, 0, 100); status2 = client.open(); - I32 size = sizeof(m_data_storage); + U32 size = sizeof(m_data_storage); // Not testing with reconnect thread, we will need to open ourselves if (not recv_thread) { diff --git a/Drv/Udp/test/ut/UdpTester.cpp b/Drv/Udp/test/ut/UdpTester.cpp index cba732d5c3..1df2ad0160 100644 --- a/Drv/Udp/test/ut/UdpTester.cpp +++ b/Drv/Udp/test/ut/UdpTester.cpp @@ -47,7 +47,7 @@ void UdpTester::test_with_loop(U32 iterations, bool recv_thread) { // Loop through a bunch of client disconnects for (U32 i = 0; i < iterations; i++) { Drv::UdpSocket udp2; - I32 size = sizeof(m_data_storage); + U32 size = sizeof(m_data_storage); // Not testing with reconnect thread, we will need to open ourselves if (not recv_thread) {