From 847794c67e68c0bcb25d5239140ef2b7d7761915 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 12 May 2022 14:44:22 -0600 Subject: [PATCH 1/4] Fix #2100, Resolve UT uninit var static analysis warnings --- modules/cfe_testcase/src/es_cds_test.c | 4 + modules/cfe_testcase/src/es_info_test.c | 4 + modules/cfe_testcase/src/es_mempool_test.c | 12 +- .../cfe_testcase/src/es_resource_id_test.c | 13 +- modules/cfe_testcase/src/es_task_test.c | 12 +- modules/cfe_testcase/src/fs_header_test.c | 8 +- modules/cfe_testcase/src/fs_util_test.c | 2 + .../cfe_testcase/src/resource_id_misc_test.c | 7 + modules/cfe_testcase/src/sb_pipe_mang_test.c | 12 +- modules/cfe_testcase/src/sb_sendrecv_test.c | 23 +- .../cfe_testcase/src/sb_subscription_test.c | 14 +- .../src/tbl_content_access_test.c | 9 +- .../cfe_testcase/src/tbl_content_mang_test.c | 4 +- .../cfe_testcase/src/tbl_information_test.c | 17 +- .../cfe_testcase/src/tbl_registration_test.c | 6 +- modules/es/ut-coverage/es_UT.c | 27 +- modules/evs/ut-coverage/evs_UT.c | 10 +- modules/msg/ut-coverage/test_msg_pri_not.c | 32 +- modules/sb/ut-coverage/sb_UT.c | 336 +++++++++++------- modules/tbl/ut-coverage/tbl_UT.c | 6 + modules/time/ut-coverage/time_UT.c | 7 +- 21 files changed, 360 insertions(+), 205 deletions(-) diff --git a/modules/cfe_testcase/src/es_cds_test.c b/modules/cfe_testcase/src/es_cds_test.c index f96cda05c..0b72b2b70 100644 --- a/modules/cfe_testcase/src/es_cds_test.c +++ b/modules/cfe_testcase/src/es_cds_test.c @@ -91,6 +91,8 @@ void TestCDSName(void) CFE_ES_CDSHandle_t IdByName; char CDSNameBuf[CFE_MISSION_ES_CDS_MAX_FULL_NAME_LEN]; + memset(CDSNameBuf, 0, sizeof(CDSNameBuf)); + UtPrintf("Testing: CFE_ES_GetCDSBlockIDByName, CFE_ES_GetCDSBlockName"); UtAssert_INT32_EQ(CFE_ES_RegisterCDS(&CDSHandlePtr, BlockSize, Name), CFE_ES_CDS_ALREADY_EXISTS); @@ -119,6 +121,8 @@ void TestCopyRestoreCDS(void) char Data[BlockSize]; char DataBuff[BlockSize]; + memset(DataBuff, 0, sizeof(DataBuff)); + UtPrintf("Testing: CFE_ES_CopyToCDS, CFE_ES_RestoreFromCDS"); snprintf(Data, BlockSize, "Test Data"); diff --git a/modules/cfe_testcase/src/es_info_test.c b/modules/cfe_testcase/src/es_info_test.c index a5955be89..3c50cb158 100644 --- a/modules/cfe_testcase/src/es_info_test.c +++ b/modules/cfe_testcase/src/es_info_test.c @@ -247,6 +247,10 @@ void TestModuleInfo(void) CFE_ES_AppInfo_t TestAppInfo; const char * LibName = "ASSERT_LIB"; + memset(&ModuleInfo, 0, sizeof(ModuleInfo)); + memset(&LibInfo, 0, sizeof(LibInfo)); + memset(&TestAppInfo, 0, sizeof(TestAppInfo)); + UtPrintf("Testing: CFE_ES_GetModuleInfo"); UtAssert_INT32_EQ(CFE_ES_GetAppID(&TestAppId), CFE_SUCCESS); diff --git a/modules/cfe_testcase/src/es_mempool_test.c b/modules/cfe_testcase/src/es_mempool_test.c index 61af11c2b..a1e7a0f8e 100644 --- a/modules/cfe_testcase/src/es_mempool_test.c +++ b/modules/cfe_testcase/src/es_mempool_test.c @@ -38,7 +38,7 @@ static CFE_FT_PoolMemBlock_t CFE_FT_PoolMemBlock[CFE_PLATFORM_ES_MAX_MEMORY_POOL void TestMemPoolCreate(void) { - CFE_ES_MemHandle_t PoolID; + CFE_ES_MemHandle_t PoolID = CFE_ES_MEMHANDLE_UNDEFINED; UtPrintf("Testing: CFE_ES_PoolCreateNoSem, CFE_ES_PoolCreate, CFE_ES_PoolCreateEx"); @@ -102,7 +102,7 @@ void TestMemPoolCreateMax(void) void TestMemPoolGetBuf(void) { - CFE_ES_MemHandle_t PoolID; + CFE_ES_MemHandle_t PoolID = CFE_ES_MEMHANDLE_UNDEFINED; int8 Pool[1024]; size_t BufferSize = 512; size_t BufferBig = 2048; @@ -127,7 +127,7 @@ void TestMemPoolGetBuf(void) void TestMemPoolBufInfo(void) { - CFE_ES_MemHandle_t PoolID; + CFE_ES_MemHandle_t PoolID = CFE_ES_MEMHANDLE_UNDEFINED; int8 Pool[1024]; size_t Buffer = 512; CFE_ES_MemPoolBuf_t addressp = CFE_ES_MEMPOOLBUF_C(0); @@ -152,7 +152,7 @@ void TestMemPoolBufInfo(void) void TestMemPoolPutBuf(void) { - CFE_ES_MemHandle_t PoolID; + CFE_ES_MemHandle_t PoolID = CFE_ES_MEMHANDLE_UNDEFINED; int8 Pool[1024]; size_t Buffer = 512; CFE_ES_MemPoolBuf_t addressp = CFE_ES_MEMPOOLBUF_C(0); @@ -174,10 +174,12 @@ void TestMemPoolPutBuf(void) void TestMemPoolDelete(void) { - CFE_ES_MemHandle_t PoolID; /* Poo1 1 handle, no mutex */ + CFE_ES_MemHandle_t PoolID = CFE_ES_MEMHANDLE_UNDEFINED; /* Poo1 1 handle, no mutex */ uint8 Buffer[1024]; CFE_ES_MemPoolStats_t Stats; + memset(&Stats, 0, sizeof(Stats)); + UtPrintf("Testing: CFE_ES_PoolDelete, CFE_ES_GetMemPoolStats, CFE_ES_PoolCreateEx"); UtAssert_INT32_EQ(CFE_ES_PoolCreateEx(&PoolID, Buffer, sizeof(Buffer), 0, NULL, CFE_ES_NO_MUTEX), CFE_SUCCESS); diff --git a/modules/cfe_testcase/src/es_resource_id_test.c b/modules/cfe_testcase/src/es_resource_id_test.c index d04fd187b..09065f6b7 100644 --- a/modules/cfe_testcase/src/es_resource_id_test.c +++ b/modules/cfe_testcase/src/es_resource_id_test.c @@ -50,8 +50,9 @@ void TestLibIDToIndex(void) UtPrintf("Testing: CFE_ES_LibID_ToIndex"); const char * LibName = "ASSERT_LIB"; CFE_ES_LibId_t LibId; - uint32 LibIdx; - uint32 idx; + uint32 LibIdx = 0; + uint32 idx = 0; + UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&LibId, LibName), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, &LibIdx), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, &idx), CFE_SUCCESS); @@ -64,10 +65,12 @@ void TestLibIDToIndex(void) void TestTaskIDToIndex(void) { + CFE_ES_TaskId_t TaskId = CFE_ES_TASKID_UNDEFINED; + uint32 TaskIdx = 0; + uint32 idx = 0; + UtPrintf("Testing: CFE_ES_TaskID_ToIndex"); - CFE_ES_TaskId_t TaskId; - uint32 TaskIdx; - uint32 idx; + UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskId), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, &TaskIdx), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, &idx), CFE_SUCCESS); diff --git a/modules/cfe_testcase/src/es_task_test.c b/modules/cfe_testcase/src/es_task_test.c index 45a8ff850..54349aacd 100644 --- a/modules/cfe_testcase/src/es_task_test.c +++ b/modules/cfe_testcase/src/es_task_test.c @@ -96,8 +96,8 @@ void TestCreateChild(void) { UtPrintf("Testing: CFE_ES_CreateChildTask"); - CFE_ES_TaskId_t TaskId; - CFE_ES_TaskId_t TaskId2; + CFE_ES_TaskId_t TaskId = CFE_ES_TASKID_UNDEFINED; + CFE_ES_TaskId_t TaskId2 = CFE_ES_TASKID_UNDEFINED; const char * TaskName = "CHILD_TASK_1"; CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE; size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE; @@ -106,7 +106,7 @@ void TestCreateChild(void) int32 ExpectedCount = 5; int32 RetryCount; char TaskNameBuf[16]; - osal_id_t OtherTaskId; + osal_id_t OtherTaskId = OS_OBJECT_ID_UNDEFINED; OS_task_prop_t task_prop; CFE_FT_Global.Count = 0; @@ -187,7 +187,7 @@ void TestChildTaskName(void) { UtPrintf("Testing: CFE_ES_GetTaskIDByName, CFE_ES_GetTaskName"); - CFE_ES_TaskId_t TaskId; + CFE_ES_TaskId_t TaskId = CFE_ES_TASKID_UNDEFINED; const char TaskName[] = "CHILD_TASK_1"; CFE_ES_TaskId_t TaskIdByName; char TaskNameBuf[OS_MAX_API_NAME + 4]; @@ -196,6 +196,8 @@ void TestChildTaskName(void) CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY; uint32 Flags = 0; + memset(TaskNameBuf, 0, sizeof(TaskNameBuf)); + UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&TaskId, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags), CFE_SUCCESS); @@ -223,7 +225,7 @@ void TestChildTaskDelete(void) { UtPrintf("Testing: CFE_ES_DeleteChildTask"); - CFE_ES_TaskId_t TaskId; + CFE_ES_TaskId_t TaskId = CFE_ES_TASKID_UNDEFINED; const char * TaskName = "CHILD_TASK_1"; CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE; size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE; diff --git a/modules/cfe_testcase/src/fs_header_test.c b/modules/cfe_testcase/src/fs_header_test.c index 0afab2d3f..528b7b358 100644 --- a/modules/cfe_testcase/src/fs_header_test.c +++ b/modules/cfe_testcase/src/fs_header_test.c @@ -34,8 +34,10 @@ char *fsAddrPtr = NULL; static osal_id_t setup_file(void) { - osal_id_t id; + osal_id_t id = OS_OBJECT_ID_UNDEFINED; + UtAssert_INT32_EQ(OS_OpenCreate(&id, OS_TEST_HEADER_FILENAME, OS_FILE_FLAG_CREATE, OS_READ_WRITE), OS_SUCCESS); + return id; } @@ -70,6 +72,8 @@ void TestReadHeader(void) const char * TestDescription = "TEST_HEADER"; osal_id_t fd = setup_file(); + memset(&ReadHeader, 0, sizeof(ReadHeader)); + UtPrintf("Testing: CFE_FS_ReadHeader"); UtAssert_VOIDCALL(CFE_FS_InitHeader(&Header, TestDescription, CFE_FS_SubType_ES_ERLOG)); @@ -96,6 +100,8 @@ void TestTimeStamp(void) CFE_TIME_SysTime_t NewTimestamp = {0xFFFFFFFF, 0xFFFFFFFF}; osal_id_t fd = setup_file(); + memset(&ReadHeader, 0, sizeof(ReadHeader)); + UtPrintf("Testing: CFE_FS_SetTimestamp"); UtAssert_VOIDCALL(CFE_FS_InitHeader(&Header, TestDescription, CFE_FS_SubType_ES_ERLOG)); diff --git a/modules/cfe_testcase/src/fs_util_test.c b/modules/cfe_testcase/src/fs_util_test.c index a227d83c4..fe9ee1089 100644 --- a/modules/cfe_testcase/src/fs_util_test.c +++ b/modules/cfe_testcase/src/fs_util_test.c @@ -116,6 +116,8 @@ void TestFileName(void) char Name[OS_MAX_FILE_NAME]; const char ExpectedName[] = "FileName.test"; + memset(Name, 0, sizeof(Name)); + UtPrintf("Testing: CFE_FS_ExtractFilenameFromPath"); snprintf(Path, sizeof(Path), "/func/FileName.test"); diff --git a/modules/cfe_testcase/src/resource_id_misc_test.c b/modules/cfe_testcase/src/resource_id_misc_test.c index 50fa042ff..dfb6974a4 100644 --- a/modules/cfe_testcase/src/resource_id_misc_test.c +++ b/modules/cfe_testcase/src/resource_id_misc_test.c @@ -111,6 +111,13 @@ void TestGetBaseSerial(void) CFE_ResourceId_t ResourceID; } CDSHandleIdBuf; + memset(&AppIdBuf, 0, sizeof(AppIdBuf)); + memset(&LibIdBuf, 0, sizeof(LibIdBuf)); + memset(&TaskIdBuf, 0, sizeof(TaskIdBuf)); + memset(&CounterIdBuf, 0, sizeof(CounterIdBuf)); + memset(&PoolIdBuf, 0, sizeof(PoolIdBuf)); + memset(&CDSHandleIdBuf, 0, sizeof(CDSHandleIdBuf)); + /* Referenced from cfe_core_resourceid_basevalues.h */ int TASKID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_OS_TASK); int APPID_BASE = CFE_RESOURCEID_MAKE_BASE(OS_OBJECT_TYPE_USER + 1); diff --git a/modules/cfe_testcase/src/sb_pipe_mang_test.c b/modules/cfe_testcase/src/sb_pipe_mang_test.c index 224e5ec6c..431ac8eed 100644 --- a/modules/cfe_testcase/src/sb_pipe_mang_test.c +++ b/modules/cfe_testcase/src/sb_pipe_mang_test.c @@ -31,7 +31,7 @@ void TestPipeCreate(void) { - CFE_SB_PipeId_t PipeId1; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 10; const char PipeName[] = "Test Pipe"; @@ -100,7 +100,7 @@ void TestPipeCreateMax(void) void TestPipeIndex(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 10; const char PipeName[] = "Test Pipe"; uint32 Idx; @@ -119,11 +119,11 @@ void TestPipeIndex(void) void TestPipeOptions(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 10; const char PipeName[] = "Test Pipe"; uint8 Opts = 2; - uint8 OptsBuff; + uint8 OptsBuff = 0; UtPrintf("Testing: CFE_SB_SetPipeOpts, CFE_SB_GetPipeOpts"); @@ -143,11 +143,11 @@ void TestPipeOptions(void) void TestPipeName(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 10; const char PipeName[] = "Test Pipe"; char PipeNameBuf[OS_MAX_API_NAME]; - CFE_SB_PipeId_t PipeIdBuff; + CFE_SB_PipeId_t PipeIdBuff = CFE_SB_INVALID_PIPE; const char InvalidPipeName[] = "Invalid Pipe"; UtPrintf("Testing: CFE_SB_GetPipeName, CFE_SB_GetPipeIdByName"); diff --git a/modules/cfe_testcase/src/sb_sendrecv_test.c b/modules/cfe_testcase/src/sb_sendrecv_test.c index fc03d512f..f89db7a2c 100644 --- a/modules/cfe_testcase/src/sb_sendrecv_test.c +++ b/modules/cfe_testcase/src/sb_sendrecv_test.c @@ -67,8 +67,8 @@ static CFE_FT_TestBigMessage_t CFE_FT_BigMsg; void TestBasicTransmitRecv(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; CFE_FT_TestCmdMessage_t CmdMsg; CFE_FT_TestTlmMessage_t TlmMsg; CFE_SB_MsgId_t MsgId; @@ -77,6 +77,9 @@ void TestBasicTransmitRecv(void) const CFE_FT_TestCmdMessage_t *CmdPtr; const CFE_FT_TestTlmMessage_t *TlmPtr; + memset(&CmdMsg, 0, sizeof(CmdMsg)); + memset(&TlmMsg, 0, sizeof(TlmMsg)); + UtPrintf("Testing: CFE_SB_TransmitMsg"); /* Setup, create a pipe and subscribe (one cmd, one tlm) */ @@ -218,10 +221,10 @@ void TestBasicTransmitRecv(void) */ void TestMsgBroadcast(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; - CFE_SB_PipeId_t PipeId3; - CFE_SB_PipeId_t PipeId4; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId3 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId4 = CFE_SB_INVALID_PIPE; CFE_FT_TestCmdMessage_t CmdMsg; CFE_SB_MsgId_t MsgId; CFE_SB_Buffer_t * MsgBuf1; @@ -230,6 +233,8 @@ void TestMsgBroadcast(void) CFE_SB_Buffer_t * MsgBuf4; const CFE_FT_TestCmdMessage_t *CmdPtr; + memset(&CmdMsg, 0, sizeof(CmdMsg)); + UtPrintf("Testing: MsgLimit enforcement"); /* Setup - subscribe same MsgId to multiple different pipes with different limits */ @@ -373,12 +378,12 @@ void TestMsgBroadcast(void) /* This is a variant of the message transmit API that does not copy */ void TestZeroCopyTransmitRecv(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; CFE_SB_Buffer_t * CmdBuf; CFE_SB_Buffer_t * TlmBuf; CFE_SB_Buffer_t * MsgBuf; - CFE_SB_MsgId_t MsgId; + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; CFE_MSG_SequenceCount_t SeqCmd1; CFE_MSG_SequenceCount_t SeqTlm1; CFE_MSG_SequenceCount_t SeqCmd2; diff --git a/modules/cfe_testcase/src/sb_subscription_test.c b/modules/cfe_testcase/src/sb_subscription_test.c index ab4275e08..491c8d526 100644 --- a/modules/cfe_testcase/src/sb_subscription_test.c +++ b/modules/cfe_testcase/src/sb_subscription_test.c @@ -39,8 +39,8 @@ static const CFE_SB_MsgId_t CFE_FT_TLM_MSGID = CFE_SB_MSGID_WRAP_VALUE(CFE_TEST_ void TestSubscribeUnsubscribe(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; UtPrintf("Testing: CFE_SB_Subscribe, CFE_SB_Unsubscribe"); @@ -91,8 +91,8 @@ void TestSubscribeUnsubscribe(void) void TestSubscribeUnsubscribeLocal(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; UtPrintf("Testing: CFE_SB_SubscribeLocal, CFE_SB_UnsubscribeLocal"); @@ -143,8 +143,8 @@ void TestSubscribeUnsubscribeLocal(void) void TestSubscribeEx(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; /* * NOTE: CFE_SB_SubscribeEx adds a "Quality" parameter for Qos, which is @@ -185,7 +185,7 @@ void TestSBMaxSubscriptions(void) CFE_Status_t Status; uint32 NumSubs; CFE_SB_MsgId_t TestMsgId; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; UtPrintf("Testing: CFE_SB_Subscribe, max routing table limit"); diff --git a/modules/cfe_testcase/src/tbl_content_access_test.c b/modules/cfe_testcase/src/tbl_content_access_test.c index 25008ba60..9492eee49 100644 --- a/modules/cfe_testcase/src/tbl_content_access_test.c +++ b/modules/cfe_testcase/src/tbl_content_access_test.c @@ -40,10 +40,15 @@ void LoadTable(TBL_TEST_Table_t *TestTable, CFE_Status_t ExpectedStatus) void TestGetAddress(void) { - UtPrintf("Testing: CFE_TBL_GetAddress"); void * TblPtr; TBL_TEST_Table_t *TestTblPtr; TBL_TEST_Table_t TestTable = {1, 2}; + + CFE_TBL_Handle_t SharedTblHandle = CFE_TBL_BAD_TABLE_HANDLE; + const char * SharedTblName = "SAMPLE_APP.SampleAppTable"; + + UtPrintf("Testing: CFE_TBL_GetAddress"); + /* Never loaded */ UtAssert_INT32_EQ(CFE_TBL_GetAddress(&TblPtr, CFE_FT_Global.TblHandle), CFE_TBL_ERR_NEVER_LOADED); UtAssert_INT32_EQ(CFE_TBL_GetAddress(&TblPtr, CFE_TBL_BAD_TABLE_HANDLE), CFE_TBL_ERR_INVALID_HANDLE); @@ -64,8 +69,6 @@ void TestGetAddress(void) UtAssert_INT32_EQ(CFE_TBL_GetAddress(&TblPtr, CFE_FT_Global.TblHandle), CFE_TBL_ERR_INVALID_HANDLE); /* Access a shared table */ - CFE_TBL_Handle_t SharedTblHandle; - const char * SharedTblName = "SAMPLE_APP.SampleAppTable"; UtAssert_INT32_EQ(CFE_TBL_Share(&SharedTblHandle, SharedTblName), CFE_SUCCESS); /* Returns CFE_TBL_INFO_UPDATED since it hasn't been touched since it was loaded */ UtAssert_INT32_EQ(CFE_TBL_GetAddress(&TblPtr, SharedTblHandle), CFE_TBL_INFO_UPDATED); diff --git a/modules/cfe_testcase/src/tbl_content_mang_test.c b/modules/cfe_testcase/src/tbl_content_mang_test.c index 3c2d2e422..5609f2f4b 100644 --- a/modules/cfe_testcase/src/tbl_content_mang_test.c +++ b/modules/cfe_testcase/src/tbl_content_mang_test.c @@ -276,8 +276,8 @@ void TblTest_UpdateOffset(CFE_ES_MemOffset_t *TgtVal, CFE_ES_MemOffset_t SetVal) */ void TblTest_GenerateTblFiles(void) { - osal_id_t fh1; - osal_id_t fh2; + osal_id_t fh1 = OS_OBJECT_ID_UNDEFINED; + osal_id_t fh2 = OS_OBJECT_ID_UNDEFINED; uint32 PartialOffset; uint32 PartialSize; union diff --git a/modules/cfe_testcase/src/tbl_information_test.c b/modules/cfe_testcase/src/tbl_information_test.c index 701c72e77..3b0988ac8 100644 --- a/modules/cfe_testcase/src/tbl_information_test.c +++ b/modules/cfe_testcase/src/tbl_information_test.c @@ -44,9 +44,13 @@ void TestGetStatus(void) void TestGetInfo(void) { - UtPrintf("Testing: CFE_TBL_GetInfo"); CFE_TBL_Info_t TblInfo; const char * BadTblName = "BadTable"; + + memset(&TblInfo, 0, sizeof(TblInfo)); + + UtPrintf("Testing: CFE_TBL_GetInfo"); + UtAssert_INT32_EQ(CFE_TBL_GetInfo(&TblInfo, CFE_FT_Global.RegisteredTblName), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_TBL_GetInfo(NULL, CFE_FT_Global.TblName), CFE_TBL_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_TBL_GetInfo(&TblInfo, BadTblName), CFE_TBL_ERR_INVALID_NAME); @@ -71,12 +75,13 @@ void TestGetInfo(void) void TestNotifyByMessage(void) { + CFE_TBL_Handle_t SharedTblHandle = CFE_TBL_BAD_TABLE_HANDLE; + const char * SharedTblName = "SAMPLE_APP.SampleAppTable"; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(CFE_TEST_CMD_MID); + CFE_MSG_FcnCode_t TestCmdCode = 0; + uint32 TestParameter = 0; + UtPrintf("Testing: CFE_TBL_NotifyByMessage"); - CFE_TBL_Handle_t SharedTblHandle; - const char * SharedTblName = "SAMPLE_APP.SampleAppTable"; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(CFE_TEST_CMD_MID); - CFE_MSG_FcnCode_t TestCmdCode = 0; - uint32 TestParameter = 0; UtAssert_INT32_EQ(CFE_TBL_NotifyByMessage(CFE_TBL_BAD_TABLE_HANDLE, TestMsgId, TestCmdCode, TestParameter), CFE_TBL_ERR_INVALID_HANDLE); diff --git a/modules/cfe_testcase/src/tbl_registration_test.c b/modules/cfe_testcase/src/tbl_registration_test.c index 818f63f84..68c3bfd58 100644 --- a/modules/cfe_testcase/src/tbl_registration_test.c +++ b/modules/cfe_testcase/src/tbl_registration_test.c @@ -39,7 +39,7 @@ int32 CallbackFunc(void *TblPtr) void TestTableRegistration(void) { char BadTblName[CFE_TBL_MAX_FULL_NAME_LEN + 2]; - CFE_TBL_Handle_t OtherHandle; + CFE_TBL_Handle_t OtherHandle = CFE_TBL_BAD_TABLE_HANDLE; UtPrintf("Testing: CFE_TBL_Register, CFE_TBL_Unregister"); @@ -105,7 +105,7 @@ void TestTableRegistration(void) void TestTableMaxLimits(void) { - CFE_TBL_Handle_t Handles[CFE_PLATFORM_TBL_MAX_NUM_HANDLES + 1]; + CFE_TBL_Handle_t Handles[CFE_PLATFORM_TBL_MAX_NUM_HANDLES + 2]; char TblName[CFE_TBL_MAX_FULL_NAME_LEN]; uint32 numTblsCreated = 0; /* Track num created to unregister them all */ @@ -230,7 +230,7 @@ void TestTblNonAppContext(void) void TestTableBadContext(void) { uint32 RetryCount; - osal_id_t OtherTaskId; + osal_id_t OtherTaskId = OS_OBJECT_ID_UNDEFINED; OS_task_prop_t TaskProp; /* Create one (good) handle first from this task */ diff --git a/modules/es/ut-coverage/es_UT.c b/modules/es/ut-coverage/es_UT.c index e5c73fcf5..240be009c 100644 --- a/modules/es/ut-coverage/es_UT.c +++ b/modules/es/ut-coverage/es_UT.c @@ -268,7 +268,7 @@ void ES_UT_SetupAppStartParams(CFE_ES_AppStartParams_t *Params, const char *File void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_t AppState, const char *AppName, CFE_ES_AppRecord_t **OutAppRec, CFE_ES_TaskRecord_t **OutTaskRec) { - osal_id_t UtOsalId; + osal_id_t UtOsalId = OS_OBJECT_ID_UNDEFINED; CFE_ResourceId_t UtTaskId; CFE_ResourceId_t UtAppId; CFE_ES_AppRecord_t * LocalAppPtr; @@ -326,7 +326,7 @@ void ES_UT_SetupSingleAppId(CFE_ES_AppType_Enum_t AppType, CFE_ES_AppState_Enum_ */ void ES_UT_SetupChildTaskId(const CFE_ES_AppRecord_t *ParentApp, const char *TaskName, CFE_ES_TaskRecord_t **OutTaskRec) { - osal_id_t UtOsalId; + osal_id_t UtOsalId = OS_OBJECT_ID_UNDEFINED; CFE_ES_TaskId_t UtTaskId; CFE_ES_AppId_t UtAppId; CFE_ES_TaskRecord_t *LocalTaskPtr; @@ -558,6 +558,9 @@ int32 ES_UT_SetupOSCleanupHook(void *UserObj, int32 StubRetcode, uint32 CallCoun */ if (CallCount == 0) { + /* Initialize to avoid static analysis warnings */ + memset(ObjList, 0, sizeof(ObjList)); + OS_TaskCreate(&ObjList[0], NULL, NULL, OSAL_TASK_STACK_ALLOCATE, 0, 0, 0); OS_QueueCreate(&ObjList[1], NULL, 0, 0, 0); OS_MutSemCreate(&ObjList[2], NULL, 0); @@ -1101,7 +1104,7 @@ static void ES_UT_ForEachObjectIncrease(void *UserObj, UT_EntryKey_t FuncKey, co void * callback_arg = UT_Hook_GetArgValueByName(Context, "callback_arg", void *); int * count = (int *)UserObj; int i; - osal_id_t id; + osal_id_t id = OS_OBJECT_ID_UNDEFINED; /* Increasing number of objects per call */ for (i = 0; i < *count; i++) @@ -1117,7 +1120,7 @@ static void ES_UT_ForEachObjectFail(void *UserObj, UT_EntryKey_t FuncKey, const OS_ArgCallback_t callback_ptr = UT_Hook_GetArgValueByName(Context, "callback_ptr", OS_ArgCallback_t); void * callback_arg = UT_Hook_GetArgValueByName(Context, "callback_arg", void *); - osal_id_t id; + osal_id_t id = OS_OBJECT_ID_UNDEFINED; OS_OpenCreate(&id, NULL, 0, 0); UT_SetDeferredRetcode(UT_KEY(OS_close), 1, -1); @@ -2149,12 +2152,12 @@ void TestGenericPool(void) { CFE_ES_GenPoolRecord_t Pool1; CFE_ES_GenPoolRecord_t Pool2; - size_t Offset1; - size_t Offset2; - size_t Offset3; - size_t Offset4; + size_t Offset1 = 0; + size_t Offset2 = 0; + size_t Offset3 = 0; + size_t Offset4 = 0; size_t OffsetEnd; - size_t BlockSize; + size_t BlockSize = 0; CFE_ES_MemOffset_t FreeSize; CFE_ES_MemOffset_t TotalSize; uint16 NumBlocks; @@ -4539,7 +4542,7 @@ void TestGenericCounterAPI(void) char CounterName[OS_MAX_API_NAME + 1]; CFE_ES_CounterId_t CounterId; CFE_ES_CounterId_t CounterId2; - uint32 CounterCount; + uint32 CounterCount = 0; int i; /* Test successfully registering a generic counter */ @@ -5136,8 +5139,8 @@ void TestCDSMempool(void) void TestESMempool(void) { - CFE_ES_MemHandle_t PoolID1; /* Poo1 1 handle, no mutex */ - CFE_ES_MemHandle_t PoolID2; /* Poo1 2 handle, with mutex */ + CFE_ES_MemHandle_t PoolID1 = CFE_ES_MEMHANDLE_UNDEFINED; /* Poo1 1 handle, no mutex */ + CFE_ES_MemHandle_t PoolID2 = CFE_ES_MEMHANDLE_UNDEFINED; /* Poo1 2 handle, with mutex */ uint8 Buffer1[1024]; uint8 Buffer2[1024]; CFE_ES_MemPoolBuf_t addressp1 = CFE_ES_MEMPOOLBUF_C(0); /* Pool 1 buffer address */ diff --git a/modules/evs/ut-coverage/evs_UT.c b/modules/evs/ut-coverage/evs_UT.c index 96a87c521..e4cd2c4ba 100644 --- a/modules/evs/ut-coverage/evs_UT.c +++ b/modules/evs/ut-coverage/evs_UT.c @@ -650,6 +650,8 @@ void Test_Format(void) UT_EVS_MSGInitData_t MsgData; CFE_MSG_Message_t * MsgSend; + memset(&modecmd, 0, sizeof(modecmd)); + /* Get a local ref to the "current" AppData table entry */ EVS_GetCurrentContext(&AppDataPtr, &AppID); @@ -760,6 +762,8 @@ void Test_Ports(void) CFE_EVS_BitMaskCmd_t bitmaskcmd; UT_SoftwareBusSnapshot_Entry_t LocalSnapshotData = {.MsgId = CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_LONG_EVENT_MSG_MID)}; + memset(&bitmaskcmd, 0, sizeof(bitmaskcmd)); + UtPrintf("Begin Test Ports"); CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; @@ -855,7 +859,7 @@ void Test_Logging(void) CFE_EVS_SetLogModeCmd_t modecmd; CFE_EVS_WriteLogDataFileCmd_t logfilecmd; } CmdBuf; - cpuaddr TempAddr; + cpuaddr TempAddr = 0; CFE_ES_ResetData_t *CFE_EVS_ResetDataPtr; UtPrintf("Begin Test Logging"); @@ -1358,6 +1362,8 @@ void Test_EventCmd(void) CFE_EVS_AppNameCmd_t appnamecmd; UT_SoftwareBusSnapshot_Entry_t LocalSnapshotData = {.MsgId = CFE_SB_MSGID_WRAP_VALUE(CFE_EVS_LONG_EVENT_MSG_MID)}; + memset(&bitmaskcmd, 0, sizeof(bitmaskcmd)); + UtPrintf("Begin Test Event Command"); CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; @@ -1683,6 +1689,8 @@ void Test_InvalidCmd(void) { CFE_MSG_CommandHeader_t cmd; + memset(&cmd, 0, sizeof(cmd)); + UtPrintf("Begin Test Invalid Command"); /* Test invalid msg id event */ diff --git a/modules/msg/ut-coverage/test_msg_pri_not.c b/modules/msg/ut-coverage/test_msg_pri_not.c index 9638ac198..35c7555df 100644 --- a/modules/msg/ut-coverage/test_msg_pri_not.c +++ b/modules/msg/ut-coverage/test_msg_pri_not.c @@ -29,14 +29,14 @@ unsigned int Test_MSG_Pri_NotZero(const CFE_MSG_Message_t *MsgPtr) { - unsigned int bits = 0; - CFE_MSG_HeaderVersion_t hdrver; - bool hassec; - CFE_MSG_Type_t type; - CFE_MSG_ApId_t apid; - CFE_MSG_SegmentationFlag_t segflag; - CFE_MSG_SequenceCount_t seqcnt; - CFE_MSG_Size_t size; + unsigned int bits = 0; + CFE_MSG_HeaderVersion_t hdrver = 0; + bool hassec = false; + CFE_MSG_Type_t type = 0; + CFE_MSG_ApId_t apid = 0; + CFE_MSG_SegmentationFlag_t segflag = 0; + CFE_MSG_SequenceCount_t seqcnt = 0; + CFE_MSG_Size_t size = 0; CFE_MSG_GetHeaderVersion(MsgPtr, &hdrver); if (hdrver != 0) @@ -65,14 +65,14 @@ unsigned int Test_MSG_Pri_NotZero(const CFE_MSG_Message_t *MsgPtr) unsigned int Test_MSG_Pri_NotF(const CFE_MSG_Message_t *MsgPtr) { - unsigned int bits = 0; - CFE_MSG_HeaderVersion_t hdrver; - bool hassec; - CFE_MSG_Type_t type; - CFE_MSG_ApId_t apid; - CFE_MSG_SegmentationFlag_t segflag; - CFE_MSG_SequenceCount_t seqcnt; - CFE_MSG_Size_t size; + unsigned int bits = 0; + CFE_MSG_HeaderVersion_t hdrver = 0; + bool hassec = false; + CFE_MSG_Type_t type = 0; + CFE_MSG_ApId_t apid = 0; + CFE_MSG_SegmentationFlag_t segflag = 0; + CFE_MSG_SequenceCount_t seqcnt = 0; + CFE_MSG_Size_t size = 0; CFE_MSG_GetHeaderVersion(MsgPtr, &hdrver); if (hdrver != 0x7) diff --git a/modules/sb/ut-coverage/sb_UT.c b/modules/sb/ut-coverage/sb_UT.c index 670df5dd6..e83f346a1 100644 --- a/modules/sb/ut-coverage/sb_UT.c +++ b/modules/sb/ut-coverage/sb_UT.c @@ -524,6 +524,8 @@ void Test_SB_Cmds_Noop(void) CFE_SB_NoopCmd_t Cmd; } Noop; + memset(&Noop, 0, sizeof(Noop)); + UT_CallTaskPipe(CFE_SB_ProcessCmdPipePkt, &Noop.SBBuf.Msg, sizeof(Noop.Cmd), UT_TPID_CFE_SB_CMD_NOOP_CC); CFE_UtAssert_EVENTCOUNT(1); @@ -546,6 +548,8 @@ void Test_SB_Cmds_RstCtrs(void) CFE_SB_ResetCountersCmd_t Cmd; } ResetCounters; + memset(&ResetCounters, 0, sizeof(ResetCounters)); + UT_CallTaskPipe(CFE_SB_ProcessCmdPipePkt, &ResetCounters.SBBuf.Msg, sizeof(ResetCounters.Cmd), UT_TPID_CFE_SB_CMD_RESET_COUNTERS_CC); @@ -570,9 +574,11 @@ void Test_SB_Cmds_Stats(void) } SendSbStats; CFE_SB_MsgId_t MsgId; CFE_MSG_Size_t Size; - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; - CFE_SB_PipeId_t PipeId3; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId3 = CFE_SB_INVALID_PIPE; + + memset(&SendSbStats, 0, sizeof(SendSbStats)); /* Make the pipe table non-empty so the stats command writes something */ CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId1, 4, "TestPipe1")); @@ -615,7 +621,7 @@ void Test_SB_Cmds_RoutingInfoDef(void) CFE_SB_WriteRoutingInfoCmd_t Cmd; } WriteRoutingInfo; - WriteRoutingInfo.Cmd.Payload.Filename[0] = '\0'; + memset(&WriteRoutingInfo, 0, sizeof(WriteRoutingInfo)); /* Make some routing info by calling CFE_SB_AppInit */ CFE_UtAssert_SETUP(CFE_SB_AppInit()); @@ -654,6 +660,8 @@ void Test_SB_Cmds_RoutingInfoAlreadyPending(void) CFE_SB_WriteRoutingInfoCmd_t Cmd; } WriteRoutingInfo; + memset(&WriteRoutingInfo, 0, sizeof(WriteRoutingInfo)); + UT_SetDefaultReturnValue(UT_KEY(CFE_FS_BackgroundFileDumpIsPending), true); strncpy(WriteRoutingInfo.Cmd.Payload.Filename, "RoutingTstFile", sizeof(WriteRoutingInfo.Cmd.Payload.Filename) - 1); @@ -673,9 +681,9 @@ void Test_SB_Cmds_RoutingInfoAlreadyPending(void) */ void Test_SB_Cmds_RoutingInfoDataGetter(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; - CFE_SB_PipeId_t PipeId3; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId3 = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId0 = SB_UT_TLM_MID1; CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2; CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3; @@ -755,12 +763,12 @@ void Test_SB_Cmds_PipeInfoDef(void) CFE_SB_Buffer_t SBBuf; CFE_SB_WritePipeInfoCmd_t Cmd; } WritePipeInfo; - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; - CFE_SB_PipeId_t PipeId3; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId3 = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 10; - WritePipeInfo.Cmd.Payload.Filename[0] = '\0'; + memset(&WritePipeInfo, 0, sizeof(WritePipeInfo)); /* Create some pipe info */ CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); @@ -800,6 +808,8 @@ void Test_SB_Cmds_PipeInfoAlreadyPending(void) CFE_SB_WritePipeInfoCmd_t Cmd; } WritePipeInfo; + memset(&WritePipeInfo, 0, sizeof(WritePipeInfo)); + UT_SetDefaultReturnValue(UT_KEY(CFE_FS_BackgroundFileDumpIsPending), true); strncpy(WritePipeInfo.Cmd.Payload.Filename, "PipeTstFile", sizeof(WritePipeInfo.Cmd.Payload.Filename) - 1); @@ -819,9 +829,9 @@ void Test_SB_Cmds_PipeInfoAlreadyPending(void) */ void Test_SB_Cmds_PipeInfoDataGetter(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; - CFE_SB_PipeId_t PipeId3; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId3 = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 10; void * LocalBuffer; size_t LocalBufSize; @@ -890,9 +900,9 @@ void Test_SB_Cmds_BackgroundFileWriteEvents(void) */ void Test_SB_Cmds_MapInfoDataGetter(void) { - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; - CFE_SB_PipeId_t PipeId3; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId3 = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId0 = SB_UT_TLM_MID1; CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2; CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3; @@ -944,9 +954,9 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_Buffer_t SBBuf; CFE_SB_WriteMapInfoCmd_t Cmd; } WriteMapInfo; - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; - CFE_SB_PipeId_t PipeId3; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId3 = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId0 = SB_UT_TLM_MID1; CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2; CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3; @@ -955,7 +965,7 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6; uint16 PipeDepth = 10; - WriteMapInfo.Cmd.Payload.Filename[0] = '\0'; + memset(&WriteMapInfo, 0, sizeof(WriteMapInfo)); /* Create some map info */ CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); @@ -1005,6 +1015,8 @@ void Test_SB_Cmds_MapInfoAlreadyPending(void) CFE_SB_WriteMapInfoCmd_t Cmd; } WriteMapInfo; + memset(&WriteMapInfo, 0, sizeof(WriteMapInfo)); + UT_SetDefaultReturnValue(UT_KEY(CFE_FS_BackgroundFileDumpIsPending), true); strncpy(WriteMapInfo.Cmd.Payload.Filename, "MapTstFile", sizeof(WriteMapInfo.Cmd.Payload.Filename) - 1); @@ -1030,10 +1042,12 @@ void Test_SB_Cmds_EnRouteValParam(void) CFE_SB_Buffer_t SBBuf; CFE_SB_EnableRouteCmd_t Cmd; } EnableRoute; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; + memset(&EnableRoute, 0, sizeof(EnableRoute)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "EnRouteTestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); EnableRoute.Cmd.Payload.MsgId = MsgId; @@ -1068,11 +1082,13 @@ void Test_SB_Cmds_EnRouteNonExist(void) CFE_SB_Buffer_t SBBuf; CFE_SB_EnableRouteCmd_t Cmd; } EnableRoute; - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; + memset(&EnableRoute, 0, sizeof(EnableRoute)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "EnRouteTestPipe1")); CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "EnRouteTestPipe2")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId1)); @@ -1104,6 +1120,8 @@ void Test_SB_Cmds_EnRouteInvParam(void) CFE_SB_EnableRouteCmd_t Cmd; } EnableRoute; + memset(&EnableRoute, 0, sizeof(EnableRoute)); + EnableRoute.Cmd.Payload.MsgId = SB_UT_LAST_VALID_MID; EnableRoute.Cmd.Payload.Pipe = SB_UT_PIPEID_3; @@ -1127,6 +1145,8 @@ void Test_SB_Cmds_EnRouteInvParam2(void) CFE_SB_EnableRouteCmd_t Cmd; } EnableRoute; + memset(&EnableRoute, 0, sizeof(EnableRoute)); + EnableRoute.Cmd.Payload.MsgId = CFE_SB_INVALID_MSG_ID; EnableRoute.Cmd.Payload.Pipe = SB_UT_PIPEID_3; @@ -1151,6 +1171,8 @@ void Test_SB_Cmds_EnRouteInvParam3(void) CFE_SB_EnableRouteCmd_t Cmd; } EnableRoute; + memset(&EnableRoute, 0, sizeof(EnableRoute)); + EnableRoute.Cmd.Payload.MsgId = SB_UT_ALTERNATE_INVALID_MID; EnableRoute.Cmd.Payload.Pipe = SB_UT_PIPEID_0; @@ -1173,10 +1195,12 @@ void Test_SB_Cmds_DisRouteValParam(void) CFE_SB_Buffer_t SBBuf; CFE_SB_DisableRouteCmd_t Cmd; } DisableRoute; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; + memset(&DisableRoute, 0, sizeof(DisableRoute)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "DisRouteTestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); DisableRoute.Cmd.Payload.MsgId = MsgId; @@ -1211,10 +1235,13 @@ void Test_SB_Cmds_DisRouteNonExist(void) CFE_SB_Buffer_t SBBuf; CFE_SB_DisableRouteCmd_t Cmd; } DisableRoute; - CFE_SB_PipeId_t PipeId1, PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; + memset(&DisableRoute, 0, sizeof(DisableRoute)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "DisRouteTestPipe1")); CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "DisRouteTestPipe2")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId1)); @@ -1246,6 +1273,8 @@ void Test_SB_Cmds_DisRouteInvParam(void) CFE_SB_DisableRouteCmd_t Cmd; } DisableRoute; + memset(&DisableRoute, 0, sizeof(DisableRoute)); + DisableRoute.Cmd.Payload.MsgId = SB_UT_LAST_VALID_MID; DisableRoute.Cmd.Payload.Pipe = SB_UT_PIPEID_3; @@ -1269,6 +1298,8 @@ void Test_SB_Cmds_DisRouteInvParam2(void) CFE_SB_DisableRouteCmd_t Cmd; } DisableRoute; + memset(&DisableRoute, 0, sizeof(DisableRoute)); + DisableRoute.Cmd.Payload.MsgId = CFE_SB_INVALID_MSG_ID; DisableRoute.Cmd.Payload.Pipe = SB_UT_PIPEID_3; @@ -1293,6 +1324,8 @@ void Test_SB_Cmds_DisRouteInvParam3(void) CFE_SB_DisableRouteCmd_t Cmd; } DisableRoute; + memset(&DisableRoute, 0, sizeof(DisableRoute)); + DisableRoute.Cmd.Payload.MsgId = SB_UT_ALTERNATE_INVALID_MID; DisableRoute.Cmd.Payload.Pipe = SB_UT_PIPEID_0; @@ -1318,6 +1351,8 @@ void Test_SB_Cmds_SendHK(void) CFE_SB_MsgId_t MsgIdCmd; CFE_MSG_Size_t Size; + memset(&Housekeeping, 0, sizeof(Housekeeping)); + /* For HK command processing - set up FIRST */ UT_SetupBasicMsgDispatch(&UT_TPID_CFE_SB_SEND_HK, sizeof(Housekeeping.Cmd), false); @@ -1346,8 +1381,8 @@ void Test_SB_Cmds_SendPrevSubs(void) CFE_SB_Buffer_t SBBuf; CFE_SB_SendPrevSubsCmd_t Cmd; } SendPrevSubs; - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_BARE_TLM_MID3; uint16 MsgLim = 4; uint16 PipeDepth = 50; @@ -1356,6 +1391,8 @@ void Test_SB_Cmds_SendPrevSubs(void) CFE_MSG_Size_t Size; CFE_SB_MsgId_t MsgIdCmd; + memset(&SendPrevSubs, 0, sizeof(SendPrevSubs)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); NumEvts = 2; /* one for each pipe create */ @@ -1475,6 +1512,8 @@ void Test_SB_Cmds_SubRptOn(void) CFE_SB_EnableSubReportingCmd_t Cmd; } EnableSubReporting; + memset(&EnableSubReporting, 0, sizeof(EnableSubReporting)); + UT_CallTaskPipe(CFE_SB_ProcessCmdPipePkt, &EnableSubReporting.SBBuf.Msg, sizeof(EnableSubReporting.Cmd), UT_TPID_CFE_SB_SUB_RPT_CTL_ENABLE_SUB_REPORTING_CC); @@ -1502,6 +1541,8 @@ void Test_SB_Cmds_SubRptOff(void) CFE_SB_DisableSubReportingCmd_t Cmd; } DisableSubReporting; + memset(&DisableSubReporting, 0, sizeof(DisableSubReporting)); + UT_CallTaskPipe(CFE_SB_ProcessCmdPipePkt, &DisableSubReporting.SBBuf.Msg, sizeof(DisableSubReporting.Cmd), UT_TPID_CFE_SB_SUB_RPT_CTL_DISABLE_SUB_REPORTING_CC); @@ -1670,7 +1711,7 @@ void Test_CreatePipe_NullPtr(void) */ void Test_CreatePipe_ValPipeDepth(void) { - CFE_SB_PipeId_t PipeIdReturned[2]; + CFE_SB_PipeId_t PipeIdReturned[2] = {CFE_SB_INVALID_PIPE, CFE_SB_INVALID_PIPE}; CFE_UtAssert_SUCCESS(CFE_SB_CreatePipe(&PipeIdReturned[0], 1, "TestPipeMin")); CFE_UtAssert_SUCCESS(CFE_SB_CreatePipe(&PipeIdReturned[1], OS_QUEUE_MAX_DEPTH, "TestPipeMax")); @@ -1818,7 +1859,7 @@ void Test_DeletePipe_API(void) */ void Test_DeletePipe_NoSubs(void) { - CFE_SB_PipeId_t PipedId; + CFE_SB_PipeId_t PipedId = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 10; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); @@ -1836,7 +1877,7 @@ void Test_DeletePipe_NoSubs(void) */ void Test_DeletePipe_WithSubs(void) { - CFE_SB_PipeId_t PipedId; + CFE_SB_PipeId_t PipedId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId0 = SB_UT_CMD_MID1; CFE_SB_MsgId_t MsgId1 = SB_UT_CMD_MID2; CFE_SB_MsgId_t MsgId2 = SB_UT_CMD_MID3; @@ -1877,7 +1918,7 @@ void Test_DeletePipe_InvalidPipeId(void) */ void Test_DeletePipe_InvalidPipeOwner(void) { - CFE_SB_PipeId_t PipedId; + CFE_SB_PipeId_t PipedId = CFE_SB_INVALID_PIPE; CFE_SB_PipeD_t *PipeDscPtr; CFE_ES_AppId_t RealOwner; uint16 PipeDepth = 10; @@ -1907,7 +1948,7 @@ void Test_DeletePipe_InvalidPipeOwner(void) */ void Test_DeletePipe_WithAppid(void) { - CFE_SB_PipeId_t PipedId; + CFE_SB_PipeId_t PipedId = CFE_SB_INVALID_PIPE; CFE_ES_AppId_t AppId; uint16 PipeDepth = 10; @@ -1952,7 +1993,7 @@ void Test_GetPipeName_API(void) */ void Test_GetPipeName_NullPtr(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; char NameBuf[10]; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, 4, "TestPipe")); @@ -1973,7 +2014,7 @@ void Test_GetPipeName_NullPtr(void) void Test_GetPipeName_InvalidId(void) { char PipeName[OS_MAX_API_NAME]; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, 4, "TestPipe")); @@ -2096,7 +2137,7 @@ void Test_SetPipeOpts_BadID(void) */ void Test_SetPipeOpts_NotOwner(void) { - CFE_SB_PipeId_t PipeID; + CFE_SB_PipeId_t PipeID = CFE_SB_INVALID_PIPE; CFE_SB_PipeD_t *PipeDscPtr; CFE_ES_AppId_t OrigOwner; @@ -2122,7 +2163,7 @@ void Test_SetPipeOpts_NotOwner(void) */ void Test_SetPipeOpts(void) { - CFE_SB_PipeId_t PipeID; + CFE_SB_PipeId_t PipeID = CFE_SB_INVALID_PIPE; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); @@ -2155,7 +2196,7 @@ void Test_GetPipeOpts_BadID(void) */ void Test_GetPipeOpts_BadPtr(void) { - CFE_SB_PipeId_t PipeID; + CFE_SB_PipeId_t PipeID = CFE_SB_INVALID_PIPE; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); @@ -2172,8 +2213,8 @@ void Test_GetPipeOpts_BadPtr(void) */ void Test_GetPipeOpts(void) { - CFE_SB_PipeId_t PipeID; - uint8 Opts = 0; + CFE_SB_PipeId_t PipeID = CFE_SB_INVALID_PIPE; + uint8 Opts = 0; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); @@ -2209,7 +2250,7 @@ void Test_Subscribe_API(void) */ void Test_Subscribe_SubscribeEx(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; CFE_SB_Qos_t Quality = {0, 0}; uint16 PipeDepth = 10; @@ -2249,7 +2290,7 @@ void Test_Subscribe_InvalidPipeId(void) */ void Test_Subscribe_InvalidMsgId(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_ALTERNATE_INVALID_MID; uint16 PipeDepth = 10; @@ -2270,7 +2311,7 @@ void Test_Subscribe_InvalidMsgId(void) */ void Test_Subscribe_MaxMsgLim(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; CFE_SB_Qos_t Quality = {0, 0}; uint16 PipeDepth = 10; @@ -2294,7 +2335,7 @@ void Test_Subscribe_MaxMsgLim(void) */ void Test_Subscribe_DuplicateSubscription(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; uint16 PipeDepth = 10; @@ -2317,7 +2358,7 @@ void Test_Subscribe_DuplicateSubscription(void) */ void Test_Subscribe_LocalSubscription(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 10; uint16 MsgLim = 4; @@ -2390,9 +2431,9 @@ void Test_Subscribe_MaxDestCount(void) */ void Test_Subscribe_MaxMsgIdCount(void) { - CFE_SB_PipeId_t PipeId0; - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId0 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 50; int32 i; @@ -2432,9 +2473,9 @@ void Test_Subscribe_MaxMsgIdCount(void) */ void Test_Subscribe_SendPrevSubs(void) { - CFE_SB_PipeId_t PipeId0; - CFE_SB_PipeId_t PipeId1; - CFE_SB_PipeId_t PipeId2; + CFE_SB_PipeId_t PipeId0 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId0 = SB_UT_TLM_MID1; CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2; CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3; @@ -2497,9 +2538,9 @@ void Test_Subscribe_PipeNonexistent(void) */ void Test_Subscribe_SubscriptionReporting(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; - CFE_SB_Qos_t Quality; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_Qos_t Quality = CFE_SB_DEFAULT_QOS; uint16 PipeDepth = 10; CFE_SB_MsgId_t MsgIdRpt; CFE_MSG_Size_t Size; @@ -2541,7 +2582,7 @@ void Test_Subscribe_SubscriptionReporting(void) */ void Test_Subscribe_InvalidPipeOwner(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_PipeD_t *PipeDscPtr; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 10; @@ -2589,7 +2630,7 @@ void Test_Unsubscribe_API(void) */ void Test_Unsubscribe_Basic(void) { - CFE_SB_PipeId_t TestPipe; + CFE_SB_PipeId_t TestPipe = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_INTERMEDIATE_VALID_MID; uint16 PipeDepth = 50; @@ -2617,7 +2658,7 @@ void Test_Unsubscribe_Basic(void) */ void Test_Unsubscribe_AppId(void) { - CFE_SB_PipeId_t TestPipe; + CFE_SB_PipeId_t TestPipe = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; CFE_ES_AppId_t CallerId; @@ -2642,7 +2683,7 @@ void Test_Unsubscribe_AppId(void) */ void Test_Unsubscribe_Local(void) { - CFE_SB_PipeId_t TestPipe; + CFE_SB_PipeId_t TestPipe = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; @@ -2664,7 +2705,7 @@ void Test_Unsubscribe_Local(void) */ void Test_Unsubscribe_InvalParam(void) { - CFE_SB_PipeId_t TestPipe; + CFE_SB_PipeId_t TestPipe = CFE_SB_INVALID_PIPE; CFE_ES_AppId_t CallerId; CFE_SB_PipeD_t *PipeDscPtr; uint16 PipeDepth = 50; @@ -2709,7 +2750,7 @@ void Test_Unsubscribe_InvalParam(void) */ void Test_Unsubscribe_NoMatch(void) { - CFE_SB_PipeId_t TestPipe; + CFE_SB_PipeId_t TestPipe = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; @@ -2737,7 +2778,7 @@ void Test_Unsubscribe_NoMatch(void) */ void Test_Unsubscribe_InvalidPipe(void) { - CFE_SB_PipeId_t TestPipe; + CFE_SB_PipeId_t TestPipe = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; @@ -2759,8 +2800,8 @@ void Test_Unsubscribe_InvalidPipe(void) */ void Test_Unsubscribe_InvalidPipeOwner(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_PipeD_t *PipeDscPtr; CFE_ES_AppId_t RealOwner; uint16 PipeDepth = 10; @@ -2793,10 +2834,10 @@ void Test_Unsubscribe_InvalidPipeOwner(void) */ void Test_Unsubscribe_FirstDestWithMany(void) { - CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; - CFE_SB_PipeId_t TestPipe1; - CFE_SB_PipeId_t TestPipe2; - CFE_SB_PipeId_t TestPipe3; + CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; + CFE_SB_PipeId_t TestPipe1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t TestPipe2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t TestPipe3 = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 50; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); @@ -2825,10 +2866,10 @@ void Test_Unsubscribe_FirstDestWithMany(void) */ void Test_Unsubscribe_MiddleDestWithMany(void) { - CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; - CFE_SB_PipeId_t TestPipe1; - CFE_SB_PipeId_t TestPipe2; - CFE_SB_PipeId_t TestPipe3; + CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; + CFE_SB_PipeId_t TestPipe1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t TestPipe2 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t TestPipe3 = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 50; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); @@ -2857,9 +2898,9 @@ void Test_Unsubscribe_MiddleDestWithMany(void) */ void Test_Unsubscribe_GetDestPtr(void) { - CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; - CFE_SB_PipeId_t TestPipe1; - CFE_SB_PipeId_t TestPipe2; + CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; + CFE_SB_PipeId_t TestPipe1 = CFE_SB_INVALID_PIPE; + CFE_SB_PipeId_t TestPipe2 = CFE_SB_INVALID_PIPE; uint16 PipeDepth = 50; CFE_SBR_RouteId_t RouteId; @@ -2931,6 +2972,8 @@ void Test_TransmitMsg_NoSubscribers(void) SB_UT_Test_Tlm_t TlmPkt; CFE_MSG_Size_t Size = sizeof(TlmPkt); + memset(&TlmPkt, 0, sizeof(TlmPkt)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -2951,6 +2994,8 @@ void Test_TransmitMsg_MaxMsgSizePlusOne(void) SB_UT_Test_Tlm_t TlmPkt; CFE_MSG_Size_t Size = CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); CFE_SB_Global.HKTlmMsg.Payload.MsgSendErrorCounter = 0; @@ -2969,13 +3014,15 @@ void Test_TransmitMsg_MaxMsgSizePlusOne(void) */ void Test_TransmitMsg_BasicSend(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 2; CFE_MSG_Size_t Size = sizeof(TlmPkt); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); @@ -3006,8 +3053,8 @@ static int32 UT_CheckSetSequenceCount(void *UserObj, int32 StubRetcode, uint32 C */ void Test_TransmitMsg_SequenceCount(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; CFE_MSG_Size_t Size = sizeof(TlmPkt); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; @@ -3015,6 +3062,8 @@ void Test_TransmitMsg_SequenceCount(void) CFE_MSG_SequenceCount_t SeqCnt; CFE_MSG_SequenceCount_t SeqCntExpected; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + /* Set up hook for checking CFE_MSG_SetSequenceCount calls */ UT_SetHookFunction(UT_KEY(CFE_MSG_SetSequenceCount), UT_CheckSetSequenceCount, &SeqCnt); @@ -3087,13 +3136,15 @@ void Test_TransmitMsg_SequenceCount(void) */ void Test_TransmitMsg_QueuePutError(void) { - CFE_SB_PipeId_t PipeId4Error; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId4Error = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 2; CFE_MSG_Size_t Size = sizeof(TlmPkt); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId4Error, PipeDepth, "TestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId4Error)); UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_ERROR); @@ -3116,13 +3167,15 @@ void Test_TransmitMsg_QueuePutError(void) */ void Test_TransmitMsg_PipeFull(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 1; CFE_MSG_Size_t Size = sizeof(TlmPkt); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); @@ -3155,13 +3208,15 @@ void Test_TransmitMsg_PipeFull(void) */ void Test_TransmitMsg_MsgLimitExceeded(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 5; CFE_MSG_Size_t Size = sizeof(TlmPkt); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); /* Set maximum allowed messages on the pipe at one time to 1 */ @@ -3196,12 +3251,14 @@ void Test_TransmitMsg_MsgLimitExceeded(void) */ void Test_TransmitMsg_GetPoolBufErr(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth; CFE_MSG_Size_t Size = sizeof(TlmPkt); + memset(&TlmPkt, 0, sizeof(TlmPkt)); + PipeDepth = 1; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "GetPoolErrPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -3317,9 +3374,9 @@ void Test_TransmitBuffer_IncrementSeqCnt(void) { CFE_SB_Buffer_t * SendPtr = NULL; CFE_SB_Buffer_t * ReceivePtr = NULL; - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; - uint32 PipeDepth = 10; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + uint32 PipeDepth = 10; CFE_MSG_SequenceCount_t SeqCnt; CFE_MSG_Size_t Size = sizeof(SB_UT_Test_Tlm_t); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; @@ -3383,12 +3440,12 @@ void Test_TransmitBuffer_NoIncrement(void) { CFE_SB_Buffer_t * SendPtr = NULL; CFE_SB_Buffer_t * ReceivePtr = NULL; - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; - uint32 PipeDepth = 10; - CFE_MSG_SequenceCount_t SeqCnt = 22; - CFE_MSG_Size_t Size = sizeof(SB_UT_Test_Tlm_t); - CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + uint32 PipeDepth = 10; + CFE_MSG_SequenceCount_t SeqCnt = 22; + CFE_MSG_Size_t Size = sizeof(SB_UT_Test_Tlm_t); + CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; /* Set up hook for checking CFE_MSG_SetSequenceCount calls */ UT_SetHookFunction(UT_KEY(CFE_MSG_SetSequenceCount), UT_CheckSetSequenceCount, &SeqCnt); @@ -3462,8 +3519,8 @@ void Test_ReleaseMessageBuffer(void) */ void Test_TransmitMsg_DisabledDestination(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; CFE_SB_DestinationD_t *DestPtr; int32 PipeDepth; @@ -3471,6 +3528,8 @@ void Test_TransmitMsg_DisabledDestination(void) CFE_MSG_Size_t Size = sizeof(TlmPkt); CFE_SBR_RouteId_t RouteId; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + PipeDepth = 2; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -3499,8 +3558,8 @@ void Test_TransmitMsg_DisabledDestination(void) */ void Test_BroadcastBufferToRoute(void) { - CFE_SB_PipeId_t PipeId; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_BufferD_t SBBufD; int32 PipeDepth; CFE_SBR_RouteId_t RouteId; @@ -3536,10 +3595,12 @@ void Test_TransmitMsgValidate_MaxMsgSizePlusOne(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_MsgId_t MsgIdRtn; SB_UT_Test_Tlm_t TlmPkt; - CFE_MSG_Size_t Size = CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1; - CFE_MSG_Size_t SizeRtn; + CFE_MSG_Size_t Size = CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1; + CFE_MSG_Size_t SizeRtn = 0; CFE_SBR_RouteId_t RouteIdRtn; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -3561,9 +3622,11 @@ void Test_TransmitMsgValidate_NoSubscribers(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_MsgId_t MsgIdRtn; SB_UT_Test_Tlm_t TlmPkt; - CFE_MSG_Size_t Size = sizeof(TlmPkt); - CFE_MSG_Size_t SizeRtn; - CFE_SBR_RouteId_t RouteIdRtn; + CFE_MSG_Size_t Size = sizeof(TlmPkt); + CFE_MSG_Size_t SizeRtn = 0; + CFE_SBR_RouteId_t RouteIdRtn = CFE_SBR_INVALID_ROUTE_ID; + + memset(&TlmPkt, 0, sizeof(TlmPkt)); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); @@ -3590,6 +3653,8 @@ void Test_TransmitMsgValidate_InvalidMsgId(void) CFE_MSG_Size_t SizeRtn; CFE_SBR_RouteId_t RouteIdRtn; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); UtAssert_INT32_EQ(CFE_SB_TransmitMsgValidate(CFE_MSG_PTR(TlmPkt.TelemetryHeader), &MsgIdRtn, &SizeRtn, &RouteIdRtn), @@ -3658,7 +3723,7 @@ void Test_ReceiveBuffer_InvalidPipeId(void) { CFE_SB_Buffer_t *SBBufPtr; CFE_SB_PipeId_t InvalidPipeId = SB_UT_ALTERNATE_INVALID_PIPEID; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_PipeD_t * PipeDscPtr; UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&SBBufPtr, InvalidPipeId, CFE_SB_POLL), CFE_SB_BAD_ARGUMENT); @@ -3701,7 +3766,7 @@ void Test_ReceiveBuffer_InvalidPipeId(void) void Test_ReceiveBuffer_InvalidTimeout(void) { CFE_SB_Buffer_t *SBBufPtr; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint32 PipeDepth = 10; int32 TimeOut = -5; @@ -3725,7 +3790,7 @@ void Test_ReceiveBuffer_InvalidTimeout(void) void Test_ReceiveBuffer_Poll(void) { CFE_SB_Buffer_t *SBBufPtr; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint32 PipeDepth = 10; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvTestPipe")); @@ -3748,7 +3813,7 @@ void Test_ReceiveBuffer_Poll(void) void Test_ReceiveBuffer_Timeout(void) { CFE_SB_Buffer_t *SBBufPtr; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint32 PipeDepth = 10; int32 TimeOut = 200; @@ -3773,7 +3838,7 @@ void Test_ReceiveBuffer_Timeout(void) void Test_ReceiveBuffer_PipeReadError(void) { CFE_SB_Buffer_t *SBBufPtr; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint32 PipeDepth = 10; size_t Data = 1; @@ -3804,14 +3869,16 @@ void Test_ReceiveBuffer_PipeReadError(void) void Test_ReceiveBuffer_PendForever(void) { CFE_SB_Buffer_t *SBBufPtr; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; - CFE_SB_PipeId_t PipeId; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; SB_UT_Test_Tlm_t TlmPkt; uint32 PipeDepth = 10; CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; CFE_MSG_Size_t Size = sizeof(TlmPkt); CFE_SB_PipeD_t * PipeDscPtr; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvTestPipe")); PipeDscPtr = CFE_SB_LocatePipeDescByID(PipeId); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); @@ -3905,7 +3972,7 @@ void Test_CleanupApp_API(void) */ void Test_ReceiveBuffer_InvalidBufferPtr(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; uint32 PipeDepth = 10; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvTestPipe")); @@ -3941,6 +4008,8 @@ void Test_CFE_SB_MsgHdrSize(void) bool hassec; CFE_MSG_Type_t type; + memset(&msg, 0, sizeof(msg)); + /* No secondary */ hassec = false; type = CFE_MSG_Type_Invalid; @@ -4030,6 +4099,16 @@ void Test_CFE_SB_GetUserData(void) uint64 payload; } tlm_uint64; + memset(&msg, 0, sizeof(msg)); + memset(&cmd_uint8, 0, sizeof(cmd_uint8)); + memset(&cmd_uint16, 0, sizeof(cmd_uint16)); + memset(&cmd_uint32, 0, sizeof(cmd_uint32)); + memset(&cmd_uint64, 0, sizeof(cmd_uint64)); + memset(&tlm_uint8, 0, sizeof(tlm_uint8)); + memset(&tlm_uint16, 0, sizeof(tlm_uint16)); + memset(&tlm_uint32, 0, sizeof(tlm_uint32)); + memset(&tlm_uint64, 0, sizeof(tlm_uint64)); + /* No secondary */ hassec = false; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetHasSecondaryHeader), &hassec, sizeof(hassec), false); @@ -4085,6 +4164,8 @@ void Test_CFE_SB_SetGetUserDataLength(void) CFE_MSG_Type_t type = CFE_MSG_Type_Invalid; bool hassec = false; + memset(&msg, 0, sizeof(msg)); + /* Pass through functions */ UT_SetDataBuffer(UT_KEY(CFE_MSG_GetHasSecondaryHeader), &hassec, sizeof(hassec), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &type, sizeof(type), false); @@ -4194,7 +4275,7 @@ void Test_UseCount_Rollover_Prevention(void) */ void Test_OS_MutSem_ErrLogic(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; uint16 PipeDepth = 50; @@ -4317,7 +4398,7 @@ void Test_CFE_SB_Buffers(void) */ void Test_CFE_SB_BadPipeInfo(void) { - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; CFE_SB_PipeD_t *PipeDscPtr; uint16 PipeDepth = 10; CFE_ES_AppId_t AppID; @@ -4356,12 +4437,15 @@ void Test_SB_TransmitMsgPaths_Nominal(void) CFE_MSG_CommandHeader_t Cmd; } Housekeeping; CFE_SB_MsgId_t MsgId; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 2; CFE_MSG_Size_t Size; CFE_MSG_Type_t Type; + memset(&Housekeeping, 0, sizeof(Housekeeping)); + memset(&TlmPkt, 0, sizeof(TlmPkt)); + /* Set up for dispatch FIRST */ UT_SetupBasicMsgDispatch(&UT_TPID_CFE_SB_SEND_HK, sizeof(Housekeeping.Cmd), false); @@ -4457,12 +4541,14 @@ void Test_SB_TransmitMsgPaths_Nominal(void) void Test_SB_TransmitMsgPaths_LimitErr(void) { CFE_SB_MsgId_t MsgId; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 2; CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; CFE_MSG_Size_t Size = sizeof(TlmPkt); + memset(&TlmPkt, 0, sizeof(TlmPkt)); + /* Test inhibiting sending a "message ID limit error" message */ MsgId = SB_UT_TLM_MID; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); @@ -4494,12 +4580,14 @@ void Test_SB_TransmitMsgPaths_LimitErr(void) void Test_SB_TransmitMsgPaths_FullErr(void) { CFE_SB_MsgId_t MsgId; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 2; CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; CFE_MSG_Size_t Size = sizeof(TlmPkt); + memset(&TlmPkt, 0, sizeof(TlmPkt)); + /* Test inhibiting sending a "pipe full" message */ MsgId = SB_UT_TLM_MID; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe")); @@ -4532,12 +4620,14 @@ void Test_SB_TransmitMsgPaths_FullErr(void) void Test_SB_TransmitMsgPaths_WriteErr(void) { CFE_SB_MsgId_t MsgId; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 2; CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; CFE_MSG_Size_t Size = sizeof(TlmPkt); + memset(&TlmPkt, 0, sizeof(TlmPkt)); + /* Test inhibiting sending a "pipe write error" message */ MsgId = SB_UT_TLM_MID; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -4569,7 +4659,7 @@ void Test_SB_TransmitMsgPaths_WriteErr(void) void Test_SB_TransmitMsgPaths_IgnoreOpt(void) { CFE_SB_MsgId_t MsgId; - CFE_SB_PipeId_t PipeId; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; SB_UT_Test_Tlm_t TlmPkt; int32 PipeDepth = 2; CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; @@ -4577,6 +4667,8 @@ void Test_SB_TransmitMsgPaths_IgnoreOpt(void) CFE_SB_PipeD_t * PipeDscPtr; CFE_ES_AppId_t AppId; + memset(&TlmPkt, 0, sizeof(TlmPkt)); + /* Setup Test skipping sending to a pipe when the pipe option is set to ignore */ MsgId = SB_UT_TLM_MID; CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SkipPipe")); @@ -4619,13 +4711,15 @@ void Test_SB_TransmitMsgPaths_IgnoreOpt(void) void Test_ReceiveBuffer_UnsubResubPath(void) { CFE_SB_Buffer_t *SBBufPtr; - CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; - CFE_SB_PipeId_t PipeId; + CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; + CFE_SB_PipeId_t PipeId = CFE_SB_INVALID_PIPE; SB_UT_Test_Tlm_t TlmPkt; uint32 PipeDepth = 10; CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; CFE_MSG_Size_t Size = sizeof(TlmPkt); + memset(&TlmPkt, 0, sizeof(TlmPkt)); + CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvTestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); diff --git a/modules/tbl/ut-coverage/tbl_UT.c b/modules/tbl/ut-coverage/tbl_UT.c index 3166f8721..8ff25305f 100644 --- a/modules/tbl/ut-coverage/tbl_UT.c +++ b/modules/tbl/ut-coverage/tbl_UT.c @@ -2047,6 +2047,8 @@ void Test_CFE_TBL_Load(void) CFE_TBL_RegistryRec_t * RegRecPtr; CFE_TBL_AccessDescriptor_t *AccessDescPtr; + memset(&TestTable1, 0, sizeof(TestTable1)); + UtPrintf("Begin Test Load"); StdFileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; @@ -2529,6 +2531,8 @@ void Test_CFE_TBL_Manage(void) CFE_TBL_AccessDescriptor_t *AccessDescPtr; CFE_TBL_Handle_t AccessIterator; + memset(&TestTable1, 0, sizeof(TestTable1)); + UtPrintf("Begin Test Manage"); /* Test response to attempt to manage a table that doesn't need managing */ @@ -3031,6 +3035,8 @@ void Test_CFE_TBL_TblMod(void) uint8 CDS_Data[sizeof(UT_Table1_t)]; uint32 ExpectedCrc; + memset(&TblInfo1, 0, sizeof(TblInfo1)); + UtPrintf("Begin Test Table Modified"); FileHeader.SpacecraftID = CFE_PLATFORM_TBL_VALID_SCID_1; diff --git a/modules/time/ut-coverage/time_UT.c b/modules/time/ut-coverage/time_UT.c index 1dca60f98..0ea95da1c 100644 --- a/modules/time/ut-coverage/time_UT.c +++ b/modules/time/ut-coverage/time_UT.c @@ -834,6 +834,8 @@ void Test_Print(void) CFE_TIME_SysTime_t time; bool usingDefaultEpoch = true; + memset(&time, 0, sizeof(time)); + UtPrintf("Begin Test Print"); if (CFE_MISSION_TIME_EPOCH_YEAR != 1980 || CFE_MISSION_TIME_EPOCH_DAY != 1 || CFE_MISSION_TIME_EPOCH_HOUR != 0 || @@ -849,9 +851,6 @@ void Test_Print(void) CFE_UtAssert_SYSLOG(TIME_SYSLOG_MSGS[6]); /* Test with zero time value */ - time.Subseconds = 0; - time.Seconds = 0; - CFE_TIME_Print(timeBuf, time); if (usingDefaultEpoch) { @@ -1940,6 +1939,8 @@ void Test_ResetArea(void) { CFE_TIME_Reference_t Reference; + memset(&Reference, 0, sizeof(Reference)); + UtPrintf("Begin Test Reset Area"); /* Test successfully updating the reset area */ From 558b5a419c62568207bcfdcd7e23ffe362c7c12b Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Fri, 13 May 2022 13:49:03 -0600 Subject: [PATCH 2/4] Fix #2101, Resolve fsw uninit var static analysis warnings --- modules/es/fsw/src/cfe_es_api.c | 4 ++-- modules/es/fsw/src/cfe_es_apps.c | 9 ++++---- modules/es/fsw/src/cfe_es_backgroundtask.c | 3 +++ modules/es/fsw/src/cfe_es_start.c | 4 +++- modules/es/fsw/src/cfe_es_syslog.c | 2 +- modules/es/fsw/src/cfe_es_task.c | 25 +++++++++++----------- modules/evs/fsw/src/cfe_evs_utils.c | 3 +++ modules/sb/fsw/src/cfe_sb_task.c | 4 ++-- modules/tbl/fsw/src/cfe_tbl_internal.c | 4 ++-- modules/tbl/fsw/src/cfe_tbl_task_cmds.c | 4 ++-- modules/time/fsw/src/cfe_time_utils.c | 2 ++ 11 files changed, 38 insertions(+), 26 deletions(-) diff --git a/modules/es/fsw/src/cfe_es_api.c b/modules/es/fsw/src/cfe_es_api.c index fc3fe8972..b0b0463e1 100644 --- a/modules/es/fsw/src/cfe_es_api.c +++ b/modules/es/fsw/src/cfe_es_api.c @@ -780,7 +780,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; + osal_id_t OsalId = OS_OBJECT_ID_UNDEFINED; int32 OsStatus; CFE_Status_t Result; @@ -2189,7 +2189,7 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibId, uint32 *Idx) CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx) { osal_id_t OsalID; - osal_index_t OsalIndex; + osal_index_t OsalIndex = OSAL_INDEX_C(0); int32 OsStatus; if (!CFE_RESOURCEID_TEST_DEFINED(TaskID)) diff --git a/modules/es/fsw/src/cfe_es_apps.c b/modules/es/fsw/src/cfe_es_apps.c index 4eb181d2f..1f7bb29ad 100644 --- a/modules/es/fsw/src/cfe_es_apps.c +++ b/modules/es/fsw/src/cfe_es_apps.c @@ -81,7 +81,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath) osal_id_t AppFile = OS_OBJECT_ID_UNDEFINED; int32 Status; int32 OsStatus; - char c; + char c = 0; bool LineTooLong = false; bool FileOpened = false; @@ -401,7 +401,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens) int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleName, const CFE_ES_ModuleLoadParams_t *LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus) { - osal_id_t ModuleId; + osal_id_t ModuleId = OS_OBJECT_ID_UNDEFINED; cpuaddr InitSymbolAddress; int32 ReturnCode; int32 OsStatus; @@ -590,7 +590,7 @@ int32 CFE_ES_StartAppTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_ const CFE_ES_TaskStartParams_t *Params, CFE_ES_AppId_t ParentAppId) { CFE_ES_TaskRecord_t *TaskRecPtr; - osal_id_t OsalTaskId; + osal_id_t OsalTaskId = OS_OBJECT_ID_UNDEFINED; CFE_ES_TaskId_t LocalTaskId; int32 OsStatus; int32 ReturnCode; @@ -1785,6 +1785,8 @@ void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoP OS_module_prop_t ModuleInfo; int32 OsStatus; + memset(&ModuleInfo, 0, sizeof(ModuleInfo)); + OsStatus = OS_ModuleInfo(ModuleId, &ModuleInfo); if (OsStatus == OS_SUCCESS) { @@ -1794,7 +1796,6 @@ void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoP else { AppInfoPtr->AddressesAreValid = false; - memset(&ModuleInfo, 0, sizeof(ModuleInfo)); } /* diff --git a/modules/es/fsw/src/cfe_es_backgroundtask.c b/modules/es/fsw/src/cfe_es_backgroundtask.c index f3e7cab11..9750f0d7b 100644 --- a/modules/es/fsw/src/cfe_es_backgroundtask.c +++ b/modules/es/fsw/src/cfe_es_backgroundtask.c @@ -106,6 +106,9 @@ void CFE_ES_BackgroundTask(void) OS_time_t LastTime; const CFE_ES_BackgroundJobEntry_t *JobPtr; + memset(&LastTime, 0, sizeof(LastTime)); + memset(&CurrTime, 0, sizeof(CurrTime)); + CFE_PSP_GetTime(&LastTime); while (true) diff --git a/modules/es/fsw/src/cfe_es_start.c b/modules/es/fsw/src/cfe_es_start.c index e5ee5cfdb..f90a24893 100644 --- a/modules/es/fsw/src/cfe_es_start.c +++ b/modules/es/fsw/src/cfe_es_start.c @@ -475,11 +475,13 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) { int32 OsStatus; int32 PspStatus; - cpuaddr RamDiskMemoryAddress; + cpuaddr RamDiskMemoryAddress = 0; uint32 RamDiskMemorySize; int32 PercentFree; OS_statvfs_t StatBuf; + memset(&StatBuf, 0, sizeof(StatBuf)); + /* ** Get the memory area for the RAM disk */ diff --git a/modules/es/fsw/src/cfe_es_syslog.c b/modules/es/fsw/src/cfe_es_syslog.c index 4a5865722..7f1f77f45 100644 --- a/modules/es/fsw/src/cfe_es_syslog.c +++ b/modules/es/fsw/src/cfe_es_syslog.c @@ -450,7 +450,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; + osal_id_t fd = OS_OBJECT_ID_UNDEFINED; int32 OsStatus; int32 Status; size_t WritePos; diff --git a/modules/es/fsw/src/cfe_es_task.c b/modules/es/fsw/src/cfe_es_task.c index 2ad971556..447cb22ba 100644 --- a/modules/es/fsw/src/cfe_es_task.c +++ b/modules/es/fsw/src/cfe_es_task.c @@ -679,6 +679,8 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) int32 OsStatus; uint32 PerfIdx; + memset(&HeapProp, 0, sizeof(HeapProp)); + /* ** Get command execution counters, system log entry count & bytes used. */ @@ -750,21 +752,20 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data) } } + /* Fill in heap info if get successful/supported */ 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 (OsStatus != OS_SUCCESS) + if (OsStatus == OS_SUCCESS) { - memset(&HeapProp, 0, sizeof(HeapProp)); + CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree = CFE_ES_MEMOFFSET_C(HeapProp.free_bytes); + CFE_ES_Global.TaskData.HkPacket.Payload.HeapBlocksFree = CFE_ES_MEMOFFSET_C(HeapProp.free_blocks); + CFE_ES_Global.TaskData.HkPacket.Payload.HeapMaxBlockSize = CFE_ES_MEMOFFSET_C(HeapProp.largest_free_block); + } + else + { + CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree = 0; + CFE_ES_Global.TaskData.HkPacket.Payload.HeapBlocksFree = 0; + CFE_ES_Global.TaskData.HkPacket.Payload.HeapMaxBlockSize = 0; } - - CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree = CFE_ES_MEMOFFSET_C(HeapProp.free_bytes); - CFE_ES_Global.TaskData.HkPacket.Payload.HeapBlocksFree = CFE_ES_MEMOFFSET_C(HeapProp.free_blocks); - CFE_ES_Global.TaskData.HkPacket.Payload.HeapMaxBlockSize = CFE_ES_MEMOFFSET_C(HeapProp.largest_free_block); /* ** Send housekeeping telemetry packet. diff --git a/modules/evs/fsw/src/cfe_evs_utils.c b/modules/evs/fsw/src/cfe_evs_utils.c index ba5d5b075..fb8e9de43 100644 --- a/modules/evs/fsw/src/cfe_evs_utils.c +++ b/modules/evs/fsw/src/cfe_evs_utils.c @@ -358,6 +358,9 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1 CFE_EVS_ShortEventTlm_t ShortEventTlm; /* The "short" flavor is only generated if selected */ int ExpandedLength; + memset(&LongEventTlm, 0, sizeof(LongEventTlm)); + memset(&ShortEventTlm, 0, sizeof(ShortEventTlm)); + /* Initialize EVS event packets */ CFE_MSG_Init(CFE_MSG_PTR(LongEventTlm.TelemetryHeader), CFE_SB_ValueToMsgId(CFE_EVS_LONG_EVENT_MSG_MID), sizeof(LongEventTlm)); diff --git a/modules/sb/fsw/src/cfe_sb_task.c b/modules/sb/fsw/src/cfe_sb_task.c index 13498d6a8..d62f3ad51 100644 --- a/modules/sb/fsw/src/cfe_sb_task.c +++ b/modules/sb/fsw/src/cfe_sb_task.c @@ -857,9 +857,9 @@ void CFE_SB_CollectRouteInfo(CFE_SBR_RouteId_t RouteId, void *ArgPtr) int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality) { CFE_SB_SingleSubscriptionTlm_t SubRptMsg; - int32 Status; + int32 Status = CFE_SUCCESS; - Status = CFE_SUCCESS; + memset(&SubRptMsg, 0, sizeof(SubRptMsg)); if (CFE_SB_Global.SubscriptionReporting == CFE_SB_ENABLE) { diff --git a/modules/tbl/fsw/src/cfe_tbl_internal.c b/modules/tbl/fsw/src/cfe_tbl_internal.c index 95493cc72..318aa4594 100644 --- a/modules/tbl/fsw/src/cfe_tbl_internal.c +++ b/modules/tbl/fsw/src/cfe_tbl_internal.c @@ -812,8 +812,8 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe int32 OsStatus; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; - osal_id_t FileDescriptor; - size_t FilenameLen = strlen(Filename); + osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED; + size_t FilenameLen = strlen(Filename); uint32 NumBytes; uint8 ExtraByte; diff --git a/modules/tbl/fsw/src/cfe_tbl_task_cmds.c b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c index 87220ceea..634930d2e 100644 --- a/modules/tbl/fsw/src/cfe_tbl_task_cmds.c +++ b/modules/tbl/fsw/src/cfe_tbl_task_cmds.c @@ -360,7 +360,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data) const CFE_TBL_LoadCmd_Payload_t *CmdPtr = &data->Payload; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; - osal_id_t FileDescriptor; + osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED; int32 Status; int32 OsStatus; int16 RegIndex; @@ -698,7 +698,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta bool FileExistedPrev = false; CFE_FS_Header_t StdFileHeader; CFE_TBL_File_Hdr_t TblFileHeader; - osal_id_t FileDescriptor; + osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED; int32 Status; int32 OsStatus; int32 EndianCheck = 0x01020304; diff --git a/modules/time/fsw/src/cfe_time_utils.c b/modules/time/fsw/src/cfe_time_utils.c index 0b113164e..756675484 100644 --- a/modules/time/fsw/src/cfe_time_utils.c +++ b/modules/time/fsw/src/cfe_time_utils.c @@ -86,6 +86,8 @@ CFE_TIME_SysTime_t CFE_TIME_LatchClock(void) CFE_TIME_SysTime_t LatchTime; OS_time_t LocalTime; + memset(&LocalTime, 0, sizeof(LocalTime)); + /* ** Get time in O/S format (seconds : microseconds)... */ From 8557be787a071d8c0d33dfc8fd9d7afc82c8e45f Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Mon, 16 May 2022 11:16:11 -0600 Subject: [PATCH 3/4] Fix #2102, Resolve UT non-distinct identifier warnings --- modules/cfe_testcase/src/es_info_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/cfe_testcase/src/es_info_test.c b/modules/cfe_testcase/src/es_info_test.c index 3c50cb158..c51f94cd9 100644 --- a/modules/cfe_testcase/src/es_info_test.c +++ b/modules/cfe_testcase/src/es_info_test.c @@ -35,7 +35,7 @@ const char TEST_EXPECTED_FILE_NAME[] = "cfe_testcase"; const char ES_APP_EXPECTED_NAME[] = "CFE_ES"; const char INVALID_APP_NAME[] = "INVALID_NAME"; -void TestAppInfo(void) +void TestGetAppInfo(void) { CFE_ES_AppId_t TestAppId; CFE_ES_AppId_t ESAppId; @@ -129,7 +129,7 @@ void TestAppInfo(void) UtAssert_INT32_EQ(CFE_ES_GetAppInfo(NULL, TestAppId), CFE_ES_BAD_ARGUMENT); } -void TestTaskInfo(void) +void TestGetTaskInfo(void) { CFE_ES_AppId_t AppId; CFE_ES_AppInfo_t AppInfo; @@ -159,7 +159,7 @@ void TestTaskInfo(void) UtAssert_INT32_EQ(CFE_ES_GetTaskID(NULL), CFE_ES_BAD_ARGUMENT); } -void TestLibInfo(void) +void TestGetLibInfo(void) { CFE_ES_LibId_t LibId; CFE_ES_LibId_t CheckId; @@ -238,7 +238,7 @@ void TestResetType(void) UtAssert_True((rSubType > 0) && (rSubType < 10), "Reset Sub-Type = %d", (int)rSubType); } -void TestModuleInfo(void) +void TestGetModuleInfo(void) { CFE_ES_AppInfo_t ModuleInfo; CFE_ES_LibId_t LibIdByName; @@ -271,9 +271,9 @@ void TestModuleInfo(void) void ESInfoTestSetup(void) { - UtTest_Add(TestAppInfo, NULL, NULL, "Test App Info"); - UtTest_Add(TestTaskInfo, NULL, NULL, "Test Task Info"); - UtTest_Add(TestLibInfo, NULL, NULL, "Test Lib Info"); + UtTest_Add(TestGetAppInfo, NULL, NULL, "Test App Info"); + UtTest_Add(TestGetTaskInfo, NULL, NULL, "Test Task Info"); + UtTest_Add(TestGetLibInfo, NULL, NULL, "Test Lib Info"); UtTest_Add(TestResetType, NULL, NULL, "Test Reset Type"); - UtTest_Add(TestModuleInfo, NULL, NULL, "Test Module Info"); + UtTest_Add(TestGetModuleInfo, NULL, NULL, "Test Module Info"); } From 324617080417764f81f0be0a5a3fe20e5eaf3f48 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Mon, 16 May 2022 13:43:17 -0600 Subject: [PATCH 4/4] Fix #2103, Resolve UT buffer underflow warning --- modules/cfe_testcase/src/es_counter_test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/cfe_testcase/src/es_counter_test.c b/modules/cfe_testcase/src/es_counter_test.c index 6e1f70558..55c37ade1 100644 --- a/modules/cfe_testcase/src/es_counter_test.c +++ b/modules/cfe_testcase/src/es_counter_test.c @@ -62,6 +62,13 @@ void TestCounterCreateDelete(void) CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS); } + /* If no counters were available skip the rest of the test */ + if (NumCounters == 0) + { + UtAssert_MIR("No ES generic counters available for testing, skipping"); + return; + } + /* Confirm that the expected number of counters were created */ UtAssert_UINT32_LTEQ(NumCounters, CFE_PLATFORM_ES_MAX_GEN_COUNTERS);