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 16, 2022
1 parent 81416f8 commit 1f62f72
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 128 deletions.
11 changes: 7 additions & 4 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down 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 Expand Up @@ -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++)
Expand All @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion 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 @@ -855,7 +857,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");
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 1f62f72

Please sign in to comment.