Skip to content

Commit

Permalink
Merge pull request nasa#65 from jphickey/fix-64-formats
Browse files Browse the repository at this point in the history
Fix nasa#64, correct printf format strings and conversions
  • Loading branch information
dzbaker authored Jan 18, 2024
2 parents 0c7c6d4 + 0ec0368 commit 05cb142
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion fsw/src/hk_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int32 HK_ValidateHkCopyTable(void *TblPtr)
HKStatus = HK_ERROR;

CFE_EVS_SendEvent(HK_NEWCPYTBL_HK_FAILED_EID, CFE_EVS_EventType_ERROR,
"HK Validate: table contents has size %d > %d\n", sumBytes, HK_MAX_COMBINED_PACKET_SIZE);
"HK Validate: table contents has size %d > %d\n", (int)sumBytes, HK_MAX_COMBINED_PACKET_SIZE);
}
else
{
Expand Down
29 changes: 13 additions & 16 deletions unit-test/hk_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,15 @@ void Test_HK_ProcessIncomingHkData_MessageError(void)
void Test_HK_ValidateHkCopyTable_Success(void)
{
/* Arrange */
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

HK_Test_InitGoodCopyTable(CopyTblPtr);

/* Act */
int32 ReturnValue = HK_ValidateHkCopyTable(CopyTblPtr);

/* Assert */
UtAssert_True(ReturnValue == HK_SUCCESS, "HK_ValidateHkCopyTable returned %d, expected %d (HK_SUCCESS)",
ReturnValue, HK_SUCCESS);
UtAssert_INT32_EQ(ReturnValue, HK_SUCCESS);
}

/*
Expand All @@ -322,16 +321,15 @@ void Test_HK_ValidateHkCopyTable_Success(void)
void Test_HK_ValidateHkCopyTable_Error(void)
{
/* Arrange */
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];
hk_copy_table_entry_t CopyTblPtr[HK_COPY_TABLE_ENTRIES];

HK_Test_InitOverflowCopyTable(CopyTblPtr);

/* Act */
int32 ReturnValue = HK_ValidateHkCopyTable(CopyTblPtr);

/* Assert */
UtAssert_True(ReturnValue == HK_ERROR, "HK_ValidateHkCopyTable returned %d, expected %d (HK_ERROR)",
ReturnValue, HK_ERROR);
UtAssert_INT32_EQ(ReturnValue, HK_ERROR);
}

/**********************************************************************/
Expand Down Expand Up @@ -422,7 +420,7 @@ void Test_HK_ProcessNewCopyTable_PoolBufFail(void)
CFE_Status_t ReturnValue;
int32 i;
int32 ExtraSubscribes = 0;
int32 strCmpResult;
int strCmpResult;

char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];

Expand Down Expand Up @@ -457,7 +455,7 @@ void Test_HK_ProcessNewCopyTable_PoolBufFail(void)
strCmpResult =
strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[i].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event #%d string matched expected result, '%s'", i,
UtAssert_True(strCmpResult == 0, "Event #%d string matched expected result, '%s'", (int)i,
context_CFE_EVS_SendEvent[i].Spec);
}

Expand Down Expand Up @@ -486,7 +484,7 @@ void Test_HK_ProcessNewCopyTable_SubscribeFail(void)
{
/* Arrange */
CFE_Status_t ReturnValue;
int32 strCmpResult;
int strCmpResult;
int32 i;
int32 SubscriptionCount = 0;

Expand Down Expand Up @@ -522,7 +520,7 @@ void Test_HK_ProcessNewCopyTable_SubscribeFail(void)
strCmpResult =
strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[i].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event #%d string matched expected result, '%s'", i,
UtAssert_True(strCmpResult == 0, "Event #%d string matched expected result, '%s'", (int)i,
context_CFE_EVS_SendEvent[i].Spec);
}

Expand Down Expand Up @@ -867,7 +865,7 @@ void Test_HK_TearDownOldCopyTable_PoolFreeFail(void)
/* Arrange */
CFE_Status_t ReturnValue;
int32 i;
int32 strCmpResult;
int strCmpResult;

char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];

Expand Down Expand Up @@ -901,7 +899,7 @@ void Test_HK_TearDownOldCopyTable_PoolFreeFail(void)
strCmpResult =
strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[i].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event #%d string matched expected result, '%s'", i,
UtAssert_True(strCmpResult == 0, "Event #%d string matched expected result, '%s'", (int)i,
context_CFE_EVS_SendEvent[i].Spec);
}
}
Expand Down Expand Up @@ -938,7 +936,7 @@ void Test_HK_TearDownOldCopyTable_Success(void)

for (i = 0; i < 5; i++)
{
UtAssert_True(RtTblPtr[i].OutputPktAddr == NULL, "RtTblPtr[%d].OutputPktAddr == NULL", i);
UtAssert_True(RtTblPtr[i].OutputPktAddr == NULL, "RtTblPtr[%d].OutputPktAddr == NULL", (int)i);
UtAssert_INT32_EQ(RtTblPtr[i].InputMidSubscribed, HK_INPUTMID_NOT_SUBSCRIBED);
}
}
Expand Down Expand Up @@ -1019,7 +1017,7 @@ void Test_HK_TearDownOldCopyTable_Success2(void)

for (i = 0; i < 5; i++)
{
UtAssert_True(RtTblPtr[i].OutputPktAddr == NULL, "RtTblPtr[%d].OutputPktAddr == NULL", i);
UtAssert_True(RtTblPtr[i].OutputPktAddr == NULL, "RtTblPtr[%d].OutputPktAddr == NULL", (int)i);
UtAssert_INT32_EQ(RtTblPtr[i].InputMidSubscribed, HK_INPUTMID_NOT_SUBSCRIBED);
}
}
Expand Down Expand Up @@ -1955,8 +1953,7 @@ void UtTest_Setup(void)
/* Test functions for HK_VaidateHkCopyTable */
UtTest_Add(Test_HK_ValidateHkCopyTable_Success, HK_Test_Setup, HK_Test_TearDown,
"Test_HK_ValidateHkCopyTable_Success");
UtTest_Add(Test_HK_ValidateHkCopyTable_Error, HK_Test_Setup, HK_Test_TearDown,
"Test_HK_ValidateHkCopyTable_Error");
UtTest_Add(Test_HK_ValidateHkCopyTable_Error, HK_Test_Setup, HK_Test_TearDown, "Test_HK_ValidateHkCopyTable_Error");

/* Test functions for HK_ProcessNewCopyTable */
UtTest_Add(Test_HK_ProcessNewCopyTable_EmptyTable, HK_Test_Setup, HK_Test_TearDown,
Expand Down

0 comments on commit 05cb142

Please sign in to comment.