Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
thnkslprpt opened this issue May 31, 2023 · 0 comments · May be fixed by #85
Open
2 tasks done

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

thnkslprpt opened this issue May 31, 2023 · 0 comments · May be fixed by #85

Comments

@thnkslprpt
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants