Skip to content

Commit

Permalink
Fix nasa#2100, Resolve UT uninit var static analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed May 12, 2022
1 parent 81416f8 commit e03f5e5
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 122 deletions.
3 changes: 3 additions & 0 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions modules/evs/ut-coverage/evs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,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;
Expand Down Expand Up @@ -1683,6 +1685,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 */
Expand Down
32 changes: 16 additions & 16 deletions modules/msg/ut-coverage/test_msg_pri_not.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit e03f5e5

Please sign in to comment.