Skip to content

CS_GetEntryIDEepromCmd can be simplified by removing redundant variables #107

Description

@thnkslprpt

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions