-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from 21 commits
a872e0c
ebeb0de
5573b6f
9e65768
0f6ddcf
3465a16
bd77430
3c2103d
402053f
cc9abc1
e206b6d
680ad29
a4b7f84
618689b
383f7b0
e00c7e8
dd983a1
af5be5b
6567fad
2b0ee7d
310bb57
b0cf15f
f5437dc
9ca89e9
bbb29e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1000,6 +1000,7 @@ subgrouping | |
subhist | ||
subhistory | ||
subpage | ||
suseconds | ||
subseconds | ||
subtargets | ||
suppr | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ if (NOT BUILD_TESTING) | |
add_compile_options( | ||
-Wshadow | ||
-pedantic | ||
-Wconversion | ||
) | ||
endif() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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); | ||
} | ||
// 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; | ||
} | ||
|
||
|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
|
||
|
@@ -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); | ||
|
@@ -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); | ||
|
@@ -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; | ||
|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
@@ -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); | ||
|
||
|
@@ -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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future review: should |
||
} | ||
|
||
Utils::HashBuffer DpContainer::getHeaderHash() const { | ||
|
@@ -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; | ||
} | ||
|
||
|
There was a problem hiding this comment.
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.