Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed conversion warnings on framework tests #2606

Merged
merged 25 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a872e0c
Fixed conversion warnings on framework tests
JohanBertrand Mar 19, 2024
ebeb0de
Fix conversion warnings from CI
JohanBertrand Mar 28, 2024
5573b6f
Fix static_cast in SyntheticFileSystem
JohanBertrand Mar 28, 2024
9e65768
Fix read and write argument conversion
JohanBertrand Mar 28, 2024
0f6ddcf
Merge remote-tracking branch 'nasa/devel' into Fix-Wconversion-warnings
LeStarch Apr 5, 2024
3465a16
Fix new CI issues
JohanBertrand Apr 5, 2024
bd77430
Fix errors from clang-tidy
JohanBertrand Apr 8, 2024
3c2103d
Fix last errors from clang
JohanBertrand Apr 8, 2024
402053f
Fix macOS issue
JohanBertrand Apr 9, 2024
cc9abc1
Fix last macOS IPCQueueStub warning
JohanBertrand Apr 9, 2024
e206b6d
Last Os-MacOs warning fix
JohanBertrand Apr 10, 2024
680ad29
Merge remote-tracking branch 'origin/devel' into Fix-Wconversion-warn…
JohanBertrand Apr 15, 2024
a4b7f84
Fix merge conflict
JohanBertrand Apr 15, 2024
618689b
Fix new warnings and merge conflicts
JohanBertrand Apr 15, 2024
383f7b0
Reverse issues from merge conflict
JohanBertrand Apr 15, 2024
e00c7e8
Fix unit tests and one more macOS error
JohanBertrand Apr 17, 2024
dd983a1
Fix macOS errors - pt 1
LeStarch Apr 17, 2024
af5be5b
sp
LeStarch Apr 17, 2024
6567fad
Merge remote-tracking branch 'origin/devel' into Fix-Wconversion-warn…
JohanBertrand Apr 28, 2024
2b0ee7d
Fix warnings from development
JohanBertrand Apr 28, 2024
310bb57
Fixes from review
JohanBertrand Apr 28, 2024
b0cf15f
Further fixes from review - WIP
LeStarch Apr 29, 2024
f5437dc
Merge branch 'Fix-Wconversion-warnings' of github.com:JohanBertrand/f…
LeStarch Apr 29, 2024
9ca89e9
Finished review fixes
LeStarch Apr 29, 2024
bbb29e9
Fixing =CI issues
LeStarch Apr 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ subgrouping
subhist
subhistory
subpage
suseconds
subseconds
subtargets
suppr
Expand Down
2 changes: 1 addition & 1 deletion CFDP/Checksum/Checksum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace CFDP {
)
{
FW_ASSERT(offset < 4);
const U32 addend = byte << (8*(3-offset));
const U32 addend = static_cast<U32>(byte) << (8*(3-offset));
this->m_value += addend;
}

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (NOT BUILD_TESTING)
add_compile_options(
-Wshadow
-pedantic
-Wconversion
)
endif()

Expand Down
13 changes: 7 additions & 6 deletions Drv/Ip/IpSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FwAssertArgType>(timeout_microseconds));
FW_ASSERT(port != 0, port);
this->m_timeoutSeconds = timeout_seconds;
this->m_timeoutMicroseconds = timeout_microseconds;
Expand All @@ -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<time_t>(this->m_timeoutSeconds);
timeout.tv_usec = static_cast<suseconds_t>(this->m_timeoutMicroseconds);
// set socket write to timeout after 1 sec
if (setsockopt(socketFd, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast<char *>(&timeout), sizeof(timeout)) < 0) {
return SOCK_FAILED_TO_SET_SOCKET_OPTIONS;
Expand Down Expand Up @@ -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<U32>(sent);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future review: why U32 here? Seems arbitrary.

}
// 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<FwAssertArgType>(total), static_cast<FwAssertArgType>(size));
return SOCK_SUCCESS;
}

Expand All @@ -202,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<U32>(req_read));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future review: why U32 here? Seems arbitrary.

// Error is EINTR, just try again
if (size == -1 && ((errno == EINTR) || errno == EAGAIN)) {
continue;
Expand Down
16 changes: 12 additions & 4 deletions Drv/Ip/SocketReadTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,21 @@ 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<POINTER_CAST>(status),
static_cast<POINTER_CAST>(errno));
(void) Os::Task::delay(SOCKET_RETRY_INTERVAL_MS);
continue;
}

