-
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
Fixed conversion warnings on framework tests #2606
Conversation
@@ -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
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 | ||
NATIVE_INT_TYPE stat2 = static_cast<NATIVE_INT_TYPE>(read(fd, &ch, 1)); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -56,7 +56,7 @@ | |||
) { | |||
|
|||
this->m_allocatorId = identifier; | |||
NATIVE_UINT_TYPE memSize = sizeof(Fw::Buffer) * maxNumBuffers; | |||
NATIVE_UINT_TYPE memSize = static_cast<NATIVE_UINT_TYPE>(sizeof(Fw::Buffer) * maxNumBuffers); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -36,7 +36,7 @@ | |||
|
|||
while (true) { | |||
unsigned long long missed; | |||
int ret = read (fd, &missed, sizeof (missed)); | |||
int ret = static_cast<int>(read (fd, &missed, sizeof (missed))); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -212,7 +212,7 @@ | |||
} 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<FwSignedSizeType>(this->m_data->m_data.size()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note test
@@ -138,12 +138,12 @@ | |||
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<FwSignedSizeType>(this->m_data->m_data.size()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note test
@@ -157,14 +157,14 @@ | |||
static_cast<size_t>((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<FwSignedSizeType>(this->m_data->m_data.size()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note test
@@ -105,15 +105,15 @@ | |||
} | |||
std::vector<U8> output; | |||
FwSignedSizeType original_pointer = this->m_data->m_pointer; | |||
FwSignedSizeType original_size = this->m_data->m_data.size(); | |||
FwSignedSizeType original_size = static_cast<FwSignedSizeType>(this->m_data->m_data.size()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note test
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.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
@LeStarch is it possible to trigger the CI please? |
@JohanBertrand let me fix the conflict, then sure! |
@JohanBertrand, it has been triggered. Thanks for the reminder! |
@@ -239,7 +242,7 @@ | |||
|
|||
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<const CHAR*>(&buffer[accumulated]), size - accumulated); | |||
ssize_t write_size = ::write(this->m_handle.m_file_descriptor, reinterpret_cast<const CHAR*>(&buffer[accumulated]), static_cast<size_t>(size - accumulated)); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -206,7 +206,10 @@ | |||
|
|||
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<CHAR*>(&buffer[accumulated]), size - accumulated); | |||
ssize_t read_size = ::read( |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -11,7 +11,7 @@ | |||
#include <climits> | |||
#include <Fw/Logger/Logger.hpp> | |||
|
|||
#ifdef TGT_OS_TYPE_LINUX | |||
#ifdef TGT_OS_TYPE_LINUX |
Check notice
Code scanning / CodeQL
Conditional compilation Note
@@ -27,10 +27,10 @@ | |||
|
|||
#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 |
Check notice
Code scanning / CodeQL
Conditional compilation Note
@@ -63,7 +63,7 @@ | |||
private: | |||
File m_file; | |||
NATIVE_UINT_TYPE m_lineNo; | |||
NATIVE_INT_TYPE m_numArgs; | |||
NATIVE_UINT_TYPE m_numArgs; |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -13,7 +13,7 @@ | |||
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
@@ -46,7 +46,7 @@ | |||
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
@@ -23,7 +23,7 @@ | |||
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
@@ -324,9 +324,9 @@ | |||
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
@@ -22,13 +22,13 @@ | |||
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<NATIVE_INT_TYPE>(buffer.getBuffCapacity()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -13,7 +13,7 @@ | |||
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<NATIVE_INT_TYPE>(buffer.getBuffLength()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -152,7 +152,7 @@ | |||
} | |||
|
|||
// Push item onto queue: | |||
bool pushSucceeded = queue->push(buffer, size, priority); | |||
bool pushSucceeded = queue->push(buffer, static_cast<NATIVE_UINT_TYPE>(size), priority); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -108,7 +108,7 @@ | |||
/////////////////////////////// | |||
|
|||
// Push item onto queue: | |||
bool pushSucceeded = queue->push(buffer, size, priority); | |||
bool pushSucceeded = queue->push(buffer, static_cast<NATIVE_UINT_TYPE>(size), priority); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -179,16 +186,18 @@ | |||
// 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<FwSignedSizeType>(fileSize); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@LeStarch I think most of the warnings are corrected for the Linux side, except the one related to fpp (nasa/fpp#400). I'm not sure what is the path forward for that. For the ones related to macOS, is there a good way for me to test it without waiting for the CI? Also, just to make sure, are you interested into merging this PR in the future? It is a lot of (small) changes. Mostly about casting, but some small bugs are also fixed. |
@JohanBertrand I do want this PR to be merged! The above FPP PR is marked "Draft"....so you should probably make it a full PR and we can review. |
As for the mac-side things are:
|
@JohanBertrand this is on me because I didn't connect the dots between this PR and other work we have going on, but we have some fairly substantial type adjustments that we are working on. In short NATIVE_INT_TYPE, NATIVE_UINT_TYPE are going to be replaced by correctly defined types for the use case. As such, we expect collision with this work. The thought on how to proceed would be:
We are trying to not invalidate your work here, while also not leverage a bunch of extra work on you. What are your thoughts on this? |
I think only the fpp update is missing right now. I would have say that it's worth trying to review/merge everything now if it's ready, and try to merge it before the changes of types happen. If you already started on it and you foresee some conflicts on your side, I'm happy following your approach and let this PR open until you're done with the types update. |
Fw/Types/PolyType.cpp
Outdated
@@ -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; |
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.
I am not sure if that has any impact on other functions or components. Also, I did not find where this it currently used.
However, the unit tests are passing here because of the casts performed there. That's why it has not been seen before
A fair point. Our concern is masking. You are, correctly, fixing errors, but these corrections might be better fixed with the new-methodology that was neither available nor known to you. Your corrections may mask the other solution and make it harder for us to improve upon these issues. However, we absolutely do not want to discard your work either. These are valued contributions, and your counterpoint is essentially "don't let this code-rot", which is in itself abundantly valid. Building on your recommendations I propose this:
This solves both concerns:
There may be many non-blocker comments from the review as we will be flagging issues for future consideration. We will clearly mark concerns that must be resolved before this merges, should anything come up! Thanks for working with us. |
I totally understand your point, and I am also concerned about masking issues through casting. I'm all good with your proposition. I am hoping that the merge of fpp will be solving the last warnings so that you can start the review. Do you want me to add a temporary comment line before every casts I added to better identify it in the codebase later? That's something I can do easily, if that's helping you in the future. Thank you very much! |
As my own note: here is the success criteria I am using for the review:
Other items are flagged for future review. |
@JohanBertrand unless you strongly object, I will go ahead and close out the macOS errors as I have access to the necessary OS to fix those. Also, I have begun to review this. |
Fw/Types/StringType.cpp
Outdated
@@ -49,7 +49,7 @@ bool StringBase::operator==(const CHAR* other) const { | |||
} | |||
|
|||
const SizeType capacity = this->getCapacity(); | |||
const size_t result = strncmp(us, other, capacity); | |||
const size_t result = static_cast<size_t>(strncmp(us, other, capacity)); |
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: do we need to cast to size_t
just for a comparison to 0
below? Perhaps we should just use the native result type from strncmp
@@ -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); |
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.
Drv/Ip/IpSocket.cpp
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
For future review: why U32 here? Seems arbitrary.
@@ -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<I32>(slot)); |
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: should slot
in the EVR match the iteration value of U32
?
} | ||
|
||
remaining_bytes = int_file_size % CRC_FILE_READ_BLOCK; | ||
remaining_bytes = static_cast<PlatformIntType>(int_file_size % CRC_FILE_READ_BLOCK); |
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: PlatformIntType
usage here may need to be fixed.
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.
Here are a list of comments for what I have reviewed thus far. I see a few missing casts. We also need to review static_cast<FwIndexType>
as perhaps the variable type being cast should change.
Nothing blocking except the need to fix CI. I'll look at that tomorrow.
FW_ASSERT( | ||
(fwBuffer.getData() + fwBuffer.getSize()) <= (m_static_memory[portNum] + sizeof(m_static_memory[0])), | ||
static_cast<FwAssertArgType>(fwBuffer.getSize()), | ||
sizeof(m_static_memory[0])); |
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.
I think this line needs a static cast to FwAssertArgType
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.
Fixed
@@ -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<U32>(numPingEntries); | |||
this->m_watchDogCode = watchDogCode; | |||
|
|||
// copy entries to private data | |||
for (NATIVE_INT_TYPE entry = 0; entry < numPingEntries; entry++) { |
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: this should iterate using FwIndexType
FW_ASSERT(rawSize == static_cast<U32>(size)); | ||
if (type == HUB_TYPE_PORT) { | ||
// Com buffer representations should be copied before the call returns, so we need not "allocate" new data | ||
Fw::ExternalSerializeBuffer wrapper(rawData, rawSize); | ||
status = wrapper.setBuffLen(rawSize); | ||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<NATIVE_INT_TYPE>(status)); | ||
portOut_out(port, wrapper); | ||
portOut_out(static_cast<FwIndexType>(port), wrapper); |
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: port should use FwIndexType
Svc/Deframer/Deframer.cpp
Outdated
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status, offset, serSize); | ||
FW_ASSERT( | ||
status == Fw::FW_SERIALIZE_OK, | ||
status, |
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.
Another missing cast to assert arg type.
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.
Fixed
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<U64>(writeSize); |
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: U64
use seems suspicious.
Svc/ComLogger/ComLogger.cpp
Outdated
} | ||
|
||
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<FwAssertArgType>(Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix))), | ||
sizeof(this->m_filePrefix)); // ensure that file prefix is not too big |
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.
Missing a cast.
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.
Fixed
Svc/ComQueue/ComQueue.cpp
Outdated
@@ -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, |
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.
Cast
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.
Just to make sure, do you want to have the cast static_cast<FwAssertArgType>()
even if it is a compatible/equivalent type?
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.
Fixed
@@ -158,15 +166,15 @@ 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++) { |
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: use of U32 in this iterator. comQueueDepth.SIZE?
comQueueDepth[i] = this->m_queues[i].get_high_water_mark(); | ||
this->m_queues[i].clear_high_water_mark(); | ||
} | ||
this->tlmWrite_comQueueDepth(comQueueDepth); | ||
|
||
// 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++) { |
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: use of U32 in this iterator. comQueueDepth.SIZE?
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.
Note: this is an autocoder problem, as array types use U32
indices.
@LeStarch Please go ahead with the fixes for macOS if you can, it takes too many iterations for me to solve all the warnings with the CI. Is there a problem with the CI stage |
Yes there is. This is a known issue with our older CI jobs (that predate Github actions). Everything gets stuffed into a log file rather than the console. If you click on "Summary" there is a zip archive one can download to look at the logs. We need to fix this such that it is easier to see what the problem is. Also, these artifacts may be restricted to maintainers...which could be another issue. |
@LeStarch Thanks for the feedback. The issue should be fixed now, sorry for that. |
Huzzah! |
Awesome, thanks @LeStarch! From the review, you want me to add the cast static_cast() even if it is a compatible/equivalent type, is that correct? Also, do you want me to add a |
@LeStarch I solved the merge conflicts and added casts you requested in the review. Let me know if there is something else missing. |
…prime into Fix-Wconversion-warnings
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.
I went ahead and fixed anything that seems like it needed to be fixed here. Otherwise I left comments to review further.
Systematically, there seems to be no clear consensus in how to represent sizes in API calls and more specifically in model calls. We should discuss a resolution and standards for this.
@@ -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<U32>(writeSize); |
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: This is an established U32
interface, but it likely should switch to FwSizeType
?
this->log_FATAL_AF_ASSERT_1( | ||
fileArg, | ||
lineNo, | ||
static_cast<U32>(arg1)); |
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: these U32s need re-review.
@@ -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<U32>(size), length, string); |
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: U32 use in events.
@@ -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<U32>(numPingEntries); |
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: is U32 tracking ping-entries appropriate?
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<U32>(portNum)); |
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: is U32 as port number appropriate?
@@ -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<I32>(readLen) |
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: reconsider I32 as size in events.
comQueueDepth[i] = this->m_queues[i].get_high_water_mark(); | ||
this->m_queues[i].clear_high_water_mark(); | ||
} | ||
this->tlmWrite_comQueueDepth(comQueueDepth); | ||
|
||
// 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++) { |
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.
Note: this is an autocoder problem, as array types use U32
indices.
@@ -180,7 +180,7 @@ namespace Svc { | |||
); | |||
} else { | |||
this->log_WARNING_HI_ShellCommandFailed( | |||
logStringCommand, status | |||
logStringCommand, static_cast<U32>(status) |
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: the use of U32
here is probably incorrect. Shell commands can return negative status.
@@ -154,18 +154,21 @@ 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<I32>(numRecords),stat); |
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: types in events here.
DpStateEntry entry; | ||
entry.dir = dir; | ||
entry.dir = static_cast<FwIndexType>(dir); |
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 is entry.dir
FwIndexType
here and FwSizeType
in the iterator.
Note: I will fix CI this afternoon, as I broke it. |
Change Description
Example of implementation of the
-Wconversion
warning fixes.Mostly consist of
static_cast
to change fromlong (unsigned) int
to(unsigned) int
.This is mainly to illustrate the impact of the warning flag on the current code.
Needs to be merged after nasa/fpp#400 has been merged.
Rationale
Example of implementation of one of the warning flags mentioned here: #2588
Testing/Review Recommendations
N/A
Future Work
N/A