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

Conversation

JohanBertrand
Copy link
Contributor

@JohanBertrand JohanBertrand commented Mar 19, 2024

Related Issue(s)
Has Unit Tests (y/n)
Documentation Included (y/n)

Change Description

Example of implementation of the -Wconversion warning fixes.

Mostly consist of static_cast to change from long (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

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

stat2 uses the basic integral type int rather than a typedef with size and signedness.
Drv/LinuxUartDriver/LinuxUartDriver.cpp Fixed Show fixed Hide fixed
Os/Posix/File.cpp Fixed Show fixed Hide fixed
@@ -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

memSize uses the basic integral type unsigned int rather than a typedef with size and signedness.
@@ -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

ret uses the basic integral type int rather than a typedef with size and signedness.
@@ -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

original_size uses the basic integral type signed long rather than a typedef with size and signedness.
@@ -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

original_size uses the basic integral type signed long rather than a typedef with size and signedness.
@@ -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

pre_write_size uses the basic integral type signed long rather than a typedef with size and signedness.
@@ -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

original_size uses the basic integral type signed long rather than a typedef with size and signedness.
Copy link

@github-advanced-security github-advanced-security bot left a 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.

@JohanBertrand
Copy link
Contributor Author

@LeStarch is it possible to trigger the CI please?

@LeStarch
Copy link
Collaborator

LeStarch commented Apr 5, 2024

@JohanBertrand let me fix the conflict, then sure!

@LeStarch
Copy link
Collaborator

LeStarch commented Apr 5, 2024

@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

write_size uses the basic integral type long rather than a typedef with size and signedness.
@@ -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

read_size uses the basic integral type long rather than a typedef with size and signedness.
@@ -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

Use of conditional compilation must be kept to a minimum.
@@ -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

Use of conditional compilation must be kept to a minimum.
@@ -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

m_numArgs uses the basic integral type unsigned int rather than a typedef with size and signedness.
@@ -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

status uses the basic integral type int rather than a typedef with size and signedness.
@@ -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

status uses the basic integral type int rather than a typedef with size and signedness.
@@ -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

status uses the basic integral type int rather than a typedef with size and signedness.
@@ -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

xferSize uses the basic integral type int rather than a typedef with size and signedness.
@@ -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

buffCapacity uses the basic integral type int rather than a typedef with size and signedness.
@@ -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

buffLength uses the basic integral type int rather than a typedef with size and signedness.
@@ -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

pushSucceeded uses the basic integral type bool rather than a typedef with size and signedness.
@@ -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

pushSucceeded uses the basic integral type bool rather than a typedef with size and signedness.
@@ -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

writeSize uses the basic integral type signed long rather than a typedef with size and signedness.
@JohanBertrand
Copy link
Contributor Author

@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.

@LeStarch
Copy link
Collaborator

LeStarch commented Apr 9, 2024

@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.

@LeStarch
Copy link
Collaborator

LeStarch commented Apr 9, 2024

As for the mac-side things are:

  1. Let CI run it
  2. Ask one of the maintainers to work through mac issues

@LeStarch
Copy link
Collaborator

@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:

  1. Keep this PR open
  2. Finish other work
  3. Let one of the maintainers (e.g. myself) fix collisions and conflicts
  4. Merge this and the other work.

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?

@JohanBertrand
Copy link
Contributor Author

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.

@@ -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;
Copy link
Contributor Author

@JohanBertrand JohanBertrand Apr 10, 2024

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

@LeStarch
Copy link
Collaborator

LeStarch commented Apr 11, 2024

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.

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:

  1. We review your work and note anything that may be a mask, which we should revisit in the upcoming work.
  2. Merge your work once the review has passed
  3. Revisit point one as we perform our updates without blocking this PR

This solves both concerns:

  1. Your work is merged without code-rotting
  2. "Masking" issues are flagged, resolving our 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.

@JohanBertrand
Copy link
Contributor Author

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!

@LeStarch
Copy link
Collaborator

As my own note: here is the success criteria I am using for the review:

  1. Cast to properly set type (e.g. FwAssertArgType): good, correct type chosen
  2. Cast to API call specified type: good, obeying API
  3. Cast to NATIVE_*_TYPE: good, will be caught in future review

Other items are flagged for future review.

@LeStarch
Copy link
Collaborator

@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.

@@ -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));
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: 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);
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.

@@ -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.

@@ -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));
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 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);
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: PlatformIntType usage here may need to be fixed.

Copy link
Collaborator

@LeStarch LeStarch left a 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]));
Copy link
Collaborator

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

Copy link
Contributor Author

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++) {
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: 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);
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: port should use FwIndexType

FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status, offset, serSize);
FW_ASSERT(
status == Fw::FW_SERIALIZE_OK,
status,
Copy link
Collaborator

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.

Copy link
Contributor Author

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);
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: U64 use seems suspicious.

}

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing a cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cast

Copy link
Contributor Author

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?

Copy link
Contributor Author

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 Show resolved Hide resolved
@@ -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++) {
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: 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++) {
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: use of U32 in this iterator. comQueueDepth.SIZE?

Copy link
Collaborator

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.

@JohanBertrand
Copy link
Contributor Author

@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.
Sorry for that.

Is there a problem with the CI stage CI/Framework ? I can't see the problem by looking at the CI log.

@LeStarch
Copy link
Collaborator

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.

@JohanBertrand
Copy link
Contributor Author

@LeStarch Thanks for the feedback. The issue should be fixed now, sorry for that.
I also fixed the error on the macOS CI at the same time.

@LeStarch
Copy link
Collaborator

Huzzah!

@JohanBertrand
Copy link
Contributor Author

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 // TODO: check type cast in front of the comments you added for future review?

@JohanBertrand
Copy link
Contributor Author

@LeStarch I solved the merge conflicts and added casts you requested in the review. Let me know if there is something else missing.

Copy link
Collaborator

@LeStarch LeStarch left a 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);
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: 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));
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: 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);
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: 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);
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: 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));
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: 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)
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: 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++) {
Copy link
Collaborator

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)
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: 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);
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: types in events here.

DpStateEntry entry;
entry.dir = dir;
entry.dir = static_cast<FwIndexType>(dir);
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 is entry.dir FwIndexType here and FwSizeType in the iterator.

@LeStarch
Copy link
Collaborator

Note: I will fix CI this afternoon, as I broke it.

return SOCK_SUCCESS;
}

SocketIpStatus IpSocket::recv(U8* data, I32& req_read) {
SocketIpStatus IpSocket::recv(U8* data, U32& req_read) {

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
@thomas-bc thomas-bc merged commit d518121 into nasa:devel Apr 30, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants