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

Fix #92, Refactor LC_CreateTaskCDS() to remove multiple returns #94

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 64 additions & 55 deletions fsw/src/lc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,94 +762,103 @@ CFE_Status_t LC_CreateTaskCDS(void)
{
LC_OperData.TableResults |= LC_WRT_CDS_RESTORED;
}

Result = CFE_SUCCESS; /* Continue to next part of restore process */
}
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
** Create CDS and try to restore Actionpoint Results Table (ART) data
*/
LC_OperData.TableResults |= LC_ART_CDS_CREATED;

Result = CFE_ES_RestoreFromCDS(LC_OperData.ARTPtr, LC_OperData.ARTDataCDSHandle);
DataSize = LC_MAX_ACTIONPOINTS * sizeof(LC_ARTEntry_t);
Result = CFE_ES_RegisterCDS(&LC_OperData.ARTDataCDSHandle, DataSize, LC_ART_CDSNAME);

if (Result == CFE_SUCCESS)
{
LC_OperData.TableResults |= LC_ART_CDS_RESTORED;
/*
** Normal result after a power on reset (cold boot) - continue with next CDS area
*/
LC_OperData.TableResults |= LC_ART_CDS_CREATED;
}
}
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;
}
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;

/*
** 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);
Result = CFE_ES_RestoreFromCDS(LC_OperData.ARTPtr, LC_OperData.ARTDataCDSHandle);

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;
if (Result == CFE_SUCCESS)
{
LC_OperData.TableResults |= LC_ART_CDS_RESTORED;
}

Result = CFE_SUCCESS; /* Continue to next part of restore process */
}
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);
}
}
else if (Result == CFE_ES_CDS_ALREADY_EXISTS)

if (Result == CFE_SUCCESS)
{
/*
** Normal result after a processor reset (warm boot) - try to restore previous data
** Create CDS and try to restore Application (APP) data
*/
LC_OperData.TableResults |= LC_APP_CDS_CREATED;

Result = CFE_ES_RestoreFromCDS(&LC_AppData, LC_OperData.AppDataCDSHandle);
DataSize = sizeof(LC_AppData_t);
Result = CFE_ES_RegisterCDS(&LC_OperData.AppDataCDSHandle, DataSize, LC_APPDATA_CDSNAME);

if ((Result == CFE_SUCCESS) && (LC_AppData.CDSSavedOnExit == LC_CDS_SAVED))
if (Result == CFE_SUCCESS)
{
/*
** Success - only if previous session saved CDS data at least once
** Normal result after a power on reset (cold boot) - continue with next CDS area
*/
LC_OperData.TableResults |= LC_APP_CDS_RESTORED;

LC_OperData.TableResults |= LC_APP_CDS_CREATED;
}
else if (Result == CFE_ES_CDS_ALREADY_EXISTS)
{
/*
** May need to override the restored application state
** 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;
LC_AppData.CurrentLCState = LC_STATE_WHEN_CDS_RESTORED;
#endif
}

Result = CFE_SUCCESS; /* Return CFE_SUCCESS */
}
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);
}
}
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;
return Result;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Expand Down