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

Refactor multiple return statements in LC_CreateTaskCDS() #92

Open
2 tasks done
thnkslprpt opened this issue Apr 28, 2023 · 0 comments · May be fixed by #94
Open
2 tasks done

Refactor multiple return statements in LC_CreateTaskCDS() #92

thnkslprpt opened this issue Apr 28, 2023 · 0 comments · May be fixed by #94

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

Code snips

LC/fsw/src/lc_app.c

Lines 734 to 853 in 45f8e87

int32 LC_CreateTaskCDS(void)
{
int32 Result;
uint32 DataSize;
/*
** Create CDS and try to restore Watchpoint Results Table (WRT) data
*/
DataSize = LC_MAX_WATCHPOINTS * sizeof(LC_WRTEntry_t);
Result = CFE_ES_RegisterCDS(&LC_OperData.WRTDataCDSHandle, DataSize, LC_WRT_CDSNAME);
if (Result == CFE_SUCCESS)
{
/*
** Normal result after a power on reset (cold boot) - continue with next CDS area
*/
LC_OperData.TableResults |= LC_WRT_CDS_CREATED;
}
else if (Result == CFE_ES_CDS_ALREADY_EXISTS)
{
/*
** Normal result after a processor reset (warm boot) - try to restore previous data
*/
LC_OperData.TableResults |= LC_WRT_CDS_CREATED;
Result = CFE_ES_RestoreFromCDS(LC_OperData.WRTPtr, LC_OperData.WRTDataCDSHandle);
if (Result == CFE_SUCCESS)
{
LC_OperData.TableResults |= LC_WRT_CDS_RESTORED;
}
}
else
{
CFE_EVS_SendEvent(LC_WRT_CDS_REGISTER_ERR_EID, CFE_EVS_EventType_ERROR,
"Error registering WRT CDS Area, RC=0x%08X", (unsigned int)Result);
return Result;
}
/*
** Create CDS and try to restore Actionpoint Results Table (ART) data
*/
DataSize = LC_MAX_ACTIONPOINTS * sizeof(LC_ARTEntry_t);
Result = CFE_ES_RegisterCDS(&LC_OperData.ARTDataCDSHandle, DataSize, LC_ART_CDSNAME);
if (Result == CFE_SUCCESS)
{
/*
** Normal result after a power on reset (cold boot) - continue with next CDS area
*/
LC_OperData.TableResults |= LC_ART_CDS_CREATED;
}
else if (Result == CFE_ES_CDS_ALREADY_EXISTS)
{
/*
** Normal result after a processor reset (warm boot) - try to restore previous data
*/
LC_OperData.TableResults |= LC_ART_CDS_CREATED;
Result = CFE_ES_RestoreFromCDS(LC_OperData.ARTPtr, LC_OperData.ARTDataCDSHandle);
if (Result == CFE_SUCCESS)
{
LC_OperData.TableResults |= LC_ART_CDS_RESTORED;
}
}
else
{
CFE_EVS_SendEvent(LC_ART_CDS_REGISTER_ERR_EID, CFE_EVS_EventType_ERROR,
"Error registering ART CDS Area, RC=0x%08X", (unsigned int)Result);
return Result;
}
/*
** Create CDS and try to restore Application (APP) data
*/
DataSize = sizeof(LC_AppData_t);
Result = CFE_ES_RegisterCDS(&LC_OperData.AppDataCDSHandle, DataSize, LC_APPDATA_CDSNAME);
if (Result == CFE_SUCCESS)
{
/*
** Normal result after a power on reset (cold boot) - continue with next CDS area
*/
LC_OperData.TableResults |= LC_APP_CDS_CREATED;
}
else if (Result == CFE_ES_CDS_ALREADY_EXISTS)
{
/*
** Normal result after a processor reset (warm boot) - try to restore previous data
*/
LC_OperData.TableResults |= LC_APP_CDS_CREATED;
Result = CFE_ES_RestoreFromCDS(&LC_AppData, LC_OperData.AppDataCDSHandle);
if ((Result == CFE_SUCCESS) && (LC_AppData.CDSSavedOnExit == LC_CDS_SAVED))
{
/*
** Success - only if previous session saved CDS data at least once
*/
LC_OperData.TableResults |= LC_APP_CDS_RESTORED;
/*
** May need to override the restored application state
*/
#if LC_STATE_WHEN_CDS_RESTORED != LC_STATE_FROM_CDS
LC_AppData.CurrentLCState = LC_STATE_WHEN_CDS_RESTORED;
#endif
}
}
else
{
CFE_EVS_SendEvent(LC_APP_CDS_REGISTER_ERR_EID, CFE_EVS_EventType_ERROR,
"Error registering application data CDS Area, RC=0x%08X", (unsigned int)Result);
return Result;
}
return CFE_SUCCESS;
}

Expected behavior
Single entry/exit point.

Reporter Info
Avi Weiss @thnkslprpt

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

Successfully merging a pull request may close this issue.

1 participant