-
Notifications
You must be signed in to change notification settings - Fork 27
Open
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
- Issue Multiple return statements in LC_CreateTaskCDS and LC_TableInit #36 was partially addressed with PR:
- Fix #36, Refactor LC_TableInit to remove multiple returns #68
Opening this issue to address the 2nd half - refactoring the multiple returns out ofLC_CreateTaskCDS()and simplify its control flow.
- Fix #36, Refactor LC_TableInit to remove multiple returns #68
Code snips
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
Metadata
Metadata
Assignees
Labels
No labels