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 6 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 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
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 @@
}

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

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter data has not been checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter size has not been checked.
}

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

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter data has not been checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter size has not been checked.
}

} // 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 @@
}

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

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter data has not been checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter size has not been checked.
}

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

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter data has not been checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter size has not been checked.
}

} // 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 @@

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,

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter data has not been checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter size has not been checked.
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));

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter data has not been checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter size has not been checked.
}

} // namespace Drv
8 changes: 4 additions & 4 deletions Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
}

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

if (write(fd, dir, len) != len) {
(void) close(fd);
Expand Down Expand Up @@ -157,8 +157,8 @@

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,7 +199,7 @@
return -1;
}

len = strlen(edge) + 1;
len = static_cast<int>(strlen(edge) + 1);
if(write(fd, edge, len) != len) {
(void) close(fd);
DEBUG_PRINT("gpio/set-edge error!\n");
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
4 changes: 2 additions & 2 deletions Drv/LinuxUartDriver/LinuxUartDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
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<NATIVE_INT_TYPE>(::write(this->m_fd, data, xferSize));
Fixed Show fixed Hide fixed

if (-1 == stat || stat != xferSize) {
Fw::LogStringArg _arg = this->m_device;
Expand Down Expand Up @@ -368,7 +368,7 @@
// 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 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
8 changes: 4 additions & 4 deletions Fw/FilePacket/DataPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ namespace Fw {
U32 FilePacket::DataPacket ::
bufferSize() const
{
return
return static_cast<U32>(
this->m_header.bufferSize() +
sizeof(this->m_byteOffset) +
sizeof(this->m_dataSize) +
this->m_dataSize;
this->m_dataSize);
}

SerializeStatus FilePacket::DataPacket ::
Expand Down Expand Up @@ -76,10 +76,10 @@ namespace Fw {
U32 FilePacket::DataPacket ::
fixedLengthSize() const
{
return
return static_cast<U32>(
this->m_header.bufferSize() +
sizeof(this->m_byteOffset) +
sizeof(this->m_dataSize);
sizeof(this->m_dataSize));
}

SerializeStatus FilePacket::DataPacket ::
Expand Down
2 changes: 1 addition & 1 deletion Fw/FilePacket/EndPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Fw {
U32 FilePacket::EndPacket ::
bufferSize() const
{
return this->m_header.bufferSize() + sizeof(this->m_checksumValue);
return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_checksumValue));
}

SerializeStatus FilePacket::EndPacket ::
Expand Down
2 changes: 1 addition & 1 deletion Fw/FilePacket/PathName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Fw {
U32 FilePacket::PathName ::
bufferSize() const
{
return sizeof(this->m_length) + this->m_length;
return static_cast<U32>(sizeof(this->m_length) + this->m_length);
}

SerializeStatus FilePacket::PathName ::
Expand Down
5 changes: 3 additions & 2 deletions Fw/FilePacket/StartPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ namespace Fw {
U32 FilePacket::StartPacket ::
bufferSize() const
{
return this->m_header.bufferSize() +
return static_cast<U32>(
this->m_header.bufferSize() +
sizeof(this->m_fileSize) +
this->m_sourcePath.bufferSize() +
this->m_destinationPath.bufferSize();
this->m_destinationPath.bufferSize());
}

SerializeStatus FilePacket::StartPacket ::
Expand Down
19 changes: 12 additions & 7 deletions Fw/Types/Assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@

switch (numArgs) {
case 0:
(void) snprintf(destBuffer, buffSize, fileIdFs, file, lineNo);
(void) snprintf(
destBuffer,

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter destBuffer has not been checked.
static_cast<size_t>(buffSize),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffSize has not been checked.
fileIdFs,
file,

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter file has not been checked.
lineNo);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter lineNo has not been checked.
break;
case 1:
(void) snprintf(
destBuffer,
buffSize,
static_cast<size_t>(buffSize),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffSize has not been checked.
fileIdFs " %" PRI_FwAssertArgType,
file,
lineNo,
Expand All @@ -49,7 +54,7 @@
case 2:
(void) snprintf(
destBuffer,
buffSize,
static_cast<size_t>(buffSize),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffSize has not been checked.
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
file,
lineNo,
Expand All @@ -59,7 +64,7 @@
case 3:
(void) snprintf(
destBuffer,
buffSize,
static_cast<size_t>(buffSize),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffSize has not been checked.
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
" %" PRI_FwAssertArgType,
file,
Expand All @@ -70,7 +75,7 @@
case 4:
(void) snprintf(
destBuffer,
buffSize,
static_cast<size_t>(buffSize),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffSize has not been checked.
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
file,
Expand All @@ -80,7 +85,7 @@
case 5:
(void) snprintf(
destBuffer,
buffSize,
static_cast<size_t>(buffSize),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffSize has not been checked.
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
" %" PRI_FwAssertArgType,
Expand All @@ -92,7 +97,7 @@
case 6:
(void) snprintf(
destBuffer,
buffSize,
static_cast<size_t>(buffSize),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffSize has not been checked.
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
Expand Down
Loading
Loading