From 2237335fdda3d98cbc6b0ff797e4971daec3720d Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 3 Aug 2021 13:14:27 -0500 Subject: [PATCH] Fix #1755, separate variable for OSAL status Ensure a separate stack variable, always named "OsStatus", is used to hold the result of an OSAL API call. Do not use the same variable that is used to store a CFE status code. --- modules/cfe_assert/src/cfe_assert_init.c | 19 +-- modules/cfe_assert/src/cfe_assert_io.c | 16 +- .../ut-stubs/src/ut_osprintf_stubs.c | 38 ++--- modules/es/fsw/src/cfe_es_api.c | 52 ++++--- modules/es/fsw/src/cfe_es_apps.c | 145 ++++++++++-------- modules/es/fsw/src/cfe_es_backgroundtask.c | 17 +- modules/es/fsw/src/cfe_es_cds.c | 33 ++-- modules/es/fsw/src/cfe_es_mempool.c | 15 +- modules/es/fsw/src/cfe_es_perf.c | 15 +- modules/es/fsw/src/cfe_es_start.c | 93 ++++++----- modules/es/fsw/src/cfe_es_syslog.c | 22 +-- modules/es/fsw/src/cfe_es_task.c | 78 +++++++--- modules/es/ut-coverage/es_UT.c | 4 +- modules/evs/fsw/src/cfe_evs_log.c | 19 ++- modules/evs/fsw/src/cfe_evs_task.c | 25 +-- modules/evs/ut-coverage/evs_UT.c | 4 +- modules/fs/fsw/src/cfe_fs_api.c | 66 +++++--- modules/fs/fsw/src/cfe_fs_priv.c | 33 ++-- modules/fs/ut-coverage/fs_UT.c | 16 +- modules/sb/fsw/src/cfe_sb_api.c | 56 +++---- modules/sb/fsw/src/cfe_sb_init.c | 10 +- modules/sb/fsw/src/cfe_sb_priv.c | 26 ++-- modules/sb/fsw/src/cfe_sb_priv.h | 2 +- modules/sb/ut-coverage/sb_UT.c | 2 +- modules/tbl/fsw/src/cfe_tbl_internal.c | 74 ++++++--- modules/tbl/fsw/src/cfe_tbl_task_cmds.c | 49 +++--- modules/tbl/ut-coverage/tbl_UT.c | 8 +- modules/time/fsw/src/cfe_time_task.c | 37 ++--- modules/time/fsw/src/cfe_time_tone.c | 12 +- modules/time/ut-coverage/time_UT.c | 8 +- 30 files changed, 553 insertions(+), 441 deletions(-) diff --git a/modules/cfe_assert/src/cfe_assert_init.c b/modules/cfe_assert/src/cfe_assert_init.c index 9d77196a3..b25191158 100644 --- a/modules/cfe_assert/src/cfe_assert_init.c +++ b/modules/cfe_assert/src/cfe_assert_init.c @@ -49,7 +49,7 @@ void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback) */ int32 CFE_Assert_OpenLogFile(const char *Filename) { - int32 Status; + int32 OsStatus; char * Ext; size_t NameLen; @@ -76,11 +76,12 @@ int32 CFE_Assert_OpenLogFile(const char *Filename) } strcpy(&CFE_Assert_Global.LogFileTemp[NameLen], ".tmp"); - Status = OS_OpenCreate(&CFE_Assert_Global.LogFileDesc, CFE_Assert_Global.LogFileTemp, - OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status != OS_SUCCESS) + OsStatus = OS_OpenCreate(&CFE_Assert_Global.LogFileDesc, CFE_Assert_Global.LogFileTemp, + OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Failed to open %s, rc=%d\n", __func__, CFE_Assert_Global.LogFileTemp, (int)Status); + CFE_ES_WriteToSysLog("%s: Failed to open %s, rc=%ld\n", __func__, CFE_Assert_Global.LogFileTemp, + (long)OsStatus); return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -109,17 +110,17 @@ void CFE_Assert_CloseLogFile(void) */ int32 CFE_Assert_LibInit(CFE_ES_LibId_t LibId) { - int32 status; + int32 OsStatus; memset(&CFE_Assert_Global, 0, sizeof(CFE_Assert_Global)); UtTest_EarlyInit(); UT_BSP_Setup(); - status = OS_MutSemCreate(&CFE_Assert_Global.AccessMutex, "CFE_Assert", 0); - if (status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_Assert_Global.AccessMutex, "CFE_Assert", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, rc=%d\n", __func__, (int)status); + CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, rc=%ld\n", __func__, (long)OsStatus); return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } diff --git a/modules/cfe_assert/src/cfe_assert_io.c b/modules/cfe_assert/src/cfe_assert_io.c index b16a0377f..18876eaf0 100644 --- a/modules/cfe_assert/src/cfe_assert_io.c +++ b/modules/cfe_assert/src/cfe_assert_io.c @@ -40,23 +40,23 @@ CFE_Assert_Global_t CFE_Assert_Global; void UT_BSP_Lock(void) { - int32 rc; + int32 OsStatus; - rc = OS_MutSemTake(CFE_Assert_Global.AccessMutex); - if (rc != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_Assert_Global.AccessMutex); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemTake(): %d\n", __func__, (int)rc); + CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemTake(): %ld\n", __func__, (long)OsStatus); } } void UT_BSP_Unlock(void) { - int32 rc; + int32 OsStatus; - rc = OS_MutSemGive(CFE_Assert_Global.AccessMutex); - if (rc != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_Assert_Global.AccessMutex); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemGive(): %d\n", __func__, (int)rc); + CFE_ES_WriteToSysLog("%s(): Error from OS_MutSemGive(): %ld\n", __func__, (long)OsStatus); } } diff --git a/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c b/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c index e87e13e91..5ead9a8a9 100644 --- a/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c +++ b/modules/core_private/ut-stubs/src/ut_osprintf_stubs.c @@ -42,55 +42,55 @@ const char *UT_OSP_MESSAGES[] = { [0] = NULL, /* Message 0 is reserved */ - [UT_OSP_MOUNT_VOLATILE] = "%s: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_MOUNT_VOLATILE] = "%s: Error Mounting Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_CORE_RUNTIME] = "%s: CORE Application %s Had a Runtime Error.\n", - [UT_OSP_CORE_APP_CREATE] = "%s: OS_TaskCreate error creating core App: %s: EC = 0x%08X\n", + [UT_OSP_CORE_APP_CREATE] = "%s: OS_TaskCreate error creating core App: %s: EC = %ld\n", [UT_OSP_EARLYINIT] = "%s: Error returned when calling function: %s: EC = 0x%08X\n", [UT_OSP_FIND_LIBRARY] = "%s: Could not find Library Init symbol:%s. EC = %d\n", [UT_OSP_POR_MAX_HW_SPECIAL] = "%s: POWER ON RESET due to max proc resets (HW Spec Cmd).\n", [UT_OSP_CANNOT_CALL_APP_MAIN] = "%s: Error: Cannot Call from a cFE App Main Task. ID = %d\n", [UT_OSP_FUNCTION_POINTER] = "%s: bad function pointer ( table entry = %d).\n", - [UT_OSP_STARTUP_READ] = "%s: Error Reading Startup file. EC = 0x%08X\n", + [UT_OSP_STARTUP_READ] = "%s: Error Reading Startup file. EC = %ld\n", [UT_OSP_PROC_RESET_COMMANDED] = "%s: PROCESSOR RESET called from CFE_ES_ResetCFE (Commanded).\n", - [UT_OSP_MUTEX_TAKE] = "%s: SharedData Mutex Take Err Stat=0x%x,Func=%s,Line=%d\n", + [UT_OSP_MUTEX_TAKE] = "%s: SharedData Mutex Take Err Stat=%ld,Func=%s,Line=%d\n", [UT_OSP_STARTUP_SYNC_FAIL_1] = "%s: Startup Sync failed - Applications may not have all started\n", [UT_OSP_SYSTEM_LOG_FULL] = "Warning: System Log full, log entry discarded.\n", [UT_OSP_FILE_LINE_TOO_LONG] = "%s: **WARNING** File Line %u is malformed: %u bytes, %u tokens.\n", - [UT_OSP_SHARED_LIBRARY_INIT] = "%s: Load Shared Library Init Error = 0x%08x\n", - [UT_OSP_REMOVE_VOLATILE] = "%s: Error Removing Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_SHARED_LIBRARY_INIT] = "%s: Load Shared Library Init Error = %ld\n", + [UT_OSP_REMOVE_VOLATILE] = "%s: Error Removing Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_POR_OTHER] = "%s: POWER ON RESET due to other cause (See Subtype).\n", - [UT_OSP_DETERMINE_BLOCKS] = "%s: Error Determining Blocks Free on Volume. EC = 0x%08X\n", + [UT_OSP_DETERMINE_BLOCKS] = "%s: Error Determining Blocks Free on Volume. EC = %ld\n", [UT_OSP_STARTUP_SYNC_FAIL_2] = "%s: Startup Sync failed - Applications may not have all initialized\n", [UT_OSP_LIBRARY_SLOTS] = "%s: No free library slots available\n", [UT_OSP_EXTRACT_FILENAME_UT] = "%s: Unable to extract filename from path: %s.\n", [UT_OSP_APP_PATH_FILE_TOO_LONG] = "%s: Application path plus file name length (%d) exceeds max allowed (%d)\n", - [UT_OSP_REFORMAT_VOLATILE] = "%s: Error Re-Formating Volatile(RAM) Volume. EC = 0x%08X\n", - [UT_OSP_EXTRACT_FILENAME_UT55] = "%s: Could not load file:%s. EC = 0x%08X\n", + [UT_OSP_REFORMAT_VOLATILE] = "%s: Error Re-Formating Volatile(RAM) Volume. EC = %ld\n", + [UT_OSP_EXTRACT_FILENAME_UT55] = "%s: Could not load file:%s. EC = %ld\n", [UT_OSP_EXTRACT_FILENAME_UT46] = "%s: Unable to extract filename from path: %s.\n", [UT_OSP_NO_FREE_APP_SLOTS] = "%s: No free application slots available\n", [UT_OSP_EXTRACT_FILENAME_UT57] = "%s: Unable to extract filename from path: %s.\n", - [UT_OSP_MUTEX_GIVE] = "%s: SharedData Mutex Give Err Stat=0x%x,Func=%s,Line=%d\n", - [UT_OSP_CANNOT_FIND_SYMBOL] = "%s: Could not find symbol:%s. EC = 0x%08X\n", - [UT_OSP_INIT_VOLATILE] = "%s: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_MUTEX_GIVE] = "%s: SharedData Mutex Give Err Stat=%ld,Func=%s,Line=%d\n", + [UT_OSP_CANNOT_FIND_SYMBOL] = "%s: Could not find symbol:%s. EC = %ld\n", + [UT_OSP_INIT_VOLATILE] = "%s: Error Initializing Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_APP_INIT] = "%s: Application Init Failed,RC=0x%08X\n", [UT_OSP_POR_MAX_PROC_RESETS] = "%s: POWER ON RESET due to max proc resets (Commanded).\n", [UT_OSP_CANNOT_RESTART_APP] = "%s: Cannot Restart Application %s, It is not running.\n", [UT_OSP_INSUFF_FREE_SPACE] = "%s: Insufficent Free Space on Volatile Disk, Reformatting.\n", [UT_OSP_LOAD_SHARED_LIBRARY] = "%s: Could not load cFE Shared Library\n", [UT_OSP_POR_HW_SPECIAL] = "%s: POWER ON RESET due to HW Special Cmd (Hw Spec Cmd).\n", - [UT_OSP_APP_CREATE] = "%s: AppCreate Error: TaskCreate %s Failed. EC = 0x%08X!\n", - [UT_OSP_CREATE_VOLATILE] = "%s: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n", - [UT_OSP_MODULE_UNLOAD_FAILED] = "%s: Failed to unload: %s. EC = 0x%08X\n", + [UT_OSP_APP_CREATE] = "%s: AppCreate Error: TaskCreate %s Failed. EC = %ld!\n", + [UT_OSP_CREATE_VOLATILE] = "%s: Error Creating Volatile(RAM) Volume. EC = %ld\n", + [UT_OSP_MODULE_UNLOAD_FAILED] = "%s: Failed to unload: %s. EC = %ld\n", [UT_OSP_POR_COMMANDED] = "%s: POWERON RESET called from CFE_ES_ResetCFE (Commanded).\n", - [UT_OSP_REMOUNT_VOLATILE] = "%s: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_REMOUNT_VOLATILE] = "%s: Error Re-Mounting Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_CORE_APP_EXIT] = "%s: Cannot Exit CORE Application %s\n", [UT_OSP_ES_APP_STARTUP_OPEN] = "%s: Opened ES App Startup file: %s\n", [UT_OSP_CORE_INIT] = "%s: CORE Application %s Had an Init Error.\n", [UT_OSP_PROC_RESET_MAX_HW_SPECIAL] = "%s: PROCESSOR RESET due to Hardware Special Command (HW Spec Cmd).\n", - [UT_OSP_COMMAND_PIPE] = "%s: Error reading cmd pipe,RC=0x%08X\n", - [UT_OSP_UNMOUNT_VOLATILE] = "%s: Error Un-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", + [UT_OSP_COMMAND_PIPE] = "%s: Error reading cmd pipe,RC=%ld\n", + [UT_OSP_UNMOUNT_VOLATILE] = "%s: Error Un-Mounting Volatile(RAM) Volume. EC = %ld\n", [UT_OSP_TABLE_SLOT_IN_USE] = "%s: Error: ES_TaskTable slot in use at task creation!\n", - [UT_OSP_CANNOT_OPEN_ES_APP_STARTUP] = "%s: Error, Can't Open ES App Startup file: %s EC = 0x%08X\n", + [UT_OSP_CANNOT_OPEN_ES_APP_STARTUP] = "%s: Error, Can't Open ES App Startup file: %s, EC = %ld\n", [UT_OSP_EXTRACT_FILENAME_CF] = "%s: Unable to extract filename from path: %s.\n", [UT_OSP_INVALID_LOG_MODE] = "Warning: Invalid System Log mode, log entry discarded.\n", [UT_OSP_LIB_PATH_FILE_TOO_LONG] = "%s: Library path plus file name length (%d) exceeds max allowed (%d)\n", diff --git a/modules/es/fsw/src/cfe_es_api.c b/modules/es/fsw/src/cfe_es_api.c index f43bfc024..24745d14c 100644 --- a/modules/es/fsw/src/cfe_es_api.c +++ b/modules/es/fsw/src/cfe_es_api.c @@ -771,7 +771,7 @@ CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName) { osal_id_t OsalId; - int32 Status; + int32 OsStatus; CFE_Status_t Result; if (TaskName == NULL || TaskIdPtr == NULL) @@ -780,8 +780,8 @@ CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *Task } /* For tasks IDs, defer to OSAL for name lookup */ - Status = OS_TaskGetIdByName(&OsalId, TaskName); - if (Status == OS_SUCCESS) + OsStatus = OS_TaskGetIdByName(&OsalId, TaskName); + if (OsStatus == OS_SUCCESS) { Result = CFE_SUCCESS; *TaskIdPtr = CFE_ES_TaskId_FromOSAL(OsalId); @@ -969,7 +969,7 @@ CFE_Status_t CFE_ES_GetLibName(char *LibName, CFE_ES_LibId_t LibId, size_t Buffe *-----------------------------------------------------------------*/ CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t BufferLength) { - int32 Result; + int32 OsStatus; osal_id_t OsalId; if (BufferLength == 0 || TaskName == NULL) @@ -985,10 +985,10 @@ CFE_Status_t CFE_ES_GetTaskName(char *TaskName, CFE_ES_TaskId_t TaskId, size_t B /* * Query OSAL to get the task name */ - OsalId = CFE_ES_TaskId_ToOSAL(TaskId); - Result = OS_GetResourceName(OsalId, TaskName, BufferLength); + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); + OsStatus = OS_GetResourceName(OsalId, TaskName, BufferLength); - if (Result != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -1409,7 +1409,7 @@ CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) uint32 i; bool TaskIsMain; int32 ReturnCode = CFE_SUCCESS; - int32 OSReturnCode; + int32 OsStatus; osal_id_t OsalId; /* @@ -1452,9 +1452,9 @@ CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) /* ** Can delete the Task */ - OsalId = CFE_ES_TaskId_ToOSAL(TaskId); - OSReturnCode = OS_TaskDelete(OsalId); - if (OSReturnCode == OS_SUCCESS) + OsalId = CFE_ES_TaskId_ToOSAL(TaskId); + OsStatus = OS_TaskDelete(OsalId); + if (OsStatus == OS_SUCCESS) { /* ** Invalidate the task table entry @@ -1470,8 +1470,8 @@ CFE_Status_t CFE_ES_DeleteChildTask(CFE_ES_TaskId_t TaskId) } else { - CFE_ES_SysLogWrite_Unsync("%s: Error Calling OS_TaskDelete: Task %lu, RC = 0x%08X\n", __func__, - CFE_RESOURCEID_TO_ULONG(TaskId), (unsigned int)OSReturnCode); + CFE_ES_SysLogWrite_Unsync("%s: Error Calling OS_TaskDelete: Task %lu, RC = %ld\n", __func__, + CFE_RESOURCEID_TO_ULONG(TaskId), (long)OsStatus); ReturnCode = CFE_ES_ERR_CHILD_TASK_DELETE; } } @@ -2168,6 +2168,7 @@ CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) { osal_id_t OsalID; osal_index_t OsalIndex; + int32 OsStatus; if (!CFE_RESOURCEID_TEST_DEFINED(TaskID)) { @@ -2179,8 +2180,9 @@ CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) return CFE_ES_BAD_ARGUMENT; } - OsalID = CFE_ES_TaskId_ToOSAL(TaskID); - if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex) != OS_SUCCESS) + OsalID = CFE_ES_TaskId_ToOSAL(TaskID); + OsStatus = OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex); + if (OsStatus != OS_SUCCESS) { return CFE_ES_ERR_RESOURCEID_NOT_VALID; } @@ -2218,17 +2220,17 @@ CFE_Status_t CFE_ES_CounterID_ToIndex(CFE_ES_CounterId_t CounterId, uint32 *Idx) *-----------------------------------------------------------------*/ void CFE_ES_LockSharedData(const char *FunctionName, int32 LineNumber) { - int32 Status; + int32 OsStatus; - Status = OS_MutSemTake(CFE_ES_Global.SharedDataMutex); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_ES_Global.SharedDataMutex); + if (OsStatus != OS_SUCCESS) { /* * NOTE: this is going to write into a buffer that itself * is _supposed_ to be protected by this same mutex. */ - CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Take Err Stat=0x%x,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, FunctionName, (int)LineNumber); + CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Take Err Stat=%ld,Func=%s,Line=%d\n", __func__, (long)OsStatus, + FunctionName, (int)LineNumber); } /* end if */ @@ -2245,17 +2247,17 @@ void CFE_ES_LockSharedData(const char *FunctionName, int32 LineNumber) *-----------------------------------------------------------------*/ void CFE_ES_UnlockSharedData(const char *FunctionName, int32 LineNumber) { - int32 Status; + int32 OsStatus; - Status = OS_MutSemGive(CFE_ES_Global.SharedDataMutex); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_ES_Global.SharedDataMutex); + if (OsStatus != OS_SUCCESS) { /* * NOTE: this is going to write into a buffer that itself * is _supposed_ to be protected by this same mutex. */ - CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Give Err Stat=0x%x,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, FunctionName, (int)LineNumber); + CFE_ES_SysLogWrite_Unsync("%s: SharedData Mutex Give Err Stat=%ld,Func=%s,Line=%d\n", __func__, (long)OsStatus, + FunctionName, (int)LineNumber); } /* end if */ diff --git a/modules/es/fsw/src/cfe_es_apps.c b/modules/es/fsw/src/cfe_es_apps.c index 2dab9e8b3..8db23681e 100644 --- a/modules/es/fsw/src/cfe_es_apps.c +++ b/modules/es/fsw/src/cfe_es_apps.c @@ -82,6 +82,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) uint32 BuffLen; /* Length of the current buffer */ osal_id_t AppFile = OS_OBJECT_ID_UNDEFINED; int32 Status; + int32 OsStatus; char c; bool LineTooLong = false; bool FileOpened = false; @@ -100,17 +101,22 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) if (Status == CFE_SUCCESS) { - Status = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); - } - - if (Status >= 0) - { - CFE_ES_WriteToSysLog("%s: Opened ES App Startup file: %s\n", __func__, ScriptFileName); - FileOpened = true; + OsStatus = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); + if (OsStatus == OS_SUCCESS) + { + FileOpened = true; + } + else + { + CFE_ES_WriteToSysLog("%s: Cannot Open Volatile Startup file: %s, Trying Nonvolatile.\n", __func__, + ScriptFileName); + } } else { - CFE_ES_WriteToSysLog("%s: Cannot Open Volatile Startup file, Trying Nonvolatile.\n", __func__); + /* not expected -- likely a misconfiguration in CFE_PLATFORM_ES_VOLATILE_STARTUP_FILE setting */ + CFE_ES_WriteToSysLog("%s: CFE_FS_ParseInputFileName() RC=%08x parsing volatile script file name.\n", + __func__, (unsigned int)Status); } } /* end if */ @@ -129,17 +135,21 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) if (Status == CFE_SUCCESS) { - Status = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); - } - - if (Status >= 0) - { - CFE_ES_WriteToSysLog("%s: Opened ES App Startup file: %s\n", __func__, ScriptFileName); - FileOpened = true; + OsStatus = OS_OpenCreate(&AppFile, ScriptFileName, OS_FILE_FLAG_NONE, OS_READ_ONLY); + if (OsStatus == OS_SUCCESS) + { + FileOpened = true; + } + else + { + CFE_ES_WriteToSysLog("%s: Error, Can't Open ES App Startup file: %s, EC = %ld\n", __func__, + ScriptFileName, (long)OsStatus); + } } else { - CFE_ES_WriteToSysLog("%s: Error, Can't Open ES App Startup file: %s EC = 0x%08X\n", __func__, StartFilePath, + /* not expected -- likely a misconfiguration in the user-supplied StartFilePath */ + CFE_ES_WriteToSysLog("%s: CFE_FS_ParseInputFileName() RC=%08x parsing StartFilePath.\n", __func__, (unsigned int)Status); } } @@ -149,6 +159,8 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) */ if (FileOpened == true) { + CFE_ES_WriteToSysLog("%s: Opened ES App Startup file: %s\n", __func__, ScriptFileName); + memset(ES_AppLoadBuffer, 0x0, ES_START_BUFF_SIZE); BuffLen = 0; NumTokens = 0; @@ -161,13 +173,13 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) */ while (1) { - Status = OS_read(AppFile, &c, 1); - if (Status < 0) + OsStatus = OS_read(AppFile, &c, 1); + if (OsStatus < OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Reading Startup file. EC = 0x%08X\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: Error Reading Startup file. EC = %ld\n", __func__, (long)OsStatus); break; } - else if (Status == 0) + else if (OsStatus == 0) { /* ** EOF Reached @@ -394,7 +406,7 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam osal_id_t ModuleId; cpuaddr InitSymbolAddress; int32 ReturnCode; - int32 StatusCode; + int32 OsStatus; uint32 LoadFlags; LoadFlags = 0; @@ -432,12 +444,12 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam /* * Load the module via OSAL. */ - StatusCode = OS_ModuleLoad(&ModuleId, ModuleName, LoadParams->FileName, LoadFlags); + OsStatus = OS_ModuleLoad(&ModuleId, ModuleName, LoadParams->FileName, LoadFlags); - if (StatusCode != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Could not load file:%s. EC = 0x%08X\n", __func__, LoadParams->FileName, - (unsigned int)StatusCode); + CFE_ES_WriteToSysLog("%s: Could not load file:%s. EC = %ld\n", __func__, LoadParams->FileName, + (long)OsStatus); ModuleId = OS_OBJECT_ID_UNDEFINED; ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -453,11 +465,11 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam if (ReturnCode == CFE_SUCCESS && LoadParams->InitSymbolName[0] != 0 && strcmp(LoadParams->InitSymbolName, "NULL") != 0) { - StatusCode = OS_ModuleSymbolLookup(ModuleId, &InitSymbolAddress, LoadParams->InitSymbolName); - if (StatusCode != OS_SUCCESS) + OsStatus = OS_ModuleSymbolLookup(ModuleId, &InitSymbolAddress, LoadParams->InitSymbolName); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Could not find symbol:%s. EC = 0x%08X\n", __func__, LoadParams->InitSymbolName, - (unsigned int)StatusCode); + CFE_ES_WriteToSysLog("%s: Could not find symbol:%s. EC = %ld\n", __func__, LoadParams->InitSymbolName, + (long)OsStatus); ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -472,11 +484,10 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam { /* If the module had been successfully loaded, then unload it, * so that it does not consume resources */ - StatusCode = OS_ModuleUnload(ModuleId); - if (StatusCode != OS_SUCCESS) /* There's not much we can do except notify */ + OsStatus = OS_ModuleUnload(ModuleId); + if (OsStatus != OS_SUCCESS) /* There's not much we can do except notify */ { - CFE_ES_WriteToSysLog("%s: Failed to unload: %s. EC = 0x%08X\n", __func__, ModuleName, - (unsigned int)StatusCode); + CFE_ES_WriteToSysLog("%s: Failed to unload: %s. EC = %ld\n", __func__, ModuleName, (long)OsStatus); } } @@ -583,23 +594,23 @@ int32 CFE_ES_StartAppTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ CFE_ES_TaskRecord_t *TaskRecPtr; osal_id_t OsalTaskId; CFE_ES_TaskId_t LocalTaskId; - int32 StatusCode; + int32 OsStatus; int32 ReturnCode; /* * Create the primary task for the newly loaded task */ - StatusCode = OS_TaskCreate(&OsalTaskId, /* task id */ - TaskName, /* task name matches app name for main task */ - CFE_ES_TaskEntryPoint, /* task function pointer */ - OSAL_TASK_STACK_ALLOCATE, /* stack pointer (allocate) */ - Params->StackSize, /* stack size */ - Params->Priority, /* task priority */ - OS_FP_ENABLED); /* task options */ + OsStatus = OS_TaskCreate(&OsalTaskId, /* task id */ + TaskName, /* task name matches app name for main task */ + CFE_ES_TaskEntryPoint, /* task function pointer */ + OSAL_TASK_STACK_ALLOCATE, /* stack pointer (allocate) */ + Params->StackSize, /* stack size */ + Params->Priority, /* task priority */ + OS_FP_ENABLED); /* task options */ CFE_ES_LockSharedData(__func__, __LINE__); - if (StatusCode == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { /* * As this is a newly-created task, this shouldn't fail. @@ -638,8 +649,8 @@ int32 CFE_ES_StartAppTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ } else { - CFE_ES_SysLogWrite_Unsync("%s: AppCreate Error: TaskCreate %s Failed. EC = 0x%08X!\n", __func__, TaskName, - (unsigned int)StatusCode); + CFE_ES_SysLogWrite_Unsync("%s: AppCreate Error: TaskCreate %s Failed. EC = %ld!\n", __func__, TaskName, + (long)OsStatus); ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; *TaskIdPtr = CFE_ES_TASKID_UNDEFINED; } @@ -1330,6 +1341,7 @@ void CFE_ES_ProcessControlRequest(CFE_ES_AppId_t AppId) int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId) { uint32 i; + int32 OsStatus; int32 Status; int32 ReturnCode; CFE_ES_TaskId_t TaskList[OS_MAX_TASKS]; @@ -1509,11 +1521,11 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId) /* ** Unload the module only if it is an external app */ - Status = OS_ModuleUnload(ModuleId); - if (Status != OS_SUCCESS) + OsStatus = OS_ModuleUnload(ModuleId); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Module (ID:0x%08lX) Unload failed. RC=0x%08X\n", __func__, - OS_ObjectIdToInteger(ModuleId), (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: Module (ID:0x%08lX) Unload failed. RC=%ld\n", __func__, + OS_ObjectIdToInteger(ModuleId), (long)OsStatus); ReturnCode = CFE_ES_APP_CLEANUP_ERR; } } @@ -1576,7 +1588,7 @@ typedef struct void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) { CFE_ES_CleanupState_t *CleanState; - int32 Status; + int32 OsStatus; osal_objtype_t ObjType; bool ObjIsValid; @@ -1587,46 +1599,46 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) switch (ObjType) { case OS_OBJECT_TYPE_OS_TASK: - Status = OS_TaskDelete(ObjectId); + OsStatus = OS_TaskDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_QUEUE: - Status = OS_QueueDelete(ObjectId); + OsStatus = OS_QueueDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_BINSEM: - Status = OS_BinSemDelete(ObjectId); + OsStatus = OS_BinSemDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_COUNTSEM: - Status = OS_CountSemDelete(ObjectId); + OsStatus = OS_CountSemDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_MUTEX: - Status = OS_MutSemDelete(ObjectId); + OsStatus = OS_MutSemDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_TIMECB: - Status = OS_TimerDelete(ObjectId); + OsStatus = OS_TimerDelete(ObjectId); break; case OS_OBJECT_TYPE_OS_STREAM: - Status = OS_close(ObjectId); + OsStatus = OS_close(ObjectId); break; case OS_OBJECT_TYPE_OS_MODULE: - Status = OS_ModuleUnload(ObjectId); + OsStatus = OS_ModuleUnload(ObjectId); break; default: ObjIsValid = false; - Status = OS_ERROR; + OsStatus = OS_ERROR; break; } if (ObjIsValid) { ++CleanState->FoundObjects; - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { ++CleanState->DeletedObjects; } else { - CFE_ES_SysLogWrite_Unsync("%s: Call to OSAL Delete Object (ID:%lu) failed. RC=0x%08X\n", __func__, - OS_ObjectIdToInteger(ObjectId), (unsigned int)Status); + CFE_ES_SysLogWrite_Unsync("%s: Call to OSAL Delete Object (ID:%lu) failed. RC=%ld\n", __func__, + OS_ObjectIdToInteger(ObjectId), (long)OsStatus); if (CleanState->OverallStatus == CFE_SUCCESS) { /* @@ -1675,6 +1687,7 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg) int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId) { CFE_ES_CleanupState_t CleanState; + int32 OsStatus; int32 Result; osal_id_t OsalId; @@ -1713,8 +1726,8 @@ int32 CFE_ES_CleanupTaskResources(CFE_ES_TaskId_t TaskId) ** In this case the OS_ERR_INVALID_ID status is returned, but ** that is OK, there is nothing else needed to do. */ - Result = OS_TaskDelete(OsalId); - if (Result == OS_SUCCESS || Result == OS_ERR_INVALID_ID) + OsStatus = OS_TaskDelete(OsalId); + if (OsStatus == OS_SUCCESS || OsStatus == OS_ERR_INVALID_ID) { Result = CleanState.OverallStatus; if (Result == CFE_SUCCESS && CleanState.FoundObjects > 0) @@ -1772,10 +1785,10 @@ void CFE_ES_CopyModuleStatusInfo(const CFE_ES_ModuleLoadStatus_t *StatusPtr, CFE void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoPtr) { OS_module_prop_t ModuleInfo; - int32 ReturnCode; + int32 OsStatus; - ReturnCode = OS_ModuleInfo(ModuleId, &ModuleInfo); - if (ReturnCode == OS_SUCCESS) + OsStatus = OS_ModuleInfo(ModuleId, &ModuleInfo); + if (OsStatus == OS_SUCCESS) { AppInfoPtr->AddressesAreValid = (sizeof(ModuleInfo.addr.code_address) <= sizeof(AppInfoPtr->CodeAddress)) && ModuleInfo.addr.valid; diff --git a/modules/es/fsw/src/cfe_es_backgroundtask.c b/modules/es/fsw/src/cfe_es_backgroundtask.c index 4c2585caf..d0532ed31 100644 --- a/modules/es/fsw/src/cfe_es_backgroundtask.c +++ b/modules/es/fsw/src/cfe_es_backgroundtask.c @@ -99,7 +99,7 @@ const CFE_ES_BackgroundJobEntry_t CFE_ES_BACKGROUND_JOB_TABLE[] = { *-----------------------------------------------------------------*/ void CFE_ES_BackgroundTask(void) { - int32 status; + int32 OsStatus; uint32 JobTotal; uint32 NumJobsRunning; uint32 NextDelay; @@ -153,11 +153,11 @@ void CFE_ES_BackgroundTask(void) CFE_ES_Global.BackgroundTask.NumJobsRunning = NumJobsRunning; - status = OS_BinSemTimedWait(CFE_ES_Global.BackgroundTask.WorkSem, NextDelay); - if (status != OS_SUCCESS && status != OS_SEM_TIMEOUT) + OsStatus = OS_BinSemTimedWait(CFE_ES_Global.BackgroundTask.WorkSem, NextDelay); + if (OsStatus != OS_SUCCESS && OsStatus != OS_SEM_TIMEOUT) { /* should never occur */ - CFE_ES_WriteToSysLog("%s: Failed to take background sem: %08lx\n", __func__, (unsigned long)status); + CFE_ES_WriteToSysLog("%s: Failed to take background sem: %ld\n", __func__, (long)OsStatus); break; } } @@ -174,12 +174,13 @@ void CFE_ES_BackgroundTask(void) int32 CFE_ES_BackgroundInit(void) { int32 status; + int32 OsStatus; - status = OS_BinSemCreate(&CFE_ES_Global.BackgroundTask.WorkSem, CFE_ES_BACKGROUND_SEM_NAME, 0, 0); - if (status != OS_SUCCESS) + OsStatus = OS_BinSemCreate(&CFE_ES_Global.BackgroundTask.WorkSem, CFE_ES_BACKGROUND_SEM_NAME, 0, 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Failed to create background sem: %08lx\n", __func__, (unsigned long)status); - return status; + CFE_ES_WriteToSysLog("%s: Failed to create background sem: %ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* Spawn a task to write the performance data to a file */ diff --git a/modules/es/fsw/src/cfe_es_cds.c b/modules/es/fsw/src/cfe_es_cds.c index bf61381e9..3781f858d 100644 --- a/modules/es/fsw/src/cfe_es_cds.c +++ b/modules/es/fsw/src/cfe_es_cds.c @@ -57,15 +57,16 @@ int32 CFE_ES_CDS_EarlyInit(void) CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; uint32 PlatformSize; size_t MinRequiredSize; + int32 OsStatus; int32 Status; CFE_ES_Global.CDSIsAvailable = false; /* Create CDS general access mutex */ - Status = OS_MutSemCreate(&CDS->GenMutex, CFE_ES_CDS_MUT_REG_NAME, CFE_ES_CDS_MUT_REG_VALUE); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CDS->GenMutex, CFE_ES_CDS_MUT_REG_NAME, CFE_ES_CDS_MUT_REG_VALUE); + if (OsStatus != OS_SUCCESS) { - CFE_ES_SysLogWrite_Unsync("%s: Failed to create mutex with error %d\n", __func__, (int)Status); + CFE_ES_SysLogWrite_Unsync("%s: Failed to create mutex with error %ld\n", __func__, (long)OsStatus); return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -702,21 +703,22 @@ void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_AppId_t T int32 CFE_ES_LockCDS(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - int32 Status; + int32 OsStatus; + CFE_Status_t ReturnCode; - Status = OS_MutSemTake(CDS->GenMutex); + OsStatus = OS_MutSemTake(CDS->GenMutex); /* Convert to CFE return code */ - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { - Status = CFE_SUCCESS; + ReturnCode = CFE_SUCCESS; } else { - Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } - return Status; + return ReturnCode; } /*---------------------------------------------------------------- @@ -730,21 +732,22 @@ int32 CFE_ES_LockCDS(void) int32 CFE_ES_UnlockCDS(void) { CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars; - int32 Status; + int32 OsStatus; + CFE_Status_t ReturnCode; - Status = OS_MutSemGive(CDS->GenMutex); + OsStatus = OS_MutSemGive(CDS->GenMutex); /* Convert to CFE return code */ - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { - Status = CFE_SUCCESS; + ReturnCode = CFE_SUCCESS; } else { - Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + ReturnCode = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } - return Status; + return ReturnCode; } /*---------------------------------------------------------------- diff --git a/modules/es/fsw/src/cfe_es_mempool.c b/modules/es/fsw/src/cfe_es_mempool.c index 1aacb5d26..82707a706 100644 --- a/modules/es/fsw/src/cfe_es_mempool.c +++ b/modules/es/fsw/src/cfe_es_mempool.c @@ -201,6 +201,7 @@ CFE_Status_t CFE_ES_PoolCreate(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_t Size, uint16 NumBlockSizes, const size_t *BlockSizes, bool UseMutex) { + int32 OsStatus; int32 Status; CFE_ResourceId_t PendingID; CFE_ES_MemPoolRecord_t *PoolRecPtr; @@ -311,11 +312,11 @@ CFE_Status_t CFE_ES_PoolCreateEx(CFE_ES_MemHandle_t *PoolID, void *MemPtr, size_ snprintf(MutexName, OS_MAX_API_NAME, "Pool%08lX", CFE_ResourceId_ToInteger(PendingID)); /* create a mutex to protect this memory pool */ - Status = OS_MutSemCreate(&PoolRecPtr->MutexId, MutexName, 0); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&PoolRecPtr->MutexId, MutexName, 0); + if (OsStatus != OS_SUCCESS) { /* log error and rewrite to CFE status code */ - CFE_ES_WriteToSysLog("%s: OSAL error %d while creating mutex\n", __func__, (int)Status); + CFE_ES_WriteToSysLog("%s: OSAL error %ld while creating mutex\n", __func__, (long)OsStatus); Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } @@ -377,7 +378,7 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) CFE_ES_MemPoolRecord_t *PoolRecPtr; osal_id_t MutexId; int32 Status; - int32 MutDeleteStatus; + int32 OsStatus; PoolRecPtr = CFE_ES_LocateMemPoolRecordByID(PoolID); @@ -403,8 +404,8 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) * potential conflict with holding two locks. */ if (OS_ObjectIdDefined(MutexId)) { - MutDeleteStatus = OS_MutSemDelete(MutexId); - if (MutDeleteStatus != OS_SUCCESS) + OsStatus = OS_MutSemDelete(MutexId); + if (OsStatus != OS_SUCCESS) { /* * Report to syslog for informational purposes only. @@ -412,7 +413,7 @@ int32 CFE_ES_PoolDelete(CFE_ES_MemHandle_t PoolID) * The MemPool entry has already been deleted, so this * function should not return an error at this point. */ - CFE_ES_WriteToSysLog("%s: Error %d deleting mutex\n", __func__, (int)MutDeleteStatus); + CFE_ES_WriteToSysLog("%s: Error %ld deleting mutex\n", __func__, (long)OsStatus); } } diff --git a/modules/es/fsw/src/cfe_es_perf.c b/modules/es/fsw/src/cfe_es_perf.c index bb50bd385..5fb305bb2 100644 --- a/modules/es/fsw/src/cfe_es_perf.c +++ b/modules/es/fsw/src/cfe_es_perf.c @@ -281,6 +281,7 @@ int32 CFE_ES_StopPerfDataCmd(const CFE_ES_StopPerfDataCmd_t *data) bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) { CFE_ES_PerfDumpGlobal_t *State = (CFE_ES_PerfDumpGlobal_t *)Arg; + int32 OsStatus; int32 Status; CFE_FS_Header_t FileHdr; size_t BlockSize; @@ -325,13 +326,13 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) { case CFE_ES_PerfDumpState_OPEN_FILE: /* Create the file to dump to */ - Status = OS_OpenCreate(&State->FileDesc, State->DataFileName, - OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status < 0) + OsStatus = OS_OpenCreate(&State->FileDesc, State->DataFileName, + OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { State->FileDesc = OS_OBJECT_ID_UNDEFINED; CFE_EVS_SendEvent(CFE_ES_PERF_LOG_ERR_EID, CFE_EVS_EventType_ERROR, - "Error creating file %s, RC = %d", State->DataFileName, (int)Status); + "Error creating file %s, RC = %ld", State->DataFileName, (long)OsStatus); } State->FileSize = 0; break; @@ -450,12 +451,14 @@ bool CFE_ES_RunPerfLogDump(uint32 ElapsedTime, void *Arg) case CFE_ES_PerfDumpState_WRITE_PERF_METADATA: /* write the performance metadata to the file */ BlockSize = sizeof(CFE_ES_PerfMetaData_t); - Status = OS_write(State->FileDesc, &Perf->MetaData, BlockSize); + OsStatus = OS_write(State->FileDesc, &Perf->MetaData, BlockSize); + Status = (long)OsStatus; /* status type conversion (size) */ break; case CFE_ES_PerfDumpState_WRITE_PERF_ENTRIES: BlockSize = sizeof(CFE_ES_PerfDataEntry_t); - Status = OS_write(State->FileDesc, &Perf->DataBuffer[State->DataPos], BlockSize); + OsStatus = OS_write(State->FileDesc, &Perf->DataBuffer[State->DataPos], BlockSize); + Status = (long)OsStatus; /* status type conversion (size) */ ++State->DataPos; if (State->DataPos >= CFE_PLATFORM_ES_PERF_DATA_BUFFER_SIZE) diff --git a/modules/es/fsw/src/cfe_es_start.c b/modules/es/fsw/src/cfe_es_start.c index 3a72bfbcd..996e40e90 100644 --- a/modules/es/fsw/src/cfe_es_start.c +++ b/modules/es/fsw/src/cfe_es_start.c @@ -75,7 +75,7 @@ CFE_ES_Global_t CFE_ES_Global; *-----------------------------------------------------------------*/ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const char *StartFilePath) { - int32 ReturnCode; + int32 OsStatus; /* * Clear the entire global data structure. @@ -93,12 +93,11 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha ** Create the ES Shared Data Mutex ** This must be done before ANY calls to CFE_ES_WriteToSysLog(), since this uses the mutex */ - ReturnCode = OS_MutSemCreate(&(CFE_ES_Global.SharedDataMutex), "ES_DATA_MUTEX", 0); - if (ReturnCode != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&(CFE_ES_Global.SharedDataMutex), "ES_DATA_MUTEX", 0); + if (OsStatus != OS_SUCCESS) { /* Cannot use SysLog here, since that requires the reset area to be set up */ - OS_printf("ES Startup: Error: ES Shared Data Mutex could not be created. RC=0x%08X\n", - (unsigned int)ReturnCode); + OS_printf("ES Startup: Error: ES Shared Data Mutex could not be created. RC=%ld\n", (long)OsStatus); /* ** Delay to allow the message to be printed @@ -134,11 +133,11 @@ void CFE_ES_Main(uint32 StartType, uint32 StartSubtype, uint32 ModeId, const cha ** Also Create the ES Performance Data Mutex ** This is to separately protect against concurrent writes to the global performance log data */ - ReturnCode = OS_MutSemCreate(&CFE_ES_Global.PerfDataMutex, "ES_PERF_MUTEX", 0); - if (ReturnCode != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_ES_Global.PerfDataMutex, "ES_PERF_MUTEX", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_SysLogWrite_Unsync("%s: Error: ES Performance Data Mutex could not be created. RC=0x%08X\n", __func__, - (unsigned int)ReturnCode); + CFE_ES_SysLogWrite_Unsync("%s: Error: ES Performance Data Mutex could not be created. RC=%ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read @@ -477,6 +476,7 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo *-----------------------------------------------------------------*/ void CFE_ES_InitializeFileSystems(uint32 StartType) { + int32 OsStatus; int32 RetStatus; cpuaddr RamDiskMemoryAddress; uint32 RamDiskMemorySize; @@ -510,12 +510,11 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) */ if (StartType == CFE_PSP_RST_TYPE_POWERON) { - RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, - CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, + CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read @@ -530,20 +529,18 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) } else { - RetStatus = OS_initfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, - CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_initfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, + CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Initializing Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); CFE_ES_WriteToSysLog("%s: Formatting Volatile(RAM) Volume.\n", __func__); - RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, - CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, + CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Creating Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read @@ -561,11 +558,10 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** Now, mount the RAM disk */ - RetStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Mounting Volatile(RAM) Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -589,8 +585,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** See how many blocks are free in the RAM disk */ - RetStatus = OS_FileSysStatVolume(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING, &StatBuf); - if (RetStatus == OS_SUCCESS && StatBuf.total_blocks > 0) + OsStatus = OS_FileSysStatVolume(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING, &StatBuf); + if (OsStatus == OS_SUCCESS && StatBuf.total_blocks > 0) { /* ** Determine if the disk is too full @@ -605,32 +601,32 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) /* ** First, unmount the disk */ - RetStatus = OS_unmount(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if (RetStatus == OS_SUCCESS) + OsStatus = OS_unmount(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); + if (OsStatus == OS_SUCCESS) { /* ** Remove the file system from the OSAL */ - RetStatus = OS_rmfs("/ramdev0"); - if (RetStatus == OS_SUCCESS) + OsStatus = OS_rmfs("/ramdev0"); + if (OsStatus == OS_SUCCESS) { /* ** Next, make a new file system on the disk */ - RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", - CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); - if (RetStatus == OS_SUCCESS) + OsStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", + CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS); + if (OsStatus == OS_SUCCESS) { /* ** Last, remount the disk */ - RetStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if (RetStatus != OS_SUCCESS) + OsStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", - __func__, (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Re-Mounting Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -646,8 +642,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else { - CFE_ES_WriteToSysLog("%s: Error Re-Formating Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Re-Formating Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -663,8 +659,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else /* could not Remove File system */ { - CFE_ES_WriteToSysLog("%s: Error Removing Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Removing Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -679,8 +675,8 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) } else /* could not un-mount disk */ { - CFE_ES_WriteToSysLog("%s: Error Un-Mounting Volatile(RAM) Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Un-Mounting Volatile(RAM) Volume. EC = %ld\n", __func__, + (long)OsStatus); /* ** Delay to allow the message to be read */ @@ -697,8 +693,7 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else /* could not determine free blocks */ { /* Log error message -- note that BlocksFree returns the error code in this case */ - CFE_ES_WriteToSysLog("%s: Error Determining Blocks Free on Volume. EC = 0x%08X\n", __func__, - (unsigned int)RetStatus); + CFE_ES_WriteToSysLog("%s: Error Determining Blocks Free on Volume. EC = %ld\n", __func__, (long)OsStatus); /* ** Delay to allow the message to be read diff --git a/modules/es/fsw/src/cfe_es_syslog.c b/modules/es/fsw/src/cfe_es_syslog.c index 3f57561c5..fd2a7efce 100644 --- a/modules/es/fsw/src/cfe_es_syslog.c +++ b/modules/es/fsw/src/cfe_es_syslog.c @@ -453,6 +453,7 @@ void CFE_ES_SysLog_vsnprintf(char *Buffer, size_t BufferSize, const char *SpecSt int32 CFE_ES_SysLogDump(const char *Filename) { osal_id_t fd; + int32 OsStatus; int32 Status; size_t WritePos; size_t TotalSize; @@ -463,11 +464,11 @@ int32 CFE_ES_SysLogDump(const char *Filename) CFE_FS_Header_t FileHdr; } Buffer; - Status = OS_OpenCreate(&fd, Filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status < 0) + OsStatus = OS_OpenCreate(&fd, Filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { - CFE_EVS_SendEvent(CFE_ES_SYSLOG2_ERR_EID, CFE_EVS_EventType_ERROR, "Error creating file %s, RC = 0x%08X", - Filename, (unsigned int)Status); + CFE_EVS_SendEvent(CFE_ES_SYSLOG2_ERR_EID, CFE_EVS_EventType_ERROR, "Error creating file %s, RC = %ld", Filename, + (long)OsStatus); return CFE_ES_FILE_IO_ERR; } /* end if */ @@ -496,18 +497,21 @@ int32 CFE_ES_SysLogDump(const char *Filename) while (WritePos < Buffer.LogData.BlockSize) { LastReqSize = Buffer.LogData.BlockSize - WritePos; - Status = OS_write(fd, &Buffer.LogData.Data[WritePos], LastReqSize); - if (Status <= 0) + OsStatus = OS_write(fd, &Buffer.LogData.Data[WritePos], LastReqSize); + + /* NOTE: this stops for errors or EOF code (0) */ + if (OsStatus <= 0) { break; } /* end if */ - WritePos += Status; - TotalSize += Status; + WritePos += (long)OsStatus; + TotalSize += (long)OsStatus; } - if (Status <= 0) + if (OsStatus <= 0) { + Status = (long)OsStatus; break; } diff --git a/modules/es/fsw/src/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c index d4beafa40..72c4f0e94 100644 --- a/modules/es/fsw/src/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -745,7 +745,7 @@ void CFE_ES_TaskPipe(CFE_SB_Buffer_t *SBBufPtr) int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) { OS_heap_prop_t HeapProp; - int32 stat; + int32 OsStatus; uint32 PerfIdx; /* @@ -819,14 +819,14 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) } } - stat = OS_HeapGetInfo(&HeapProp); + OsStatus = OS_HeapGetInfo(&HeapProp); /* * If retrieving info from OSAL was not successful, * zero out the property struct, so all sizes will * in turn be reported in telemetry as 0. */ - if (stat != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { memset(&HeapProp, 0, sizeof(HeapProp)); } @@ -1274,6 +1274,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) uint32 i; uint32 EntryCount = 0; uint32 FileSize = 0; + int32 OsStatus; int32 Result; CFE_ES_AppInfo_t AppInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; @@ -1324,8 +1325,20 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) /* ** Create (or truncate) ES task log data file */ - Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, - OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, + OS_WRITE_ONLY); + + if (OsStatus != OS_SUCCESS) + { + CFE_EVS_SendEvent(CFE_ES_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write App Info file, OS_OpenCreate RC = %ld", (long)OsStatus); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + } + else + { + CFE_EVS_SendEvent(CFE_ES_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write App Info file, CFE_FS_ParseInputFileNameEx RC = %08x", (unsigned int)Result); } if (Result >= 0) @@ -1373,14 +1386,14 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data) /* ** Write the local entry to file */ - Result = OS_write(FileDescriptor, &AppInfo, sizeof(CFE_ES_AppInfo_t)); - if (Result != sizeof(CFE_ES_AppInfo_t)) + OsStatus = OS_write(FileDescriptor, &AppInfo, sizeof(CFE_ES_AppInfo_t)); + if (OsStatus != sizeof(CFE_ES_AppInfo_t)) { OS_close(FileDescriptor); CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKWR_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write App Info file, Task write RC = 0x%08X, exp %d", - (unsigned int)Result, (int)sizeof(CFE_ES_AppInfo_t)); + "Failed to write App Info file, Task write RC = %ld, exp %d", (long)OsStatus, + (int)sizeof(CFE_ES_AppInfo_t)); /* * returning "success" here as there is no other recourse; * the full extent of the error recovery has been done @@ -1425,6 +1438,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) uint32 i; uint32 EntryCount = 0; uint32 FileSize = 0; + int32 OsStatus; int32 Result; CFE_ES_TaskInfo_t TaskInfo; const CFE_ES_FileNameCmd_Payload_t *CmdPtr = &data->Payload; @@ -1466,8 +1480,21 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) /* ** Create (or truncate) ES task log data file */ - Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, - OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, + OS_WRITE_ONLY); + + if (OsStatus != OS_SUCCESS) + { + CFE_EVS_SendEvent(CFE_ES_TASKINFO_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write Task Info file, OS_OpenCreate RC = %ld", (long)OsStatus); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + } + else + { + CFE_EVS_SendEvent(CFE_ES_TASKINFO_OSCREATE_ERR_EID, CFE_EVS_EventType_ERROR, + "Failed to write Task Info file, CFE_FS_ParseInputFileNameEx RC = %08x", + (unsigned int)Result); } if (Result >= 0) @@ -1515,14 +1542,14 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data) /* ** Write the local entry to file */ - Result = OS_write(FileDescriptor, &TaskInfo, sizeof(CFE_ES_TaskInfo_t)); - if (Result != sizeof(CFE_ES_TaskInfo_t)) + OsStatus = OS_write(FileDescriptor, &TaskInfo, sizeof(CFE_ES_TaskInfo_t)); + if (OsStatus != sizeof(CFE_ES_TaskInfo_t)) { OS_close(FileDescriptor); CFE_ES_Global.TaskData.CommandErrorCounter++; CFE_EVS_SendEvent(CFE_ES_TASKINFO_WR_ERR_EID, CFE_EVS_EventType_ERROR, - "Failed to write Task Info file, Task write RC = 0x%08X, exp %d", - (unsigned int)Result, (int)sizeof(CFE_ES_TaskInfo_t)); + "Failed to write Task Info file, Task write RC = %ld, exp %d", (long)OsStatus, + (int)sizeof(CFE_ES_TaskInfo_t)); /* * returning "success" here as there is no other recourse; * the full extent of the error recovery has been done @@ -1981,6 +2008,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) { CFE_FS_Header_t StdFileHeader; osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED; + int32 OsStatus; int32 Status; int16 RegIndex = 0; const CFE_ES_DumpCDSRegistryCmd_Payload_t *CmdPtr = &data->Payload; @@ -2006,13 +2034,14 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) else { /* Create a new dump file, overwriting anything that may have existed previously */ - Status = + OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { CFE_EVS_SendEvent(CFE_ES_CREATING_CDS_DUMP_ERR_EID, CFE_EVS_EventType_ERROR, - "Error creating CDS dump file '%s', Status=0x%08X", DumpFilename, (unsigned int)Status); + "Error creating CDS dump file '%s', Status=%ld", DumpFilename, (long)OsStatus); + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -2029,9 +2058,9 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) if (Status == sizeof(CFE_FS_Header_t)) { - Status = sizeof(CFE_ES_CDSRegDumpRec_t); + OsStatus = sizeof(CFE_ES_CDSRegDumpRec_t); RegRecPtr = CFE_ES_Global.CDSVars.Registry; - while ((RegIndex < CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES) && (Status == sizeof(CFE_ES_CDSRegDumpRec_t))) + while ((RegIndex < CFE_PLATFORM_ES_CDS_MAX_NUM_ENTRIES) && (OsStatus == sizeof(CFE_ES_CDSRegDumpRec_t))) { /* Check to see if the Registry entry is empty */ if (CFE_ES_CDSBlockRecordIsUsed(RegRecPtr)) @@ -2044,9 +2073,9 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) strncpy(DumpRecord.Name, RegRecPtr->Name, sizeof(DumpRecord.Name) - 1); /* Output Registry Dump Record to Registry Dump File */ - Status = OS_write(FileDescriptor, &DumpRecord, sizeof(CFE_ES_CDSRegDumpRec_t)); + OsStatus = OS_write(FileDescriptor, &DumpRecord, sizeof(CFE_ES_CDSRegDumpRec_t)); - FileSize += Status; + FileSize += (long)OsStatus; NumEntries++; } @@ -2055,7 +2084,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) ++RegRecPtr; } - if (Status == sizeof(CFE_ES_CDSRegDumpRec_t)) + if (OsStatus == sizeof(CFE_ES_CDSRegDumpRec_t)) { CFE_EVS_SendEvent(CFE_ES_CDS_REG_DUMP_INF_EID, CFE_EVS_EventType_DEBUG, "Successfully dumped CDS Registry to '%s':Size=%d,Entries=%d", DumpFilename, @@ -2067,8 +2096,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistryCmd_t *data) else { CFE_EVS_SendEvent(CFE_ES_CDS_DUMP_ERR_EID, CFE_EVS_EventType_ERROR, - "Error writing CDS Registry to '%s', Status=0x%08X", DumpFilename, - (unsigned int)Status); + "Error writing CDS Registry to '%s', Status=%ld", DumpFilename, (long)OsStatus); /* Increment Command Error Counter */ CFE_ES_Global.TaskData.CommandErrorCounter++; diff --git a/modules/es/ut-coverage/es_UT.c b/modules/es/ut-coverage/es_UT.c index ca7156b5c..c0c2de32a 100644 --- a/modules/es/ut-coverage/es_UT.c +++ b/modules/es/ut-coverage/es_UT.c @@ -2238,7 +2238,7 @@ void TestTask(void) /* Test task init with background init fail */ ES_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_BinSemCreate), 1, -7); - UtAssert_INT32_EQ(CFE_ES_TaskInit(), -7); + UtAssert_INT32_EQ(CFE_ES_TaskInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Set the log mode to OVERWRITE; CFE_ES_TaskInit() sets SystemLogMode to * DISCARD, which can result in a log overflow depending on the value that @@ -4280,7 +4280,7 @@ void TestCDS() /* Test CDS initialization with size not obtainable */ ES_ResetUnitTest(); UT_SetDefaultReturnValue(UT_KEY(CFE_PSP_GetCDSSize), -1); - UtAssert_INT32_EQ(CFE_ES_CDS_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_ES_CDS_EarlyInit(), -1); /* Reset back to a sufficient CDS size */ UT_SetCDSSize(128 * 1024); diff --git a/modules/evs/fsw/src/cfe_evs_log.c b/modules/evs/fsw/src/cfe_evs_log.c index e1004577e..22ff3e484 100644 --- a/modules/evs/fsw/src/cfe_evs_log.c +++ b/modules/evs/fsw/src/cfe_evs_log.c @@ -130,6 +130,7 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) const CFE_EVS_LogFileCmd_Payload_t *CmdPtr = &data->Payload; int32 Result; int32 LogIndex; + int32 OsStatus; int32 BytesWritten; osal_id_t LogFileHandle = OS_OBJECT_ID_UNDEFINED; uint32 i; @@ -152,12 +153,14 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) else { /* Create the log file */ - Result = OS_OpenCreate(&LogFileHandle, LogFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Result != OS_SUCCESS) + OsStatus = + OS_OpenCreate(&LogFileHandle, LogFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRLOGFILE_EID, CFE_EVS_EventType_ERROR, - "Write Log File Command Error: OS_OpenCreate = 0x%08X, filename = %s", (unsigned int)Result, + "Write Log File Command Error: OS_OpenCreate = %ld, filename = %s", (long)OsStatus, LogFilename); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -192,10 +195,10 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) /* Write all the "in-use" event log entries to the file */ for (i = 0; i < CFE_EVS_Global.EVS_LogPtr->LogCount; i++) { - BytesWritten = OS_write(LogFileHandle, &CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex], - sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])); + OsStatus = OS_write(LogFileHandle, &CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex], + sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])); - if (BytesWritten == sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])) + if (OsStatus == sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])) { LogIndex++; @@ -223,8 +226,8 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) else { EVS_SendEvent(CFE_EVS_ERR_WRLOGFILE_EID, CFE_EVS_EventType_ERROR, - "Write Log File Command Error: OS_write = 0x%08X, filename = %s", - (unsigned int)BytesWritten, LogFilename); + "Write Log File Command Error: OS_write = %ld, filename = %s", (long)OsStatus, + LogFilename); } } diff --git a/modules/evs/fsw/src/cfe_evs_task.c b/modules/evs/fsw/src/cfe_evs_task.c index 5ebd5eef1..562b7f282 100644 --- a/modules/evs/fsw/src/cfe_evs_task.c +++ b/modules/evs/fsw/src/cfe_evs_task.c @@ -62,7 +62,7 @@ bool CFE_EVS_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); *-----------------------------------------------------------------*/ int32 CFE_EVS_EarlyInit(void) { - + int32 OsStatus; int32 Status; uint32 resetAreaSize = 0; cpuaddr resetAreaAddr; @@ -112,16 +112,17 @@ int32 CFE_EVS_EarlyInit(void) 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); + OsStatus = OS_MutSemCreate(&CFE_EVS_Global.EVS_SharedDataMutexID, "CFE_EVS_DataMutex", 0); - if (Status != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, RC=0x%08x\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: OS_MutSemCreate failed, RC=%ld\n", __func__, (long)OsStatus); /* Delay to allow message to be read */ OS_TaskDelay(CFE_EVS_PANIC_DELAY); CFE_PSP_Panic(CFE_PSP_PANIC_STARTUP_SEM); + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } else { @@ -1549,6 +1550,7 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFileCmd_t *data) { int32 Result; osal_id_t FileHandle = OS_OBJECT_ID_UNDEFINED; + int32 OsStatus; int32 BytesWritten; uint32 EntryCount = 0; uint32 i; @@ -1574,13 +1576,14 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFileCmd_t *data) else { /* Create Application Data File */ - Result = OS_OpenCreate(&FileHandle, LocalName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileHandle, LocalName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Result != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRDATFILE_EID, CFE_EVS_EventType_ERROR, - "Write App Data Command Error: OS_OpenCreate = 0x%08X, filename = %s", (unsigned int)Result, + "Write App Data Command Error: OS_OpenCreate = %ld, filename = %s", (long)OsStatus, LocalName); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } @@ -1617,17 +1620,17 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFileCmd_t *data) CFE_PLATFORM_EVS_MAX_EVENT_FILTERS * sizeof(EVS_BinFilter_t)); /* Write application data record to file */ - BytesWritten = OS_write(FileHandle, &AppDataFile, sizeof(CFE_EVS_AppDataFile_t)); + OsStatus = OS_write(FileHandle, &AppDataFile, sizeof(CFE_EVS_AppDataFile_t)); - if (BytesWritten == sizeof(CFE_EVS_AppDataFile_t)) + if (OsStatus == sizeof(CFE_EVS_AppDataFile_t)) { EntryCount++; } else { EVS_SendEvent(CFE_EVS_ERR_WRDATFILE_EID, CFE_EVS_EventType_ERROR, - "Write App Data Command Error: OS_write = 0x%08X, filename = %s", - (unsigned int)BytesWritten, LocalName); + "Write App Data Command Error: OS_write = %ld, filename = %s", (long)OsStatus, + LocalName); break; } } diff --git a/modules/evs/ut-coverage/evs_UT.c b/modules/evs/ut-coverage/evs_UT.c index 9bedb5003..570256766 100644 --- a/modules/evs/ut-coverage/evs_UT.c +++ b/modules/evs/ut-coverage/evs_UT.c @@ -44,7 +44,7 @@ static const char *EVS_SYSLOG_MSGS[] = { NULL, "%s: Call to CFE_PSP_GetResetArea failed, RC=0x%08x\n", "%s: Unexpected size from CFE_PSP_GetResetArea: expected = 0x%08lX, actual = 0x%08lX\n", - "%s: OS_MutSemCreate failed, RC=0x%08x\n", + "%s: OS_MutSemCreate failed, RC=%ld\n", "%s: Event Log cleared following power-on reset\n", "%s: Event Log cleared, n=%d, c=%d, f=%d, m=%d, o=%d\n", "%s: Event Log restored, n=%d, c=%d, f=%d, m=%d, o=%d\n", @@ -922,7 +922,7 @@ void Test_Logging(void) UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR); - UtAssert_INT32_EQ(CFE_EVS_WriteLogDataFileCmd(&CmdBuf.logfilecmd), OS_ERROR); + UtAssert_INT32_EQ(CFE_EVS_WriteLogDataFileCmd(&CmdBuf.logfilecmd), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successfully writing all log entries */ UT_InitData(); diff --git a/modules/fs/fsw/src/cfe_fs_api.c b/modules/fs/fsw/src/cfe_fs_api.c index 81615f45c..2e52d8e37 100644 --- a/modules/fs/fsw/src/cfe_fs_api.c +++ b/modules/fs/fsw/src/cfe_fs_api.c @@ -125,6 +125,7 @@ const char *CFE_FS_GetDefaultExtension(CFE_FS_FileCategory_t FileCategory) *-----------------------------------------------------------------*/ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) { + int32 OsStatus; int32 Result; int32 EndianCheck = 0x01020304; @@ -136,14 +137,14 @@ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) /* ** Ensure that we are at the start of the file... */ - Result = OS_lseek(FileDes, 0, OS_SEEK_SET); + OsStatus = OS_lseek(FileDes, 0, OS_SEEK_SET); - if (Result == OS_SUCCESS) + if (OsStatus >= OS_SUCCESS) { /* ** Read header structure into callers buffer... */ - Result = OS_read(FileDes, Hdr, sizeof(CFE_FS_Header_t)); + OsStatus = OS_read(FileDes, Hdr, sizeof(CFE_FS_Header_t)); /* Determine if this processor is a little endian processor */ if ((*(char *)(&EndianCheck)) == 0x04) @@ -154,6 +155,16 @@ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes) } } + if (OsStatus >= OS_SUCCESS) + { + /* The "OsStatus" reflects size actually read */ + Result = (long)OsStatus; + } + else + { + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + return (Result); } @@ -190,6 +201,7 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) { CFE_TIME_SysTime_t Time; + int32 OsStatus; int32 Result; int32 EndianCheck = 0x01020304; CFE_ES_AppId_t AppID; @@ -202,9 +214,9 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) /* ** Ensure that we are at the start of the file... */ - Result = OS_lseek(FileDes, 0, OS_SEEK_SET); + OsStatus = OS_lseek(FileDes, 0, OS_SEEK_SET); - if (Result == OS_SUCCESS) + if (OsStatus >= OS_SUCCESS) { /* ** Fill in the ID fields... @@ -241,7 +253,7 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) /* ** Write header structure from callers buffer... */ - Result = OS_write(FileDes, Hdr, sizeof(CFE_FS_Header_t)); + OsStatus = OS_write(FileDes, Hdr, sizeof(CFE_FS_Header_t)); /* ** Determine if this is a little endian processor @@ -254,6 +266,16 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) } } + if (OsStatus >= OS_SUCCESS) + { + /* The "OsStatus" reflects size actually written */ + Result = (long)OsStatus; + } + else + { + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + return (Result); } @@ -267,6 +289,7 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr) *-----------------------------------------------------------------*/ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimestamp) { + int32 OsStatus; int32 Result; CFE_FS_Header_t TempHdr; int32 EndianCheck = 0x01020304; @@ -274,9 +297,9 @@ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimest int32 FileOffset = 0; FileOffset = ((char *)&TempHdr.TimeSeconds - (char *)&TempHdr.ContentType); - Result = OS_lseek(FileDes, FileOffset, OS_SEEK_SET); + OsStatus = OS_lseek(FileDes, FileOffset, OS_SEEK_SET); - if (Result == FileOffset) + if (OsStatus == FileOffset) { /* ** Determine if this is a little endian processor @@ -289,22 +312,23 @@ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimest CFE_FS_ByteSwapUint32(&OutTimestamp.Subseconds); } - Result = OS_write(FileDes, &OutTimestamp, sizeof(OutTimestamp)); + OsStatus = OS_write(FileDes, &OutTimestamp, sizeof(OutTimestamp)); /* On a good write, the value returned will equal the number of bytes written */ - if (Result == sizeof(OutTimestamp)) + if (OsStatus == sizeof(OutTimestamp)) { Result = CFE_SUCCESS; } else { - CFE_ES_WriteToSysLog("%s: Failed to write timestamp (Status=0x%08X)\n", __func__, (unsigned int)Result); + CFE_ES_WriteToSysLog("%s: Failed to write timestamp (Status=%ld)\n", __func__, (long)OsStatus); Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } } else { - CFE_ES_WriteToSysLog("%s: Failed to lseek time fields (Status=0x%08X)\n", __func__, (unsigned int)Result); + CFE_ES_WriteToSysLog("%s: Failed to lseek time fields (Status=%ld)\n", __func__, (long)OsStatus); + Result = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } return (Result); @@ -674,6 +698,7 @@ bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) CFE_FS_CurrentFileState_t * State; CFE_FS_BackgroundFileDumpEntry_t *Curr; CFE_FS_FileWriteMetaData_t * Meta; + int32 OsStatus; int32 Status; CFE_FS_Header_t FileHdr; void * RecordPtr; @@ -717,11 +742,13 @@ bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) if (!OS_ObjectIdDefined(State->Fd) && Meta->IsPending) { /* First time processing this entry - open the file */ - Status = OS_OpenCreate(&State->Fd, Meta->FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status < 0) + OsStatus = + OS_OpenCreate(&State->Fd, Meta->FileName, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + if (OsStatus != OS_SUCCESS) { State->Fd = OS_OBJECT_ID_UNDEFINED; - Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_CREATE_ERROR, Status, 0, 0, 0); + /* NOTE: This converts the OSAL status directly into a CFE status for logging */ + Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_CREATE_ERROR, (long)OsStatus, 0, 0, 0); } else { @@ -764,17 +791,18 @@ bool CFE_FS_RunBackgroundFileDump(uint32 ElapsedTime, void *Arg) /* * Now write to file */ - Status = OS_write(State->Fd, RecordPtr, RecordSize); + OsStatus = OS_write(State->Fd, RecordPtr, RecordSize); - if (Status != RecordSize) + if (OsStatus != RecordSize) { /* end the file early (cannot set "IsEOF" as this would cause the complete event to be generated too) */ OS_close(State->Fd); State->Fd = OS_OBJECT_ID_UNDEFINED; /* generate write error event */ - Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_RECORD_WRITE_ERROR, Status, State->RecordNum, RecordSize, - State->FileSize); + /* NOTE: This converts the OSAL status directly into a CFE status for logging */ + Meta->OnEvent(Meta, CFE_FS_FileWriteEvent_RECORD_WRITE_ERROR, (long)OsStatus, State->RecordNum, + RecordSize, State->FileSize); break; } else diff --git a/modules/fs/fsw/src/cfe_fs_priv.c b/modules/fs/fsw/src/cfe_fs_priv.c index 37e771112..d3dfe0f35 100644 --- a/modules/fs/fsw/src/cfe_fs_priv.c +++ b/modules/fs/fsw/src/cfe_fs_priv.c @@ -52,18 +52,18 @@ CFE_FS_Global_t CFE_FS_Global; *-----------------------------------------------------------------*/ int32 CFE_FS_EarlyInit(void) { - int32 Stat; + int32 OsStatus; memset(&CFE_FS_Global, 0, sizeof(CFE_FS_Global)); - Stat = OS_MutSemCreate(&CFE_FS_Global.SharedDataMutexId, "CFE_FS_SharedMutex", 0); - if (Stat != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_FS_Global.SharedDataMutexId, "CFE_FS_SharedMutex", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Shared Data Mutex creation failed! RC=0x%08x\n", __func__, (unsigned int)Stat); - return Stat; + CFE_ES_WriteToSysLog("%s: Shared Data Mutex creation failed! RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ - return Stat; + return CFE_SUCCESS; } /*---------------------------------------------------------------- @@ -76,16 +76,15 @@ int32 CFE_FS_EarlyInit(void) *-----------------------------------------------------------------*/ void CFE_FS_LockSharedData(const char *FunctionName) { - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemTake(CFE_FS_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_FS_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); - - CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=0x%x,App=%lu,Function=%s\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=%ld,App=%lu,Function=%s\n", __func__, (long)OsStatus, + CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); } /* end if */ @@ -102,15 +101,15 @@ void CFE_FS_LockSharedData(const char *FunctionName) *-----------------------------------------------------------------*/ void CFE_FS_UnlockSharedData(const char *FunctionName) { - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemGive(CFE_FS_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_FS_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { CFE_ES_GetAppID(&AppId); - CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=0x%x,App=%lu,Function=%s\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=%ld,App=%lu,Function=%s\n", __func__, (long)OsStatus, + CFE_RESOURCEID_TO_ULONG(AppId), FunctionName); } /* end if */ return; diff --git a/modules/fs/ut-coverage/fs_UT.c b/modules/fs/ut-coverage/fs_UT.c index 79affdcf3..5bef77250 100644 --- a/modules/fs/ut-coverage/fs_UT.c +++ b/modules/fs/ut-coverage/fs_UT.c @@ -42,8 +42,8 @@ #include "target_config.h" -const char *FS_SYSLOG_MSGS[] = {NULL, "%s: SharedData Mutex Take Err Stat=0x%x,App=%lu,Function=%s\n", - "%s: SharedData Mutex Give Err Stat=0x%x,App=%lu,Function=%s\n"}; +const char *FS_SYSLOG_MSGS[] = {NULL, "%s: SharedData Mutex Take Err Stat=%ld,App=%lu,Function=%s\n", + "%s: SharedData Mutex Give Err Stat=%ld,App=%lu,Function=%s\n"}; /* counts the number of times UT_FS_OnEvent() was invoked (below) */ uint32 UT_FS_FileWriteEventCount[CFE_FS_FileWriteEvent_MAX]; @@ -117,13 +117,13 @@ void Test_CFE_FS_ReadHeader(void) /* Test reading the header with a lseek failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_lseek), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successfully reading the header */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(OS_read), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_ReadHeader(&Hdr, FileDes), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test calling with NULL pointer argument */ UtAssert_INT32_EQ(CFE_FS_ReadHeader(NULL, FileDes), CFE_FS_BAD_ARGUMENT); @@ -142,13 +142,13 @@ void Test_CFE_FS_WriteHeader(void) /* Test writing the header with a lseek failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_lseek), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successfully writing the header */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_SUCCESS); UT_SetDeferredRetcode(UT_KEY(OS_write), 1, OS_SUCCESS); - UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), OS_SUCCESS); + UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, &Hdr), CFE_SUCCESS); /* Test calling with NULL pointer argument */ UtAssert_INT32_EQ(CFE_FS_WriteHeader(FileDes, NULL), CFE_FS_BAD_ARGUMENT); @@ -167,7 +167,7 @@ void Test_CFE_FS_SetTimestamp(void) /* Test setting the time stamp with a lseek failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_lseek), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_SetTimestamp(FileDes, NewTimestamp), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_SetTimestamp(FileDes, NewTimestamp), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test setting the time stamp with a seconds write failure */ UT_InitData(); @@ -486,7 +486,7 @@ void Test_CFE_FS_Private(void) /* Test FS initialization with a mutex creation failure */ UT_InitData(); UT_SetDefaultReturnValue(UT_KEY(OS_MutSemCreate), OS_ERROR); - UtAssert_INT32_EQ(CFE_FS_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_FS_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test successful locking of shared data */ UT_InitData(); diff --git a/modules/sb/fsw/src/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c index 5ce76600e..f4efa30c3 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -103,6 +103,7 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c CFE_ES_AppId_t AppId; CFE_ES_TaskId_t TskId; osal_id_t SysQueueId; + int32 OsStatus; int32 Status; CFE_SB_PipeD_t * PipeDscPtr; CFE_ResourceId_t PendingPipeId = CFE_RESOURCEID_UNDEFINED; @@ -163,19 +164,19 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c if (Status == CFE_SUCCESS) { /* create the queue */ - Status = OS_QueueCreate(&SysQueueId, PipeName, Depth, sizeof(CFE_SB_BufferD_t *), 0); - if (Status == OS_SUCCESS) + OsStatus = OS_QueueCreate(&SysQueueId, PipeName, Depth, sizeof(CFE_SB_BufferD_t *), 0); + if (OsStatus == OS_SUCCESS) { /* just translate the RC to CFE */ Status = CFE_SUCCESS; } else { - if (Status == OS_ERR_NAME_TAKEN) + if (OsStatus == OS_ERR_NAME_TAKEN) { PendingEventId = CFE_SB_CR_PIPE_NAME_TAKEN_EID; } - else if (Status == OS_ERR_NO_FREE_IDS) + else if (OsStatus == OS_ERR_NO_FREE_IDS) { PendingEventId = CFE_SB_CR_PIPE_NO_FREE_EID; } @@ -266,7 +267,7 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c break; case CFE_SB_CR_PIPE_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, - "CreatePipeErr:OS_QueueCreate returned %d,app %s", (int)Status, + "CreatePipeErr:OS_QueueCreate returned %ld,app %s", (long)OsStatus, CFE_SB_GetAppTskName(TskId, FullName)); break; } @@ -662,6 +663,7 @@ CFE_Status_t CFE_SB_GetPipeOpts(CFE_SB_PipeId_t PipeId, uint8 *OptsPtr) *-----------------------------------------------------------------*/ CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_PipeId_t PipeId) { + int32 OsStatus; int32 Status; CFE_ES_TaskId_t TskId; char FullName[(OS_MAX_API_NAME * 2)]; @@ -699,9 +701,9 @@ CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_P } else { - Status = OS_GetResourceName(SysQueueId, PipeNameBuf, PipeNameSize); + OsStatus = OS_GetResourceName(SysQueueId, PipeNameBuf, PipeNameSize); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } @@ -756,6 +758,7 @@ CFE_Status_t CFE_SB_GetPipeName(char *PipeNameBuf, size_t PipeNameSize, CFE_SB_P *-----------------------------------------------------------------*/ CFE_Status_t CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName) { + int32 OsStatus; int32 Status; CFE_ES_TaskId_t TskId; uint32 Idx; @@ -775,8 +778,8 @@ CFE_Status_t CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *Pipe else { /* Get QueueID from OSAL */ - Status = OS_QueueGetIdByName(&SysQueueId, PipeName); - if (Status == OS_SUCCESS) + OsStatus = OS_QueueGetIdByName(&SysQueueId, PipeName); + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } @@ -1554,7 +1557,7 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ CFE_SB_DestinationD_t *DestPtr; CFE_SB_PipeD_t * PipeDscPtr; CFE_SB_EventBuf_t SBSndErr; - int32 Status; + int32 OsStatus; uint32 i; char FullName[(OS_MAX_API_NAME * 2)]; char PipeName[OS_MAX_API_NAME]; @@ -1623,9 +1626,9 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ ** Write the buffer descriptor to the queue of the pipe. If the write ** failed, log info and increment the pipe's error counter. */ - Status = OS_QueuePut(PipeDscPtr->SysQueueId, &BufDscPtr, sizeof(BufDscPtr), 0); + OsStatus = OS_QueuePut(PipeDscPtr->SysQueueId, &BufDscPtr, sizeof(BufDscPtr), 0); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { /* The queue now holds a ref to the buffer, so increment its ref count. */ CFE_SB_IncrBufUseCnt(BufDscPtr); @@ -1638,7 +1641,7 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ PipeDscPtr->PeakQueueDepth = PipeDscPtr->CurrentQueueDepth; } } - else if (Status == OS_QUEUE_FULL) + else if (OsStatus == OS_QUEUE_FULL) { SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_FULL_ERR_EID; @@ -1649,9 +1652,9 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ else { /* Unexpected error while writing to queue. */ - SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; - SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_WR_ERR_EID; - SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].ErrStat = Status; + SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId; + SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_Q_WR_ERR_EID; + SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].OsStatus = OsStatus; SBSndErr.EvtsToSnd++; CFE_SB_Global.HKTlmMsg.Payload.InternalErrorCounter++; PipeDscPtr->SendErrors++; @@ -1751,10 +1754,9 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ CFE_SB_GetPipeName(PipeName, sizeof(PipeName), SBSndErr.EvtBuf[i].PipeId); CFE_EVS_SendEventWithAppID(CFE_SB_Q_WR_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, - "Pipe Write Err,MsgId 0x%x,pipe %s,sender %s,stat 0x%x", + "Pipe Write Err,MsgId 0x%x,pipe %s,sender %s,stat %ld", (unsigned int)CFE_SB_MsgIdToValue(BufDscPtr->MsgId), PipeName, - CFE_SB_GetAppTskName(TskId, FullName), - (unsigned int)SBSndErr.EvtBuf[i].ErrStat); + CFE_SB_GetAppTskName(TskId, FullName), (long)(SBSndErr.EvtBuf[i].OsStatus)); /* clear the bit so the task may send this event again */ CFE_SB_FinishSendEvent(TskId, CFE_SB_Q_WR_ERR_EID_BIT); @@ -1775,7 +1777,7 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut) { int32 Status; - int32 RcvStatus; + int32 OsStatus; CFE_SB_BufferD_t * BufDscPtr; size_t BufDscSize; CFE_SB_PipeD_t * PipeDscPtr; @@ -1795,7 +1797,7 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe BufDscPtr = NULL; DestPtr = NULL; BufDscSize = 0; - RcvStatus = OS_SUCCESS; + OsStatus = OS_SUCCESS; /* * Check input args and see if any are bad, which require @@ -1880,7 +1882,7 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe if (Status == CFE_SUCCESS) { /* Read the buffer descriptor address from the queue. */ - RcvStatus = OS_QueueGet(SysQueueId, &BufDscPtr, sizeof(BufDscPtr), &BufDscSize, SysTimeout); + OsStatus = OS_QueueGet(SysQueueId, &BufDscPtr, sizeof(BufDscPtr), &BufDscSize, SysTimeout); /* * translate the return value - @@ -1888,16 +1890,16 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe * CFE functions have their own set of RC values should not directly return OSAL codes * The size should always match. If it does not, then generate CFE_SB_Q_RD_ERR_EID. */ - if (RcvStatus == OS_SUCCESS && BufDscPtr != NULL && BufDscSize == sizeof(BufDscPtr)) + if (OsStatus == OS_SUCCESS && BufDscPtr != NULL && BufDscSize == sizeof(BufDscPtr)) { /* Pass through */ } - else if (RcvStatus == OS_QUEUE_EMPTY) + else if (OsStatus == OS_QUEUE_EMPTY) { /* normal if using CFE_SB_POLL */ Status = CFE_SB_NO_MESSAGE; } - else if (RcvStatus == OS_QUEUE_TIMEOUT) + else if (OsStatus == OS_QUEUE_TIMEOUT) { /* normal if using a nonzero timeout */ Status = CFE_SB_TIME_OUT; @@ -1995,8 +1997,8 @@ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t Pipe { case CFE_SB_Q_RD_ERR_EID: CFE_EVS_SendEventWithAppID(CFE_SB_Q_RD_ERR_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, - "Pipe Read Err,pipe %lu,app %s,stat 0x%x", CFE_RESOURCEID_TO_ULONG(PipeId), - CFE_SB_GetAppTskName(TskId, FullName), (unsigned int)RcvStatus); + "Pipe Read Err,pipe %lu,app %s,stat %ld", CFE_RESOURCEID_TO_ULONG(PipeId), + CFE_SB_GetAppTskName(TskId, FullName), (long)OsStatus); break; case CFE_SB_RCV_BAD_ARG_EID: CFE_EVS_SendEventWithAppID(CFE_SB_RCV_BAD_ARG_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId, diff --git a/modules/sb/fsw/src/cfe_sb_init.c b/modules/sb/fsw/src/cfe_sb_init.c index 4d28cdaf7..4cdc016a6 100644 --- a/modules/sb/fsw/src/cfe_sb_init.c +++ b/modules/sb/fsw/src/cfe_sb_init.c @@ -58,17 +58,17 @@ const size_t CFE_SB_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = { *-----------------------------------------------------------------*/ int32 CFE_SB_EarlyInit(void) { - + int32 OsStatus; int32 Stat; /* Clear task global */ memset(&CFE_SB_Global, 0, sizeof(CFE_SB_Global)); - Stat = OS_MutSemCreate(&CFE_SB_Global.SharedDataMutexId, "CFE_SB_DataMutex", 0); - if (Stat != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_SB_Global.SharedDataMutexId, "CFE_SB_DataMutex", 0); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Shared data mutex creation failed! RC=0x%08x\n", __func__, (unsigned int)Stat); - return Stat; + CFE_ES_WriteToSysLog("%s: Shared data mutex creation failed! RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ /* Initialize the state of susbcription reporting */ diff --git a/modules/sb/fsw/src/cfe_sb_priv.c b/modules/sb/fsw/src/cfe_sb_priv.c index 001da7582..b5b0e7c74 100644 --- a/modules/sb/fsw/src/cfe_sb_priv.c +++ b/modules/sb/fsw/src/cfe_sb_priv.c @@ -134,18 +134,15 @@ int32 CFE_SB_CleanUpApp(CFE_ES_AppId_t AppId) *-----------------------------------------------------------------*/ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber) { - - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemTake(CFE_SB_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemTake(CFE_SB_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { - CFE_ES_GetAppID(&AppId); - - CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Take Err Stat=%ld,App=%lu,Func=%s,Line=%d\n", __func__, + (long)OsStatus, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); } /* end if */ @@ -162,18 +159,15 @@ void CFE_SB_LockSharedData(const char *FuncName, int32 LineNumber) *-----------------------------------------------------------------*/ void CFE_SB_UnlockSharedData(const char *FuncName, int32 LineNumber) { - - int32 Status; + int32 OsStatus; CFE_ES_AppId_t AppId; - Status = OS_MutSemGive(CFE_SB_Global.SharedDataMutexId); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemGive(CFE_SB_Global.SharedDataMutexId); + if (OsStatus != OS_SUCCESS) { - CFE_ES_GetAppID(&AppId); - - CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=0x%x,App=%lu,Func=%s,Line=%d\n", __func__, - (unsigned int)Status, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); + CFE_ES_WriteToSysLog("%s: SharedData Mutex Give Err Stat=%ld,App=%lu,Func=%s,Line=%d\n", __func__, + (long)OsStatus, CFE_RESOURCEID_TO_ULONG(AppId), FuncName, (int)LineNumber); } /* end if */ diff --git a/modules/sb/fsw/src/cfe_sb_priv.h b/modules/sb/fsw/src/cfe_sb_priv.h index 876de9e6b..203bd36d7 100644 --- a/modules/sb/fsw/src/cfe_sb_priv.h +++ b/modules/sb/fsw/src/cfe_sb_priv.h @@ -272,7 +272,7 @@ typedef struct typedef struct { uint32 EventId; - int32 ErrStat; + int32 OsStatus; CFE_SB_PipeId_t PipeId; } CFE_SB_SendErrEventBuf_t; diff --git a/modules/sb/ut-coverage/sb_UT.c b/modules/sb/ut-coverage/sb_UT.c index 6e741708a..6877a1d7a 100644 --- a/modules/sb/ut-coverage/sb_UT.c +++ b/modules/sb/ut-coverage/sb_UT.c @@ -1720,7 +1720,7 @@ void Test_SB_EarlyInit(void) void Test_SB_EarlyInit_SemCreateError(void) { UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_ERR_NO_FREE_IDS); - UtAssert_INT32_EQ(CFE_SB_EarlyInit(), OS_ERR_NO_FREE_IDS); + UtAssert_INT32_EQ(CFE_SB_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); } /* end Test_SB_EarlyInit_SemCreateError */ /* diff --git a/modules/tbl/fsw/src/cfe_tbl_internal.c b/modules/tbl/fsw/src/cfe_tbl_internal.c index c1d73ba5d..63b85f3aa 100644 --- a/modules/tbl/fsw/src/cfe_tbl_internal.c +++ b/modules/tbl/fsw/src/cfe_tbl_internal.c @@ -49,6 +49,7 @@ int32 CFE_TBL_EarlyInit(void) { uint16 i; uint32 j; + int32 OsStatus; int32 Status; /* Clear task global */ @@ -89,19 +90,19 @@ int32 CFE_TBL_EarlyInit(void) /* ** Create table registry access mutex */ - Status = OS_MutSemCreate(&CFE_TBL_Global.RegistryMutex, CFE_TBL_MUT_REG_NAME, CFE_TBL_MUT_REG_VALUE); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_TBL_Global.RegistryMutex, CFE_TBL_MUT_REG_NAME, CFE_TBL_MUT_REG_VALUE); + if (OsStatus != OS_SUCCESS) { - return Status; + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ /* ** Create working buffer access mutex */ - Status = OS_MutSemCreate(&CFE_TBL_Global.WorkBufMutex, CFE_TBL_MUT_WORK_NAME, CFE_TBL_MUT_WORK_VALUE); - if (Status != OS_SUCCESS) + OsStatus = OS_MutSemCreate(&CFE_TBL_Global.WorkBufMutex, CFE_TBL_MUT_WORK_NAME, CFE_TBL_MUT_WORK_VALUE); + if (OsStatus != OS_SUCCESS) { - return Status; + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ /* Initialize memory partition and allocate shared table buffers. */ @@ -617,14 +618,19 @@ void CFE_TBL_FormTableName(char *FullTblName, const char *TblName, CFE_ES_AppId_ *-----------------------------------------------------------------*/ int32 CFE_TBL_LockRegistry(void) { + int32 OsStatus; int32 Status; - Status = OS_MutSemTake(CFE_TBL_Global.RegistryMutex); + OsStatus = OS_MutSemTake(CFE_TBL_Global.RegistryMutex); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } + else + { + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } return Status; } @@ -639,14 +645,19 @@ int32 CFE_TBL_LockRegistry(void) *-----------------------------------------------------------------*/ int32 CFE_TBL_UnlockRegistry(void) { + int32 OsStatus; int32 Status; - Status = OS_MutSemGive(CFE_TBL_Global.RegistryMutex); + OsStatus = OS_MutSemGive(CFE_TBL_Global.RegistryMutex); - if (Status == OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { Status = CFE_SUCCESS; } + else + { + Status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } return Status; } @@ -663,6 +674,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, CFE_TBL_Re bool CalledByApp) { int32 Status = CFE_SUCCESS; + int32 OsStatus; int32 i; int32 InactiveBufferIndex; CFE_TBL_Handle_t AccessIterator; @@ -737,13 +749,13 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, CFE_TBL_Re { /* Take Mutex to make sure we are not trying to grab a working buffer that some */ /* other application is also trying to grab. */ - Status = OS_MutSemTake(CFE_TBL_Global.WorkBufMutex); + OsStatus = OS_MutSemTake(CFE_TBL_Global.WorkBufMutex); /* Make note of any errors but continue and hope for the best */ - if (Status != OS_SUCCESS) + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Internal error taking WorkBuf Mutex (Status=0x%08X)\n", __func__, - (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: Internal error taking WorkBuf Mutex (Status=%ld)\n", __func__, + (long)OsStatus); } /* Determine if there are any common buffers available */ @@ -799,6 +811,7 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe const char *Filename) { int32 Status = CFE_SUCCESS; + int32 OsStatus; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; osal_id_t FileDescriptor; @@ -817,12 +830,12 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe } /* Try to open the specified table file */ - Status = OS_OpenCreate(&FileDescriptor, Filename, OS_FILE_FLAG_NONE, OS_READ_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, Filename, OS_FILE_FLAG_NONE, OS_READ_ONLY); - if (Status < 0) + if (OsStatus != OS_SUCCESS) { CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, - "%s: Unable to open file (FileDescriptor=%d)", AppName, (int)Status); + "%s: Unable to open file (Status=%ld)", AppName, (long)OsStatus); return CFE_TBL_ERR_ACCESS; } @@ -871,8 +884,16 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe Status = CFE_TBL_WARN_SHORT_FILE; } - NumBytes = + OsStatus = OS_read(FileDescriptor, ((uint8 *)WorkingBufferPtr->BufferPtr) + TblFileHeader.Offset, TblFileHeader.NumBytes); + if (OsStatus >= OS_SUCCESS) + { + NumBytes = (long)OsStatus; /* status code conversion (size) */ + } + else + { + NumBytes = 0; + } if (NumBytes != TblFileHeader.NumBytes) { @@ -885,7 +906,15 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe } /* Check to see if the file is too large (ie - more data than header claims) */ - NumBytes = OS_read(FileDescriptor, &ExtraByte, 1); + OsStatus = OS_read(FileDescriptor, &ExtraByte, 1); + if (OsStatus >= OS_SUCCESS) + { + NumBytes = (long)OsStatus; /* status code conversion (size) */ + } + else + { + NumBytes = 0; + } /* If successfully read another byte, then file must have too much data */ if (NumBytes == 1) @@ -1058,6 +1087,7 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead CFE_TBL_File_Hdr_t *TblFileHeaderPtr, const char *LoadFilename) { int32 Status; + int32 OsStatus; int32 EndianCheck = 0x01020304; #if (CFE_PLATFORM_TBL_VALID_SCID_COUNT > 0) @@ -1109,14 +1139,14 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead } else { - Status = OS_read(FileDescriptor, TblFileHeaderPtr, sizeof(CFE_TBL_File_Hdr_t)); + OsStatus = OS_read(FileDescriptor, TblFileHeaderPtr, sizeof(CFE_TBL_File_Hdr_t)); /* Verify successful read of cFE Table File Header */ - if (Status != sizeof(CFE_TBL_File_Hdr_t)) + if (OsStatus != sizeof(CFE_TBL_File_Hdr_t)) { CFE_EVS_SendEventWithAppID( CFE_TBL_FILE_TBL_HDR_ERR_EID, CFE_EVS_EventType_ERROR, CFE_TBL_Global.TableTaskAppId, - "Unable to read tbl header for '%s', Status = 0x%08X", LoadFilename, (unsigned int)Status); + "Unable to read tbl header for '%s', Status = %ld", LoadFilename, (long)OsStatus); Status = CFE_TBL_ERR_NO_TBL_HEADER; } diff --git a/modules/tbl/fsw/src/cfe_tbl_task_cmds.c b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c index 0032eef8c..8cf5195d3 100644 --- a/modules/tbl/fsw/src/cfe_tbl_task_cmds.c +++ b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c @@ -48,6 +48,7 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) { int32 Status; + int32 OsStatus; uint32 i; CFE_TBL_DumpControl_t *DumpCtrlPtr; CFE_TIME_SysTime_t DumpTime; @@ -101,10 +102,10 @@ int32 CFE_TBL_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) DumpTime.Seconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSecs; DumpTime.Subseconds = DumpCtrlPtr->DumpBufferPtr->FileCreateTimeSubSecs; - Status = OS_OpenCreate(&FileDescriptor, DumpCtrlPtr->DumpBufferPtr->DataSource, OS_FILE_FLAG_NONE, - OS_READ_WRITE); + OsStatus = OS_OpenCreate(&FileDescriptor, DumpCtrlPtr->DumpBufferPtr->DataSource, OS_FILE_FLAG_NONE, + OS_READ_WRITE); - if (Status >= 0) + if (OsStatus == OS_SUCCESS) { Status = CFE_FS_SetTimestamp(FileDescriptor, DumpTime); @@ -363,6 +364,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) CFE_TBL_File_Hdr_t TblFileHeader; osal_id_t FileDescriptor; int32 Status; + int32 OsStatus; int16 RegIndex; CFE_TBL_RegistryRec_t * RegRecPtr; CFE_TBL_LoadBuff_t * WorkingBufferPtr; @@ -374,9 +376,9 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) sizeof(CmdPtr->LoadFilename)); /* Try to open the specified table file */ - Status = OS_OpenCreate(&FileDescriptor, LoadFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, LoadFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); - if (Status >= 0) + if (OsStatus == OS_SUCCESS) { Status = CFE_TBL_ReadHeaders(FileDescriptor, &StdFileHeader, &TblFileHeader, &LoadFilename[0]); @@ -423,19 +425,19 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) if (Status == CFE_SUCCESS) { /* Copy data from file into working buffer */ - Status = + OsStatus = OS_read(FileDescriptor, ((uint8 *)WorkingBufferPtr->BufferPtr) + TblFileHeader.Offset, TblFileHeader.NumBytes); /* Make sure the appropriate number of bytes were read */ - if (Status == (int32)TblFileHeader.NumBytes) + if ((long)OsStatus == TblFileHeader.NumBytes) { /* Check to ensure the file does not have any extra data at the end */ - Status = OS_read(FileDescriptor, &ExtraByte, 1); + OsStatus = OS_read(FileDescriptor, &ExtraByte, 1); /* If another byte was successfully read, then file contains more data than header * claims */ - if (Status == 1) + if ((long)OsStatus == 1) { CFE_EVS_SendEvent(CFE_TBL_FILE_TOO_BIG_ERR_EID, CFE_EVS_EventType_ERROR, "File '%s' has more data than Tbl Hdr indicates (%d)", @@ -531,8 +533,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) { /* Error opening specified file */ CFE_EVS_SendEvent(CFE_TBL_FILE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, - "Unable to open file '%s' for table load, Status = 0x%08X", LoadFilename, - (unsigned int)Status); + "Unable to open file '%s' for table load, Status = %ld", LoadFilename, (long)OsStatus); } return ReturnCode; @@ -701,24 +702,25 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta CFE_TBL_File_Hdr_t TblFileHeader; osal_id_t FileDescriptor; int32 Status; + int32 OsStatus; int32 EndianCheck = 0x01020304; /* Clear Header of any garbage before copying content */ memset(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t)); /* Check to see if the dump file already exists */ - Status = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY); - if (Status >= 0) + if (OsStatus == OS_SUCCESS) { FileExistedPrev = true; OS_close(FileDescriptor); } /* Create a new dump file, overwriting anything that may have existed previously */ - Status = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + OsStatus = OS_OpenCreate(&FileDescriptor, DumpFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (Status >= OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "Table Dump Image", CFE_FS_SubType_TBL_IMG); @@ -746,16 +748,16 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta } /* Output the Table Image Header to the Dump File */ - Status = OS_write(FileDescriptor, &TblFileHeader, sizeof(CFE_TBL_File_Hdr_t)); + OsStatus = OS_write(FileDescriptor, &TblFileHeader, sizeof(CFE_TBL_File_Hdr_t)); /* Make sure the header was output completely */ - if (Status == sizeof(CFE_TBL_File_Hdr_t)) + if ((long)OsStatus == sizeof(CFE_TBL_File_Hdr_t)) { /* Output the requested data to the dump file */ /* Output the active table image data to the dump file */ - Status = OS_write(FileDescriptor, DumpDataAddr, TblSizeInBytes); + OsStatus = OS_write(FileDescriptor, DumpDataAddr, TblSizeInBytes); - if (Status == TblSizeInBytes) + if ((long)OsStatus == TblSizeInBytes) { if (FileExistedPrev) { @@ -780,15 +782,14 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta else { CFE_EVS_SendEvent(CFE_TBL_WRITE_TBL_IMG_ERR_EID, CFE_EVS_EventType_ERROR, - "Error writing Tbl image to '%s', Status=0x%08X", DumpFilename, - (unsigned int)Status); + "Error writing Tbl image to '%s', Status=%ld", DumpFilename, (long)OsStatus); } } else { CFE_EVS_SendEvent(CFE_TBL_WRITE_TBL_HDR_ERR_EID, CFE_EVS_EventType_ERROR, - "Error writing Tbl image File Header to '%s', Status=0x%08X", DumpFilename, - (unsigned int)Status); + "Error writing Tbl image File Header to '%s', Status=%ld", DumpFilename, + (long)OsStatus); } } else @@ -804,7 +805,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta else { CFE_EVS_SendEvent(CFE_TBL_CREATING_DUMP_FILE_ERR_EID, CFE_EVS_EventType_ERROR, - "Error creating dump file '%s', Status=0x%08X", DumpFilename, (unsigned int)Status); + "Error creating dump file '%s', Status=%ld", DumpFilename, (long)OsStatus); } return ReturnCode; diff --git a/modules/tbl/ut-coverage/tbl_UT.c b/modules/tbl/ut-coverage/tbl_UT.c index de0ebf422..ba5512f19 100644 --- a/modules/tbl/ut-coverage/tbl_UT.c +++ b/modules/tbl/ut-coverage/tbl_UT.c @@ -3151,13 +3151,13 @@ void Test_CFE_TBL_Internal(void) /* EarlyInit - Table Registry Mutex Create Failure */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_EarlyInit response to a work buffer mutex create failure */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 2, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_EarlyInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_EarlyInit response to a memory pool create failure */ @@ -3467,7 +3467,7 @@ void Test_CFE_TBL_Internal(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemTake), 1, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_LockRegistry(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_LockRegistry(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_UnlockRegistry response when an error occurs giving the @@ -3475,7 +3475,7 @@ void Test_CFE_TBL_Internal(void) */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemGive), 1, OS_ERROR); - UtAssert_INT32_EQ(CFE_TBL_UnlockRegistry(), OS_ERROR); + UtAssert_INT32_EQ(CFE_TBL_UnlockRegistry(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CFE_UtAssert_EVENTCOUNT(0); /* Test CFE_TBL_LoadFromFile response to an invalid header length */ diff --git a/modules/time/fsw/src/cfe_time_task.c b/modules/time/fsw/src/cfe_time_task.c index 61d11c01c..87915e3aa 100644 --- a/modules/time/fsw/src/cfe_time_task.c +++ b/modules/time/fsw/src/cfe_time_task.c @@ -133,6 +133,7 @@ void CFE_TIME_TaskMain(void) int32 CFE_TIME_TaskInit(void) { int32 Status; + int32 OsStatus; osal_id_t TimeBaseId; osal_id_t TimerId; @@ -143,20 +144,20 @@ int32 CFE_TIME_TaskInit(void) return Status; } /* end if */ - Status = OS_BinSemCreate(&CFE_TIME_Global.ToneSemaphore, CFE_TIME_SEM_TONE_NAME, CFE_TIME_SEM_VALUE, - CFE_TIME_SEM_OPTIONS); - if (Status != OS_SUCCESS) + OsStatus = OS_BinSemCreate(&CFE_TIME_Global.ToneSemaphore, CFE_TIME_SEM_TONE_NAME, CFE_TIME_SEM_VALUE, + CFE_TIME_SEM_OPTIONS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error creating tone semaphore:RC=0x%08X\n", __func__, (unsigned int)Status); - return Status; + CFE_ES_WriteToSysLog("%s: Error creating tone semaphore:RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ - Status = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, CFE_TIME_SEM_1HZ_NAME, CFE_TIME_SEM_VALUE, - CFE_TIME_SEM_OPTIONS); - if (Status != OS_SUCCESS) + OsStatus = OS_BinSemCreate(&CFE_TIME_Global.LocalSemaphore, CFE_TIME_SEM_1HZ_NAME, CFE_TIME_SEM_VALUE, + CFE_TIME_SEM_OPTIONS); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: Error creating local semaphore:RC=0x%08X\n", __func__, (unsigned int)Status); - return Status; + CFE_ES_WriteToSysLog("%s: Error creating local semaphore:RC=%ld\n", __func__, (long)OsStatus); + return CFE_STATUS_EXTERNAL_RESOURCE_FAIL; } /* end if */ Status = CFE_ES_CreateChildTask(&CFE_TIME_Global.ToneTaskID, CFE_TIME_TASK_TONE_NAME, CFE_TIME_Tone1HzTask, @@ -288,22 +289,22 @@ int32 CFE_TIME_TaskInit(void) * way any error here means the PSP must use the "old way" and call * the 1hz function directly. */ - Status = OS_TimeBaseGetIdByName(&TimeBaseId, "cFS-Master"); - if (Status == OS_SUCCESS) + OsStatus = OS_TimeBaseGetIdByName(&TimeBaseId, "cFS-Master"); + if (OsStatus == OS_SUCCESS) { /* Create the 1Hz callback */ - Status = OS_TimerAdd(&TimerId, "cFS-1Hz", TimeBaseId, CFE_TIME_Local1HzTimerCallback, NULL); - if (Status == OS_SUCCESS) + OsStatus = OS_TimerAdd(&TimerId, "cFS-1Hz", TimeBaseId, CFE_TIME_Local1HzTimerCallback, NULL); + if (OsStatus == OS_SUCCESS) { - Status = OS_TimerSet(TimerId, 500000, 1000000); - if (Status != OS_SUCCESS) + OsStatus = OS_TimerSet(TimerId, 500000, 1000000); + if (OsStatus != OS_SUCCESS) { - CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerSet failed:RC=0x%08X\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerSet failed:RC=%ld\n", __func__, (long)OsStatus); } } else { - CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerAdd failed:RC=0x%08X\n", __func__, (unsigned int)Status); + CFE_ES_WriteToSysLog("%s: 1Hz OS_TimerAdd failed:RC=%ld\n", __func__, (long)OsStatus); } } diff --git a/modules/time/fsw/src/cfe_time_tone.c b/modules/time/fsw/src/cfe_time_tone.c index 56e471942..22d8f0fac 100644 --- a/modules/time/fsw/src/cfe_time_tone.c +++ b/modules/time/fsw/src/cfe_time_tone.c @@ -1103,7 +1103,7 @@ void CFE_TIME_Tone1HzISR(void) *-----------------------------------------------------------------*/ void CFE_TIME_Tone1HzTask(void) { - int32 Result; + int32 OsStatus; while (true) { @@ -1113,8 +1113,8 @@ void CFE_TIME_Tone1HzTask(void) /* ** Pend on semaphore given by tone ISR (above)... */ - Result = OS_BinSemTake(CFE_TIME_Global.ToneSemaphore); - if (Result != OS_SUCCESS) + OsStatus = OS_BinSemTake(CFE_TIME_Global.ToneSemaphore); + if (OsStatus != OS_SUCCESS) { break; } @@ -1301,7 +1301,7 @@ void CFE_TIME_Local1HzISR(void) *-----------------------------------------------------------------*/ void CFE_TIME_Local1HzTask(void) { - int32 Result; + int32 OsStatus; while (true) { @@ -1312,8 +1312,8 @@ void CFE_TIME_Local1HzTask(void) /* ** Pend on the 1HZ semaphore (given by local 1Hz ISR)... */ - Result = OS_BinSemTake(CFE_TIME_Global.LocalSemaphore); - if (Result != OS_SUCCESS) + OsStatus = OS_BinSemTake(CFE_TIME_Global.LocalSemaphore); + if (OsStatus != OS_SUCCESS) { break; } diff --git a/modules/time/ut-coverage/time_UT.c b/modules/time/ut-coverage/time_UT.c index b83de9ec7..4432dd753 100644 --- a/modules/time/ut-coverage/time_UT.c +++ b/modules/time/ut-coverage/time_UT.c @@ -44,8 +44,8 @@ ** External global variables */ const char *TIME_SYSLOG_MSGS[] = {NULL, "%s: Error reading cmd pipe,RC=0x%08X\n", - "%s: Application Init Failed,RC=0x%08X\n", "%s: 1Hz OS_TimerAdd failed:RC=0x%08X\n", - "%s: 1Hz OS_TimerSet failed:RC=0x%08X\n"}; + "%s: Application Init Failed,RC=0x%08X\n", "%s: 1Hz OS_TimerAdd failed:RC=%ld\n", + "%s: 1Hz OS_TimerSet failed:RC=%ld\n"}; static const UT_TaskPipeDispatchId_t UT_TPID_CFE_TIME_SEND_HK = {.MsgId = CFE_SB_MSGID_WRAP_VALUE(CFE_TIME_SEND_HK_MID)}; @@ -343,12 +343,12 @@ void Test_Init(void) /* Test response to failure creating a tone semaphore */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_BinSemCreate), 1, -1); - UtAssert_INT32_EQ(CFE_TIME_TaskInit(), -1); + UtAssert_INT32_EQ(CFE_TIME_TaskInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test response to failure creating a local semaphore */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_BinSemCreate), 2, -2); - UtAssert_INT32_EQ(CFE_TIME_TaskInit(), -2); + UtAssert_INT32_EQ(CFE_TIME_TaskInit(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Test response to an EVS register failure */ UT_InitData();