-
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
Work/dp catalog #2713
Work/dp catalog #2713
Conversation
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.
} | ||
|
||
// reset the buffer for deserializing the entry | ||
entryBuffer.setBuffLen(static_cast<Fw::Serializable::SizeType>(size)); |
Check warning
Code scanning / CodeQL
Unchecked return value Warning
setBuffLen
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.
Probably should address this one.
// reset the buffer for serializing the entry | ||
entryBuffer.resetSer(); | ||
// serialize the file directory index | ||
entryBuffer.serialize(this->m_stateFileData[entry].entry.dir); |
Check warning
Code scanning / CodeQL
Unchecked return value Warning
serialize
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.
Must fix.
entryBuffer.resetSer(); | ||
// serialize the file directory index | ||
entryBuffer.serialize(this->m_stateFileData[entry].entry.dir); | ||
entryBuffer.serialize(this->m_stateFileData[entry].entry.record); |
Check warning
Code scanning / CodeQL
Unchecked return value Warning
serialize
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.
This is a must fix.
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.
Commenting partial review.
@@ -134,15 +135,22 @@ namespace Ref { | |||
|
|||
// if a Data product is being generated, store a record | |||
if (this->m_dpInProgress) { | |||
// printf("DP1: %u %u %lu %u\n", |
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.
dead code
Fw::SerializeStatus stat = this->m_dpContainer.serializeRecord_DataRecord(sigInfo); | ||
this->m_currDp++; | ||
this->m_dpBytes += SignalInfo::SERIALIZED_SIZE; | ||
// printf("DP2: %u %u %lu\n",this->m_dpContainer.getBuffer().getSize(),this->m_dpBytes,this->m_dpContainer.getDataSize()); |
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.
dead code
@@ -41,7 +41,7 @@ namespace Ref { | |||
test_start() | |||
{ | |||
ASSERT_TLM_Output_SIZE(0); | |||
sendCmd_SignalGen_Toggle(0, 0); | |||
sendCmd_Toggle(0, 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.
No UT for data product command?
@@ -17,6 +17,7 @@ | |||
|
|||
// The format string for a file name | |||
// The format arguments are base directory, container ID, time seconds, and time microseconds | |||
constexpr const char *DP_FILENAME_FORMAT = "%s/Dp_%08" PRI_FwDpIdType "_%08" PRIu32 "_%08" PRIu32 ".fdp"; | |||
#define DP_EXT ".fdp" |
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.
Why call this out when the user could edit below?
@@ -0,0 +1,12 @@ | |||
|
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.
Don't check in makefiles.
|
||
// buffer for reading entries | ||
|
||
BYTE buffer[sizeof(FwIndexType)+DpRecord::SERIALIZED_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.
maybe use sizeof(entry.dir) so it is auto-calculated?
} | ||
|
||
// buffer for writing entries | ||
BYTE buffer[sizeof(FwIndexType)+DpRecord::SERIALIZED_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.
Same.
FW_ASSERT(this->m_stateFileData); | ||
|
||
// We will append state to the existing state file | ||
// FIXME: Have to handle case where state file has partially transmitted |
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.
Fixme
} | ||
|
||
// buffer for writing entries | ||
BYTE buffer[sizeof(FwIndexType)+DpRecord::SERIALIZED_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.
Make this a constant, the same expression is used everywhere.
BYTE buffer[sizeof(FwIndexType)+DpRecord::SERIALIZED_SIZE]; | ||
Fw::ExternalSerializeBuffer entryBuffer(buffer, sizeof(buffer)); | ||
// reset the buffer for serializing the entry | ||
entryBuffer.resetSer(); |
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.
Pull this code into a helper? I see the same few lines repeated.
// fill the binary tree with DP files | ||
response = this->fillBinaryTree(); | ||
if (response != Fw::CmdResponse::OK) { | ||
return response; |
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.
Does this cause an inconsistent state? You may have failed with a partial binary tree, and an old or empty state file. This return bypasses the state file prune and write in the next (nominal) step.
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.
Looks good to me! Here are my comments.
Not Blocking for This PR
- In
configure
, the partitioning of memory into three pieces uses reinterpret cast on the address of an out-of-bounds array element, and it may not respect alignment requirements. This kind of code should do array access on the underlying byte buffer (so it's in bounds), it should use placement new to create the arrays, and it should respect alignment requirements. - There aren't enough assertions, particularly before pointer dereference
->
.
To Fix for this PR If Possible
- Add comments to
configure
to explain what is going on: (a) We are sizing a triple of arrays as an array of triples. (b) We are using array indexing to compute the address after the end of the array. - For consistency, remove the explicit
close
operation inloadStateFile
. In two other places the implicit operation is used.
@@ -102,10 +127,233 @@ | |||
this->m_initialized = true; | |||
} | |||
|
|||
void DpCatalog::resetBinaryTree() { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
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.
This is valid.
|
||
// request memory for catalog | ||
this->m_memSize = DP_MAX_FILES * (sizeof(DpStateEntry) + sizeof(DpSortedList)); | ||
this->m_stateFile = stateFile; |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
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.
Should probably consider this one.
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.
Nothing is a blocking fix, but we do need fixes eventually.
|
||
// request memory for catalog | ||
this->m_memSize = DP_MAX_FILES * (sizeof(DpStateEntry) + sizeof(DpSortedList)); | ||
this->m_stateFile = stateFile; |
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.
Should probably consider this one.
@@ -102,10 +127,233 @@ | |||
this->m_initialized = true; | |||
} | |||
|
|||
void DpCatalog::resetBinaryTree() { |
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.
This is valid.
} | ||
|
||
// reset the buffer for deserializing the entry | ||
entryBuffer.setBuffLen(static_cast<Fw::Serializable::SizeType>(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.
Probably should address this one.
// reset the buffer for serializing the entry | ||
entryBuffer.resetSer(); | ||
// serialize the file directory index | ||
entryBuffer.serialize(this->m_stateFileData[entry].entry.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.
Must fix.
|
||
// insert entry into sorted list. if can't insert, quit | ||
if (not this->insertEntry(this->m_dpList[this->m_numDpRecords])) { | ||
if (not this->insertEntry(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.
Consider fixing this.
|
||
// if the tree is empty, add the first entry | ||
if (this->m_dpTree == nullptr) { | ||
this->allocateNode(this->m_dpTree,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.
Must fix. Specifically since it is your return value.
DpCatalog::CheckStat DpCatalog::checkLeftRight(bool condition, DpBtreeNode* &node, const DpStateEntry& newEntry) { | ||
if (condition) { | ||
if (node->left == nullptr) { | ||
if (!this->allocateNode(node->left,newEntry)) { |
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.
Consider.
} | ||
} else { | ||
if (node->right == nullptr) { | ||
if (!this->allocateNode(node->right,newEntry)) { |
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.
Consider.
Missing return value checks:
|
Change Description
A description of the changes contained in the PR.
Rationale
A rationale for this change. e.g. fixes bug, or most projects need XYZ feature.
Testing/Review Recommendations
Fill in testing procedures, specific items to focus on for review, or other info to help the team verify these changes are flight-quality.
Future Work
Note any additional work that will be done relating to this issue.