// 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<POINTER_CAST>(status),
static_cast<POINTER_CAST>(errno));
(void) Os::Task::delay(SOCKET_RETRY_INTERVAL_MS);
continue;
}
Expand All @@ -96,12 +102,14 @@ 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<POINTER_CAST>(status),
static_cast<POINTER_CAST>(errno));
self->getSocketHandler().close();
buffer.setSize(0);
} else {
// Send out received data
buffer.setSize(size);
buffer.setSize(static_cast<U32>(size));
}
self->sendBuffer(buffer, status);
}
Expand Down
4 changes: 2 additions & 2 deletions Drv/Ip/TcpClientSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<I32>(::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<I32>(::recv(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS));
}

} // namespace Drv
4 changes: 2 additions & 2 deletions Drv/Ip/TcpServerSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<I32>(::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<I32>(::recv(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS));
}

} // namespace Drv
6 changes: 3 additions & 3 deletions Drv/Ip/UdpSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<struct sockaddr *>(&this->m_state->m_addr_send), sizeof(this->m_state->m_addr_send));
return static_cast<I32>(::sendto(this->m_fd, data, size, SOCKET_IP_SEND_FLAGS,
reinterpret_cast<struct sockaddr *>(&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<I32>(::recvfrom(this->m_fd, data, size, SOCKET_IP_RECV_FLAGS, nullptr, nullptr));
}

} // namespace Drv
28 changes: 14 additions & 14 deletions Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>(len)) != len) {
(void) close(fd);
DEBUG_PRINT("gpio/export error!\n");
return -1;
Expand Down Expand Up @@ -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<size_t>(len)) != len) {
(void) close(fd);
DEBUG_PRINT("gpio/unexport error!\n");
return -1;
Expand Down Expand Up @@ -114,9 +114,9 @@ namespace Drv {
}

const char *dir = out_flag ? "out" : "in";
len = strlen(dir);
len = static_cast<int>(strlen(dir));

if (write(fd, dir, len) != len) {
if (write(fd, dir, static_cast<size_t>(len)) != len) {
(void) close(fd);
DEBUG_PRINT("gpio/direction error!\n");
return -1;
Expand Down Expand Up @@ -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<NATIVE_INT_TYPE>(lseek(fd, 0, SEEK_SET)); // Must seek back to the starting

Check notice

Code scanning / CodeQL

Use of basic integral type Note

stat1 uses the basic integral type int rather than a typedef with size and signedness.
NATIVE_INT_TYPE stat2 = static_cast<NATIVE_INT_TYPE>(read(fd, &ch, 1));

Check notice

Code scanning / CodeQL

Use of basic integral type Note

stat2 uses the basic integral type int rather than a typedef with size and signedness.

if (stat1 == -1 || stat2 != 1) {
DEBUG_PRINT("GPIO read failure: %d %d!\n",stat1,stat2);
Expand Down Expand Up @@ -199,8 +199,8 @@ namespace Drv {
return -1;
}

len = strlen(edge) + 1;
if(write(fd, edge, len) != len) {
len = static_cast<int>(strlen(edge) + 1);
if(write(fd, edge, static_cast<size_t>(len)) != len) {
(void) close(fd);
DEBUG_PRINT("gpio/set-edge error!\n");
return -1;
Expand Down Expand Up @@ -292,13 +292,13 @@ namespace Drv {
NATIVE_INT_TYPE stat;

// Configure:
stat = gpio_export(gpio);
stat = gpio_export(static_cast<unsigned int>(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<unsigned int>(gpio), direction == GPIO_OUT ? 1 : 0);
if (-1 == stat) {
Fw::LogStringArg arg = strerror(errno);
this->log_WARNING_HI_GP_OpenError(gpio,stat,arg);
Expand All @@ -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<unsigned int>(gpio));
if (-1 == this->m_fd) {
Fw::LogStringArg arg = strerror(errno);
this->log_WARNING_HI_GP_OpenError(gpio,errno,arg);
Expand All @@ -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<unsigned int>(compPtr->m_gpio), "rising");
if (-1 == stat) {
compPtr->log_WARNING_HI_GP_IntStartError(compPtr->m_gpio);
return;
Expand All @@ -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_t>(nfds), timeout);

/*
* According to this link, poll will always have POLLERR set for the sys/class/gpio subsystem
Expand Down Expand Up @@ -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<unsigned int>(this->m_gpio));
}

}
Expand Down
4 changes: 2 additions & 2 deletions Drv/LinuxI2cDriver/LinuxI2cDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(write(this->m_fd, serBuffer.getData(), serBuffer.getSize()));
if (stat == -1) {
#if DEBUG_PRINT
Fw::Logger::logMsg("Status: %d Errno: %d\n", stat, errno);
Expand Down Expand Up @@ -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<int>(read(this->m_fd, serBuffer.getData(), serBuffer.getSize()));
if (stat == -1) {
#if DEBUG_PRINT
Fw::Logger::logMsg("Status: %d Errno: %d\n", stat, errno);
Expand Down
18 changes: 9 additions & 9 deletions Drv/LinuxUartDriver/LinuxUartDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ bool LinuxUartDriver::open(const char* const device,
#endif
#endif
default:
FW_ASSERT(0, baud);
FW_ASSERT(0, static_cast<FwAssertArgType>(baud));
break;
}

Expand Down Expand Up @@ -248,15 +248,15 @@ bool LinuxUartDriver::open(const char* const device,
newtio.c_cflag |= PARENB;
break;
case PARITY_NONE:
newtio.c_cflag &= ~PARENB;
newtio.c_cflag &= static_cast<unsigned int>(~PARENB);
break;
default:
FW_ASSERT(0, parity);
break;
}

// Set baud rate:
stat = cfsetispeed(&newtio, relayRate);
stat = cfsetispeed(&newtio, static_cast<speed_t>(relayRate));
if (stat) {
DEBUG_PRINT("cfsetispeed failed\n");
close(fd);
Expand All @@ -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<speed_t>(relayRate));
if (stat) {
DEBUG_PRINT("cfsetospeed failed\n");
close(fd);
Expand Down Expand Up @@ -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<NATIVE_INT_TYPE>(serBuffer.getSize());

Check notice

Code scanning / CodeQL

Use of basic integral type Note

xferSize uses the basic integral type int rather than a typedef with size and signedness.

NATIVE_INT_TYPE stat = ::write(this->m_fd, data, xferSize);
NATIVE_INT_TYPE stat = static_cast<NATIVE_INT_TYPE>(::write(this->m_fd, data, static_cast<size_t>(xferSize)));

Check notice

Code scanning / CodeQL

Use of basic integral type Note

stat uses the basic integral type int rather than a typedef with size and signedness.

if (-1 == stat || stat != xferSize) {
Fw::LogStringArg _arg = this->m_device;
Expand All @@ -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<LinuxUartDriver*>(ptr);
while (!comp->m_quitReadThread) {
Fw::Buffer buff = comp->allocate_out(0, comp->m_allocationSize);
Fw::Buffer buff = comp->allocate_out(0, static_cast<U32>(comp->m_allocationSize));
Copy link
Collaborator

@LeStarch LeStarch Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future review: m_allocationSize needs to be made into correct type. Since it is a buffer allocation it should be U32.


// On failed allocation, error and deallocate
if (buff.getData() == nullptr) {
Expand All @@ -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<int>(::read(comp->m_fd, buff.getData(), buff.getSize()));
}
buff.setSize(0);

Expand All @@ -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<U32>(stat));
status = RecvStatus::RECV_OK; // added by m.chase 03.06.2017
} else {
status = RecvStatus::RECV_ERROR; // Simply to return the buffer
Expand Down
2 changes: 1 addition & 1 deletion Fw/Comp/ActiveComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_t>(size), "ActComp: %s", this->m_objName.toChar());

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
if (status < 0) {
buffer[0] = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Fw/Comp/PassiveComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_t>(size), "Comp: %s", this->m_objName.toChar());

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
if (status < 0) {
buffer[0] = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Fw/Comp/QueuedComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_t>(size), "QueueComp: %s", this->m_objName.toChar());

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
if (status < 0) {
buffer[0] = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions Fw/Dp/DpContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void DpContainer::setBuffer(const Buffer& buffer) {
FW_ASSERT(bufferSize >= minBufferSize, static_cast<FwAssertArgType>(bufferSize),
static_cast<FwAssertArgType>(minBufferSize));
U8* const dataAddr = &buffAddr[DATA_OFFSET];
this->m_dataBuffer.setExtBuffer(dataAddr, dataCapacity);
this->m_dataBuffer.setExtBuffer(dataAddr, static_cast<Fw::Serializable::SizeType>(dataCapacity));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future review: should setExtBuffer take a FwSizeType

}

Utils::HashBuffer DpContainer::getHeaderHash() const {
Expand Down Expand Up @@ -199,7 +199,7 @@ Utils::HashBuffer DpContainer::computeDataHash() const {
FW_ASSERT(DATA_OFFSET + dataSize <= bufferSize, static_cast<FwAssertArgType>(DATA_OFFSET + dataSize),
static_cast<FwAssertArgType>(bufferSize));
Utils::HashBuffer computedHash;
Utils::Hash::hash(dataAddr, dataSize, computedHash);
Utils::Hash::hash(dataAddr, static_cast<NATIVE_INT_TYPE>(dataSize), computedHash);
return computedHash;
}

Expand Down
Loading
Loading