-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Description
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
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:
Line 370 in bd4dd1c
| const uint16 SizeofDefinitionTableEntry, const uint16 SizeofResultsTableEntry, |
Can be CFE_MSG_FcnCode_t:
Line 268 in bd4dd1c
| uint16 CommandCode = 0; |
Several functions with multiple CS calls that could be made clearer and more compliant with an additional Status/Result variable. e.g.:
Lines 215 to 241 in bd4dd1c
| 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