Skip to content

Commit

Permalink
Fix nasa#1775, Add invalid ID Syslog entry for CFE_ES_DeleteApp and C…
Browse files Browse the repository at this point in the history
…FE_ES_ReloadApp
  • Loading branch information
skliper committed Aug 9, 2021
1 parent cfadad6 commit 10d3bde
Showing 1 changed file with 68 additions and 56 deletions.
124 changes: 68 additions & 56 deletions modules/es/fsw/src/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,51 +240,57 @@ CFE_Status_t CFE_ES_ReloadApp(CFE_ES_AppId_t AppID, const char *AppFileName)
os_fstat_t FileStatus;
CFE_ES_AppRecord_t *AppRecPtr = CFE_ES_LocateAppRecordByID(AppID);

if (AppRecPtr == NULL)
if (AppRecPtr != NULL)
{
return CFE_ES_ERR_RESOURCEID_NOT_VALID;
}

CFE_ES_LockSharedData(__func__, __LINE__);
CFE_ES_LockSharedData(__func__, __LINE__);

/*
** Check to see if the App is an external cFE App.
*/
if (AppRecPtr->Type == CFE_ES_AppType_CORE)
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Reload a CORE Application: %s.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
}
else if (AppRecPtr->AppState != CFE_ES_AppState_RUNNING)
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Reload Application %s, It is not running.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
}
else
{
/*
** Check to see if the file exists
** Check to see if the App is an external cFE App.
*/
if (OS_stat(AppFileName, &FileStatus) == OS_SUCCESS)
if (AppRecPtr->Type == CFE_ES_AppType_CORE)
{
CFE_ES_SysLogWrite_Unsync("%s: Reload Application %s Initiated. New filename = %s\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr), AppFileName);
strncpy(AppRecPtr->StartParams.BasicInfo.FileName, AppFileName,
sizeof(AppRecPtr->StartParams.BasicInfo.FileName) - 1);
AppRecPtr->StartParams.BasicInfo.FileName[sizeof(AppRecPtr->StartParams.BasicInfo.FileName) - 1] = 0;
AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD;
CFE_ES_SysLogWrite_Unsync("%s: Cannot Reload a CORE Application: %s.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
}
else if (AppRecPtr->AppState != CFE_ES_AppState_RUNNING)
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Reload Application %s, It is not running.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
}
else
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Reload Application %s, File %s does not exist.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr), AppFileName);
ReturnCode = CFE_ES_FILE_IO_ERR;
/*
** Check to see if the file exists
*/
if (OS_stat(AppFileName, &FileStatus) == OS_SUCCESS)
{
CFE_ES_SysLogWrite_Unsync("%s: Reload Application %s Initiated. New filename = %s\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr), AppFileName);
strncpy(AppRecPtr->StartParams.BasicInfo.FileName, AppFileName,
sizeof(AppRecPtr->StartParams.BasicInfo.FileName) - 1);
AppRecPtr->StartParams.BasicInfo.FileName[sizeof(AppRecPtr->StartParams.BasicInfo.FileName) - 1] = 0;
AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_RELOAD;
}
else
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Reload Application %s, File %s does not exist.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr), AppFileName);
ReturnCode = CFE_ES_FILE_IO_ERR;
}
}

CFE_ES_UnlockSharedData(__func__, __LINE__);
}
else /* App ID is not valid */
{
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;

CFE_ES_UnlockSharedData(__func__, __LINE__);
CFE_ES_WriteToSysLog("%s: Invalid Application ID received, AppID = %lu\n", __func__,
CFE_RESOURCEID_TO_ULONG(AppID));
}

return (ReturnCode);
}
Expand All @@ -302,36 +308,42 @@ CFE_Status_t CFE_ES_DeleteApp(CFE_ES_AppId_t AppID)
int32 ReturnCode = CFE_SUCCESS;
CFE_ES_AppRecord_t *AppRecPtr = CFE_ES_LocateAppRecordByID(AppID);

if (AppRecPtr == NULL)
if (AppRecPtr != NULL)
{
return CFE_ES_ERR_RESOURCEID_NOT_VALID;
}

CFE_ES_LockSharedData(__func__, __LINE__);
CFE_ES_LockSharedData(__func__, __LINE__);

/*
** Check to see if the App is an external cFE App.
*/
if (AppRecPtr->Type == CFE_ES_AppType_CORE)
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Delete a CORE Application: %s.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
/*
** Check to see if the App is an external cFE App.
*/
if (AppRecPtr->Type == CFE_ES_AppType_CORE)
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Delete a CORE Application: %s.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
}
else if (AppRecPtr->AppState != CFE_ES_AppState_RUNNING)
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Delete Application %s, It is not running.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
}
else
{
CFE_ES_SysLogWrite_Unsync("%s: Delete Application %s Initiated\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE;
}

CFE_ES_UnlockSharedData(__func__, __LINE__);
}
else if (AppRecPtr->AppState != CFE_ES_AppState_RUNNING)
else /* App ID is not valid */
{
CFE_ES_SysLogWrite_Unsync("%s: Cannot Delete Application %s, It is not running.\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
ReturnCode = CFE_ES_ERR_RESOURCEID_NOT_VALID;
}
else
{
CFE_ES_SysLogWrite_Unsync("%s: Delete Application %s Initiated\n", __func__,
CFE_ES_AppRecordGetName(AppRecPtr));
AppRecPtr->ControlReq.AppControlRequest = CFE_ES_RunStatus_SYS_DELETE;
}

CFE_ES_UnlockSharedData(__func__, __LINE__);
CFE_ES_WriteToSysLog("%s: Invalid Application ID received, AppID = %lu\n", __func__,
CFE_RESOURCEID_TO_ULONG(AppID));
}

return (ReturnCode);
}
Expand Down

0 comments on commit 10d3bde

Please sign in to comment.