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

CS_GetEntryIDEepromCmd can be simplified by removing redundant variables #107

Open
2 tasks done
thnkslprpt opened this issue Nov 30, 2024 · 0 comments · May be fixed by #108
Open
2 tasks done

CS_GetEntryIDEepromCmd can be simplified by removing redundant variables #107

thnkslprpt opened this issue Nov 30, 2024 · 0 comments · May be fixed by #108

Comments

@thnkslprpt
Copy link
Contributor

Checklist

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
The StartOfResultsTable and ResultsEntry are only used in a single if condition - unnecessary variables make the code more complicated and harder to test.

Code snips

CS/fsw/src/cs_eeprom_cmds.c

Lines 346 to 376 in f958cc0

void CS_GetEntryIDEepromCmd(const CS_GetEntryIDCmd_t *CmdPtr)
{
/* command verification variables */
CS_Res_EepromMemory_Table_Entry_t *StartOfResultsTable = NULL;
uint16 Loop = 0;
bool EntryFound = false;
CS_Res_EepromMemory_Table_Entry_t ResultsEntry;
StartOfResultsTable = CS_AppData.ResEepromTblPtr;
for (Loop = 0; Loop < CS_MAX_NUM_EEPROM_TABLE_ENTRIES; Loop++)
{
ResultsEntry = StartOfResultsTable[Loop];
if ((ResultsEntry.StartAddress <= CmdPtr->Payload.Address) &&
CmdPtr->Payload.Address <= (ResultsEntry.StartAddress + ResultsEntry.NumBytesToChecksum) &&
ResultsEntry.State != CS_STATE_EMPTY)
{
CFE_EVS_SendEvent(CS_GET_ENTRY_ID_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION,
"EEPROM Found Address 0x%08X in Entry ID %d", (unsigned int)(CmdPtr->Payload.Address), Loop);
EntryFound = true;
}
}
if (EntryFound == false)
{
CFE_EVS_SendEvent(CS_GET_ENTRY_ID_EEPROM_NOT_FOUND_INF_EID, CFE_EVS_EventType_INFORMATION,
"Address 0x%08X was not found in EEPROM table", (unsigned int)(CmdPtr->Payload.Address));
}
CS_AppData.HkPacket.Payload.CmdCounter++;
}

Expected behavior
Remove redundant variables.

Reporter Info
Avi Weiss   @thnkslprpt

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 a pull request may close this issue.

1 participant