Skip to content

Commit

Permalink
Fix nasa#2210, Move variables declared mid-function to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Nov 15, 2022
1 parent 6cccb3f commit 56c3f99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions modules/cfe_testcase/src/tbl_content_access_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void TestReleaseAddress(void)

void TestGetReleaseAddresses(void)
{
int i;
int numValidTbls = 5;
char TblName[10];
CFE_TBL_Handle_t TblHandles[numValidTbls + 1];
Expand All @@ -116,7 +117,7 @@ void TestGetReleaseAddresses(void)
/* Put an invalid handle at the start*/
TblHandles[0] = CFE_TBL_BAD_TABLE_HANDLE;
TblPtrs[0] = TblPtrsList;
for (int i = 1; i < numValidTbls + 1; i++)
for (i = 1; i < numValidTbls + 1; i++)
{
sprintf(TblName, "%d", i);
UtAssert_INT32_EQ(
Expand All @@ -132,7 +133,7 @@ void TestGetReleaseAddresses(void)
UtAssert_INT32_EQ(CFE_TBL_GetAddresses((void ***)&TblPtrs, numValidTbls, TblHandles + 1), CFE_TBL_ERR_NEVER_LOADED);

/* Load data and then get addresses */
for (int i = 1; i < numValidTbls + 1; i++)
for (i = 1; i < numValidTbls + 1; i++)
{
if (CFE_TBL_Load(TblHandles[i], CFE_TBL_SRC_ADDRESS, &TestTable) != CFE_SUCCESS)
{
Expand All @@ -149,7 +150,7 @@ void TestGetReleaseAddresses(void)
UtAssert_INT32_EQ(CFE_TBL_ReleaseAddresses(numValidTbls, TblHandles + 1), CFE_SUCCESS);

/* Unregister all tables */
for (int i = 1; i < numValidTbls + 1; i++)
for (i = 1; i < numValidTbls + 1; i++)
{
if (CFE_TBL_Unregister(TblHandles[i]) != CFE_SUCCESS)
{
Expand Down
16 changes: 8 additions & 8 deletions modules/cfe_testcase/src/tbl_information_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ void TestGetStatus(void)
void TestGetInfo(void)
{
CFE_TBL_Info_t TblInfo;
const char * BadTblName = "BadTable";
const char * BadTblName = "BadTable";
size_t expectedSize = sizeof(TBL_TEST_Table_t);
uint32 expectedNumUsers = 1;
bool expectedTableLoaded = false;
bool expectedDumpOnly = false;
bool expectedDoubleBuf = false;
bool expectedUserDefAddr = false;
bool expectedCritical = false;

memset(&TblInfo, 0, sizeof(TblInfo));

Expand All @@ -57,13 +64,6 @@ void TestGetInfo(void)
UtAssert_INT32_EQ(CFE_TBL_GetInfo(&TblInfo, NULL), CFE_TBL_BAD_ARGUMENT);

/* This is only checking some parts of the TblInfo struct */
size_t expectedSize = sizeof(TBL_TEST_Table_t);
uint32 expectedNumUsers = 1;
bool expectedTableLoaded = false;
bool expectedDumpOnly = false;
bool expectedDoubleBuf = false;
bool expectedUserDefAddr = false;
bool expectedCritical = false;
UtAssert_UINT32_EQ(TblInfo.Size, expectedSize);
UtAssert_UINT32_EQ(TblInfo.NumUsers, expectedNumUsers);
UtAssert_INT32_EQ(TblInfo.TableLoadedOnce, expectedTableLoaded);
Expand Down

0 comments on commit 56c3f99

Please sign in to comment.