Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8, Resolve UT uninit var static analysis warnings #15

Merged
merged 2 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions unit-test/md_cmds_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ void MD_ProcessJamCmd_Test_CantResolveJamAddr(void)
UT_CmdBuf.CmdJam.EntryId = 2;
UT_CmdBuf.CmdJam.FieldLength = 1;

strncpy(UT_CmdBuf.CmdJam.DwellAddress.SymName, "address", 10);
strncpy(UT_CmdBuf.CmdJam.DwellAddress.SymName, "address", sizeof(UT_CmdBuf.CmdJam.DwellAddress.SymName) - 1);

/* Set to satisfy condition "MD_ResolveSymAddr(&Jam->DwellAddress,&ResolvedAddr) == FALSE" */
UT_SetDeferredRetcode(UT_KEY(MD_ResolveSymAddr), 1, false);
Expand Down Expand Up @@ -1199,7 +1199,7 @@ void MD_ProcessSignatureCmd_Test_InvalidSignatureLength(void)
TestMsgId = CFE_SB_ValueToMsgId(MD_CMD_MID);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);

for (i = 0; i < MD_SIGNATURE_FIELD_LENGTH; i++)
for (i = 0; i < sizeof(UT_CmdBuf.CmdSetSignature.Signature); i++)
{
UT_CmdBuf.CmdSetSignature.Signature[i] = 'x';
}
Expand Down Expand Up @@ -1275,7 +1275,7 @@ void MD_ProcessSignatureCmd_Test_Success(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);

UT_CmdBuf.CmdSetSignature.TableId = 1;
strncpy(UT_CmdBuf.CmdSetSignature.Signature, "signature", MD_SIGNATURE_FIELD_LENGTH);
strncpy(UT_CmdBuf.CmdSetSignature.Signature, "signature", sizeof(UT_CmdBuf.CmdSetSignature.Signature) - 1);

/* Prevents segmentation fault in call to subfunction MD_UpdateTableSignature */
UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &MD_CMDS_TEST_CFE_TBL_GetAddressHook, NULL);
Expand Down Expand Up @@ -1320,7 +1320,7 @@ void MD_ProcessSignatureCmd_Test_NoUpdateTableSignature(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);

UT_CmdBuf.CmdSetSignature.TableId = 1;
strncpy(UT_CmdBuf.CmdSetSignature.Signature, "signature", MD_SIGNATURE_FIELD_LENGTH);
strncpy(UT_CmdBuf.CmdSetSignature.Signature, "signature", sizeof(UT_CmdBuf.CmdSetSignature.Signature) - 1);

/* Prevents segmentation fault in call to subfunction MD_UpdateTableSignature */
UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), &MD_CMDS_TEST_CFE_TBL_GetAddressHook, NULL);
Expand Down
2 changes: 1 addition & 1 deletion unit-test/md_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void MD_Verify16Aligned_Test(void)
void MD_ResolveSymAddr_Test(void)
{
MD_SymAddr_t SymAddr;
cpuaddr ResolvedAddr;
cpuaddr ResolvedAddr = 0;
bool Result;

memset(&SymAddr, 0, sizeof(MD_SymAddr_t));
Expand Down
2 changes: 1 addition & 1 deletion unit-test/utilities/md_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void UT_Handler_CFE_EVS_SendEvent(void *UserObj, UT_EntryKey_t FuncKey, const UT
void UT_Handler_CFE_ES_WriteToSysLog(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context, va_list va)
{
strncpy(context_CFE_ES_WriteToSysLog.Spec, UT_Hook_GetArgValueByName(Context, "SpecStringPtr", const char *),
CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);
CFE_MISSION_EVS_MAX_MESSAGE_LENGTH - 1);
context_CFE_ES_WriteToSysLog.Spec[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH - 1] = '\0';
}

Expand Down