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 #2210, Move variables declared mid-function to the top #2211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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 TestGetReleaseAddresses(void)
{
int i;
int numValidTbls = 5;
char TblName[10];
CFE_TBL_Handle_t TblHandles[numValidTbls + 1];
Expand All @@ -116,14 +117,14 @@
/* 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(
CFE_TBL_Register(&TblHandles[i], TblName, sizeof(CFE_TEST_TestTable_t), CFE_TBL_OPT_DEFAULT, NULL),
CFE_SUCCESS);
TblPtrs[i] = TblPtrsList + i;
}

Check warning

Code scanning / CodeQL-coding-standard

Unbounded loop Warning test

This loop does not have a fixed bound.

UtAssert_INT32_EQ(CFE_TBL_GetAddresses(NULL, numValidTbls, TblHandles), CFE_TBL_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_TBL_GetAddresses((void ***)&TblPtrs, numValidTbls, NULL), CFE_TBL_BAD_ARGUMENT);
Expand All @@ -132,13 +133,13 @@
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)
{
UtAssert_Failed("Failed to load data for table number %d", i);
}
}

Check warning

Code scanning / CodeQL-coding-standard

Unbounded loop Warning test

This loop does not have a fixed bound.
/* First time returns status message of CFE_TBL_INFO_UPDATED */
UtAssert_INT32_EQ(CFE_TBL_GetAddresses((void ***)&TblPtrs, numValidTbls, TblHandles + 1), CFE_TBL_INFO_UPDATED);
UtAssert_INT32_EQ(CFE_TBL_GetAddresses((void ***)&TblPtrs, numValidTbls, TblHandles + 1), CFE_SUCCESS);
Expand All @@ -149,13 +150,13 @@
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)
{
UtAssert_Failed("Failed to unregister table number %d", i);
}
}

Check warning

Code scanning / CodeQL-coding-standard

Unbounded loop Warning test

This loop does not have a fixed bound.
}

void TBLContentAccessTestSetup(void)
Expand Down
17 changes: 8 additions & 9 deletions modules/cfe_testcase/src/tbl_information_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ void TestGetStatus(void)
void TestGetInfo(void)
{
CFE_TBL_Info_t TblInfo;
const char * BadTblName = "BadTable";
const char * BadTblName = "BadTable";
size_t expectedSize = sizeof(CFE_TEST_TestTable_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,14 +64,6 @@ void TestGetInfo(void)
UtAssert_INT32_EQ(CFE_TBL_GetInfo(&TblInfo, BadTblName), CFE_TBL_ERR_INVALID_NAME);
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(CFE_TEST_TestTable_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
Loading