Checklist
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
|
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
Checklist
Describe the bug
The
StartOfResultsTableandResultsEntryare only used in a singleifcondition - 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
Expected behavior
Remove redundant variables.
Reporter Info
Avi Weiss @thnkslprpt