Skip to content

Commit

Permalink
Fix nasa#1261, Remove redundant checks in CFE_EVS_EarlyInit
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Mar 24, 2021
1 parent 98bc158 commit 614db25
Showing 1 changed file with 42 additions and 53 deletions.
95 changes: 42 additions & 53 deletions modules/evs/fsw/src/cfe_evs_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,68 +109,57 @@ int32 CFE_EVS_EarlyInit(void)

CFE_PSP_Panic(CFE_PSP_PANIC_MEMORY_ALLOC);
}
else
{
Status = CFE_SUCCESS;
}

if (Status == CFE_SUCCESS)
{
CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *)resetAreaAddr;
/* Save pointer to the EVS portion of the CFE reset area */
CFE_EVS_Global.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log;
CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *)resetAreaAddr;
/* Save pointer to the EVS portion of the CFE reset area */
CFE_EVS_Global.EVS_LogPtr = &CFE_EVS_ResetDataPtr->EVS_Log;

/* Create semaphore to serialize access to event log */
Status = OS_MutSemCreate(&CFE_EVS_Global.EVS_SharedDataMutexID, "CFE_EVS_DataMutex", 0);
/* Create semaphore to serialize access to event log */
Status = OS_MutSemCreate(&CFE_EVS_Global.EVS_SharedDataMutexID, "CFE_EVS_DataMutex", 0);

if (Status != OS_SUCCESS)
{
CFE_ES_WriteToSysLog("EVS call to OS_MutSemCreate failed, RC=0x%08x\n", (unsigned int)Status);
if (Status != OS_SUCCESS)
{
CFE_ES_WriteToSysLog("EVS call to OS_MutSemCreate failed, RC=0x%08x\n", (unsigned int)Status);

/* Delay to allow message to be read */
OS_TaskDelay(CFE_EVS_PANIC_DELAY);
/* Delay to allow message to be read */
OS_TaskDelay(CFE_EVS_PANIC_DELAY);

CFE_PSP_Panic(CFE_PSP_PANIC_STARTUP_SEM);
}
else
{
Status = CFE_SUCCESS;
}
CFE_PSP_Panic(CFE_PSP_PANIC_STARTUP_SEM);
}

if (Status == CFE_SUCCESS)
else
{
/* Convert to CFE success type */
Status = CFE_SUCCESS;
}

/* Report log as enabled */
CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true;
/* Report log as enabled */
CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true;

/* Clear event log if power-on reset or bad contents */
if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON)
{
CFE_ES_WriteToSysLog("Event Log cleared following power-on reset\n");
EVS_ClearLog();
CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE;
}
else if (((CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_OVERWRITE) &&
(CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_DISCARD)) ||
((CFE_EVS_Global.EVS_LogPtr->LogFullFlag != false) &&
(CFE_EVS_Global.EVS_LogPtr->LogFullFlag != true)) ||
(CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX))
{
CFE_ES_WriteToSysLog("Event Log cleared, n=%d, c=%d, f=%d, m=%d, o=%d\n",
(int)CFE_EVS_Global.EVS_LogPtr->Next, (int)CFE_EVS_Global.EVS_LogPtr->LogCount,
(int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, (int)CFE_EVS_Global.EVS_LogPtr->LogMode,
(int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter);
EVS_ClearLog();
CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE;
}
else
{
CFE_ES_WriteToSysLog("Event Log restored, n=%d, c=%d, f=%d, m=%d, o=%d\n",
(int)CFE_EVS_Global.EVS_LogPtr->Next, (int)CFE_EVS_Global.EVS_LogPtr->LogCount,
(int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, (int)CFE_EVS_Global.EVS_LogPtr->LogMode,
(int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter);
}
/* Clear event log if power-on reset or bad contents */
if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON)
{
CFE_ES_WriteToSysLog("Event Log cleared following power-on reset\n");
EVS_ClearLog();
CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE;
}
else if (((CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_OVERWRITE) &&
(CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_DISCARD)) ||
((CFE_EVS_Global.EVS_LogPtr->LogFullFlag != false) && (CFE_EVS_Global.EVS_LogPtr->LogFullFlag != true)) ||
(CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX))
{
CFE_ES_WriteToSysLog("Event Log cleared, n=%d, c=%d, f=%d, m=%d, o=%d\n", (int)CFE_EVS_Global.EVS_LogPtr->Next,
(int)CFE_EVS_Global.EVS_LogPtr->LogCount, (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag,
(int)CFE_EVS_Global.EVS_LogPtr->LogMode,
(int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter);
EVS_ClearLog();
CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE;
}
else
{
CFE_ES_WriteToSysLog("Event Log restored, n=%d, c=%d, f=%d, m=%d, o=%d\n", (int)CFE_EVS_Global.EVS_LogPtr->Next,
(int)CFE_EVS_Global.EVS_LogPtr->LogCount, (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag,
(int)CFE_EVS_Global.EVS_LogPtr->LogMode,
(int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter);
}

return (Status);
Expand Down

0 comments on commit 614db25

Please sign in to comment.