Checklist
Describe the bug
Some issues that can be easily cleaned up to improve readability and ease maintenance by simplifying the code.
- superfluous initializations (when the variable is immediately or always assigned a value before being used)
- side-effects in conditionals that can be easily removed and end up more readable
- a couple of types can be updated (
size_t, CFE_MSG_FcnCode_t)
Code snips
Can be size_t:
|
const uint16 SizeofDefinitionTableEntry, const uint16 SizeofResultsTableEntry, |
Can be CFE_MSG_FcnCode_t:
Several functions with multiple CS calls that could be made clearer and more compliant with an additional Status/Result variable. e.g.:
|
void CS_DisableNameAppCmd(const CS_AppNameCmd_t *CmdPtr) |
|
{ |
|
/* command verification variables */ |
|
size_t ExpectedLength = sizeof(CS_AppNameCmd_t); |
|
|
|
CS_Res_App_Table_Entry_t *ResultsEntry; |
|
CS_Def_App_Table_Entry_t *DefinitionEntry; |
|
char Name[OS_MAX_API_NAME]; |
|
|
|
/* Verify command packet length */ |
|
if (CS_VerifyCmdLength(&CmdPtr->CmdHeader.Msg, ExpectedLength)) |
|
{ |
|
if (CS_CheckRecomputeOneshot() == false) |
|
{ |
|
strncpy(Name, CmdPtr->Name, sizeof(Name) - 1); |
|
Name[sizeof(Name) - 1] = '\0'; |
|
|
|
if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) |
|
{ |
|
ResultsEntry->State = CS_STATE_DISABLED; |
|
ResultsEntry->TempChecksumValue = 0; |
|
ResultsEntry->ByteOffset = 0; |
|
|
|
CFE_EVS_SendEvent(CS_DISABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, |
|
"Checksumming of app %s is Disabled", Name); |
|
|
|
if (CS_GetAppDefTblEntryByName(&DefinitionEntry, Name)) |
Expected behavior
Clear up where it makes sense.
Reporter Info
Avi Weiss @thnkslprpt
Checklist
Describe the bug
Some issues that can be easily cleaned up to improve readability and ease maintenance by simplifying the code.
size_t,CFE_MSG_FcnCode_t)Code snips
Can be
size_t:CS/fsw/inc/cs_tbldefs.h
Line 370 in bd4dd1c
Can be
CFE_MSG_FcnCode_t:CS/fsw/src/cs_app.c
Line 268 in bd4dd1c
Several functions with multiple CS calls that could be made clearer and more compliant with an additional Status/Result variable. e.g.:
CS/fsw/src/cs_app_cmds.c
Lines 215 to 241 in bd4dd1c
Expected behavior
Clear up where it makes sense.
Reporter Info
Avi Weiss @thnkslprpt