Skip to content

Commit

Permalink
Fix #1755, separate variable for OSAL status
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jphickey committed Aug 3, 2021
1 parent c4ae5b2 commit 2237335
Show file tree
Hide file tree
Showing 30 changed files with 553 additions and 441 deletions.
19 changes: 10 additions & 9 deletions modules/cfe_assert/src/cfe_assert_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
16 changes: 8 additions & 8 deletions modules/cfe_assert/src/cfe_assert_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
38 changes: 19 additions & 19 deletions modules/core_private/ut-stubs/src/ut_osprintf_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
52 changes: 27 additions & 25 deletions modules/es/fsw/src/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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))
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 */

Expand All @@ -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 */

Expand Down
Loading

0 comments on commit 2237335

Please sign in to comment.