Skip to content

Superfluous assignments, side-effects. type updates etc. #84

@thnkslprpt

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
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:

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.:

CS/fsw/src/cs_app_cmds.c

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions