From 6e0f5412dc69d0a89265646d78d1bf879113e5b5 Mon Sep 17 00:00:00 2001 From: Avi Date: Sun, 13 Nov 2022 08:51:52 +1000 Subject: [PATCH] Fix #1330, Move variables declared mid-function to the top --- src/tests/time-base-api-test/time-base-api-test.c | 3 ++- src/unit-test-coverage/shared/src/coveragetest-idmap.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tests/time-base-api-test/time-base-api-test.c b/src/tests/time-base-api-test/time-base-api-test.c index 6ce05160a..5322a808f 100644 --- a/src/tests/time-base-api-test/time-base-api-test.c +++ b/src/tests/time-base-api-test/time-base-api-test.c @@ -74,6 +74,7 @@ void TestTimeBaseApi(void) osal_id_t tb_id[OS_MAX_TIMEBASES]; char timebase_name[OS_MAX_API_NAME + 5]; OS_timebase_prop_t timebase_prop; + int i; /* * Test Case For: @@ -89,7 +90,7 @@ void TestTimeBaseApi(void) UtAssert_INT32_EQ(OS_TimeBaseCreate(&time_base_id, timebase_name, 0), OS_ERR_NAME_TOO_LONG); /* Checking for OS_MAX_TIMEBASES */ - for (int i = 0; i < OS_MAX_TIMEBASES; i++) + for (i = 0; i < OS_MAX_TIMEBASES; i++) { /* On the final setup pass, while there is still one free slot, * check attempting to create a duplicate name (index 0) - this diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index 053931283..1b8f8ea8a 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -1157,6 +1157,8 @@ void Test_OS_ObjectIDInteger(void) int32 recordscount = 0; osal_objtype_t idtype; char str[OS_MAX_API_NAME]; + int i; + int j; memset(&token, 0, sizeof(token)); @@ -1181,11 +1183,11 @@ void Test_OS_ObjectIDInteger(void) UtAssert_True(recordscount < OS_MAX_TOTAL_RECORDS, "All Id types checked"); - for (int i = 0; i < recordscount; i++) + for (i = 0; i < recordscount; i++) { UtAssert_True(OS_ObjectIdDefined(typesI[i]), "%lu Is defined", OS_ObjectIdToInteger(typesI[i])); - for (int j = 0; j < recordscount; j++) + for (j = 0; j < recordscount; j++) { if (i == j) {