diff --git a/README.md b/README.md index e28af65db..9e18b009f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,14 @@ The autogenerated OSAL user's guide can be viewed at + ### Development Build: v6.0.0-rc4+dev74 - Update codeql workflows for reusable update diff --git a/src/bsp/pc-rtems/build_options.cmake b/src/bsp/pc-rtems/build_options.cmake index d32e9245a..909fe8b7e 100644 --- a/src/bsp/pc-rtems/build_options.cmake +++ b/src/bsp/pc-rtems/build_options.cmake @@ -6,5 +6,12 @@ # Link the RTEMS BSP with the "rtemscpu" system library target_link_libraries(osal_bsp - rtemscpu + rtemscpu ) + +# Add the networking library for RTEMS 6+ +if(CMAKE_SYSTEM_VERSION GREATER 5) + target_link_libraries(osal_bsp + networking + ) +endif(CMAKE_SYSTEM_VERSION GREATER 5) diff --git a/src/bsp/pc-rtems/src/bsp_start.c b/src/bsp/pc-rtems/src/bsp_start.c index a95e861d2..172748692 100644 --- a/src/bsp/pc-rtems/src/bsp_start.c +++ b/src/bsp/pc-rtems/src/bsp_start.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -47,6 +46,10 @@ #include #include +#if defined(OS_RTEMS_4_DEPRECATED) || defined(OS_RTEMS_5) +#include +#endif + #include "pcrtems_bsp_internal.h" /* @@ -178,6 +181,7 @@ void OS_BSP_Setup(void) BSP_DEBUG("rtems_semaphore_create: %s\n", rtems_status_text(status)); } +#if defined(OS_RTEMS_4_DEPRECATED) || defined(OS_RTEMS_5) /* ** Create the RTEMS Root file system */ @@ -186,6 +190,7 @@ void OS_BSP_Setup(void) { printf("Creating Root file system failed: %s\n", rtems_status_text(status)); } +#endif /* * Create the mountpoint for the general purpose file system @@ -413,10 +418,10 @@ rtems_task Init(rtems_task_argument ignored) #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES (OS_MAX_QUEUES + 4) #define CONFIGURE_MAXIMUM_DRIVERS 10 #define CONFIGURE_MAXIMUM_POSIX_KEYS 4 -#ifdef _RTEMS_5_ -#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) -#else +#ifdef OS_RTEMS_4_DEPRECATED #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) +#else +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (OS_MAX_NUM_OPEN_FILES + 8) #endif #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h index e752abd84..dc909d239 100644 --- a/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h +++ b/src/bsp/pc-rtems/src/pcrtems_bsp_internal.h @@ -42,10 +42,10 @@ /* * Handle the differences between RTEMS 5 and 4.11 copyright notice */ -#ifdef _RTEMS_5_ -#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice() -#else +#ifdef OS_RTEMS_4_DEPRECATED #define OSAL_BSP_COPYRIGHT_NOTICE _Copyright_Notice +#else +#define OSAL_BSP_COPYRIGHT_NOTICE rtems_get_copyright_notice() #endif /* diff --git a/src/os/inc/osapi-version.h b/src/os/inc/osapi-version.h index 3e20c0909..c9cf2eb56 100644 --- a/src/os/inc/osapi-version.h +++ b/src/os/inc/osapi-version.h @@ -34,7 +34,7 @@ /* * Development Build Macro Definitions */ -#define OS_BUILD_NUMBER 74 +#define OS_BUILD_NUMBER 83 #define OS_BUILD_BASELINE "v6.0.0-rc4" /* diff --git a/src/os/rtems/inc/os-rtems.h b/src/os/rtems/inc/os-rtems.h index ca250a19c..e18ed3b15 100644 --- a/src/os/rtems/inc/os-rtems.h +++ b/src/os/rtems/inc/os-rtems.h @@ -51,21 +51,22 @@ DEFINES ***************************************************************************************/ /* - * Handle the data structure and API name changes between RTEMS 4.11 and RTEMS 5.1 + * Handle the data structure and API name changes between RTEMS 4.11 and RTEMS 5.1+ */ -#ifdef _RTEMS_5_ -#define OSAL_HEAP_INFO_BLOCK Heap_Information_block -#define OSAL_UNRESOLV_REC_TYPE rtems_rtl_unresolv_rec -#define OSAL_UNRESOLVED_SYMBOL rtems_rtl_unresolved_symbol -#define OSAL_UNRESOLVED_ITERATE rtems_rtl_unresolved_iterate - -#else +#ifdef OS_RTEMS_4_DEPRECATED #define OSAL_HEAP_INFO_BLOCK region_information_block #define OSAL_UNRESOLV_REC_TYPE rtems_rtl_unresolv_rec_t #define OSAL_UNRESOLVED_SYMBOL rtems_rtl_unresolved_name #define OSAL_UNRESOLVED_ITERATE rtems_rtl_unresolved_interate +#else + +#define OSAL_HEAP_INFO_BLOCK Heap_Information_block +#define OSAL_UNRESOLV_REC_TYPE rtems_rtl_unresolv_rec +#define OSAL_UNRESOLVED_SYMBOL rtems_rtl_unresolved_symbol +#define OSAL_UNRESOLVED_ITERATE rtems_rtl_unresolved_iterate + #endif /**************************************************************************************** diff --git a/src/os/rtems/src/os-impl-filesys.c b/src/os/rtems/src/os-impl-filesys.c index f211d8d62..efa175fe9 100644 --- a/src/os/rtems/src/os-impl-filesys.c +++ b/src/os/rtems/src/os-impl-filesys.c @@ -190,7 +190,9 @@ int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token) */ if (return_code == OS_SUCCESS && local->system_mountpt[0] == 0) { - snprintf(local->system_mountpt, sizeof(local->system_mountpt), "/%s", local->volume_name); + local->system_mountpt[0] = '/'; + local->system_mountpt[sizeof(local->system_mountpt) - 1] = 0; + strncpy(&local->system_mountpt[1], local->volume_name, sizeof(local->system_mountpt) - 2); OS_DEBUG("OSAL: using mount point %s for %s\n", local->system_mountpt, local->volume_name); } diff --git a/src/os/rtems/src/os-impl-loader.c b/src/os/rtems/src/os-impl-loader.c index 4974aaa48..c044d12b9 100644 --- a/src/os/rtems/src/os-impl-loader.c +++ b/src/os/rtems/src/os-impl-loader.c @@ -39,7 +39,7 @@ TYPEDEFS ***************************************************************************************/ -#ifndef _RTEMS_5_ +#ifdef OS_RTEMS_4_DEPRECATED typedef rtems_rtl_obj_t rtems_rtl_obj; /* Alias for RTEMS 4.11 */ diff --git a/src/tests/bin-sem-flush-test/bin-sem-flush-test.c b/src/tests/bin-sem-flush-test/bin-sem-flush-test.c index 589905f56..1975732c9 100644 --- a/src/tests/bin-sem-flush-test/bin-sem-flush-test.c +++ b/src/tests/bin-sem-flush-test/bin-sem-flush-test.c @@ -59,6 +59,8 @@ void task_1(void) OS_bin_sem_prop_t bin_sem_prop; int counter = 0; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + OS_printf("Starting task 1\n"); OS_printf("TASK 1: Waiting on the semaphore\n"); @@ -96,6 +98,8 @@ void task_2(void) OS_bin_sem_prop_t bin_sem_prop; int counter = 0; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + task_2_failures = 0; OS_printf("Starting task 2\n"); @@ -134,6 +138,8 @@ void task_3(void) OS_bin_sem_prop_t bin_sem_prop; int counter = 0; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + OS_printf("Starting task 3\n"); OS_printf("TASK 3: Waiting on the semaphore\n"); @@ -189,6 +195,8 @@ void BinSemFlushSetup(void) uint32 status; OS_bin_sem_prop_t bin_sem_prop; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + /* Note that UT assert is not multi-thread safe, * so each thread must use a separate error counter * and then we will assert that these remain zero diff --git a/src/tests/bin-sem-test/bin-sem-test.c b/src/tests/bin-sem-test/bin-sem-test.c index f59cfa6bb..2d2ec810b 100644 --- a/src/tests/bin-sem-test/bin-sem-test.c +++ b/src/tests/bin-sem-test/bin-sem-test.c @@ -68,7 +68,10 @@ int counter = 0; */ void TimerFunction(osal_id_t local_timer_id) { - int32 status; + int32 status; + OS_bin_sem_prop_t bin_sem_prop; + + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); timer_counter++; @@ -79,7 +82,6 @@ void TimerFunction(osal_id_t local_timer_id) } { - OS_bin_sem_prop_t bin_sem_prop; status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); if (status != OS_SUCCESS) { @@ -102,6 +104,8 @@ void task_1(void) OS_bin_sem_prop_t bin_sem_prop; int printf_counter = 0; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + OS_printf("Starting task 1\n"); OS_printf("Delay for 1 second before starting\n"); @@ -153,6 +157,8 @@ void BinSemCheck(void) uint32 status; OS_bin_sem_prop_t bin_sem_prop; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + /* Delete the task, which should be pending in OS_BinSemTake() */ status = OS_TaskDelete(task_1_id); UtAssert_True(status == OS_SUCCESS, "OS_TaskDelete Rc=%d", (int)status); @@ -196,9 +202,11 @@ void UtTest_Setup(void) void BinSemSetup(void) { uint32 status; - uint32 accuracy; + uint32 accuracy = 0; OS_bin_sem_prop_t bin_sem_prop; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + /* separate task failure counter because ut-assert is not reentrant */ task_1_failures = 0; timer_failures = 0; diff --git a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c index dab8b8bd1..4a3dc4ba2 100644 --- a/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c +++ b/src/tests/bin-sem-timeout-test/bin-sem-timeout-test.c @@ -64,7 +64,10 @@ int counter = 0; */ void TimerFunction(osal_id_t local_timer_id) { - int32 status; + int32 status; + OS_bin_sem_prop_t bin_sem_prop; + + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); timer_counter++; @@ -75,7 +78,6 @@ void TimerFunction(osal_id_t local_timer_id) } { - OS_bin_sem_prop_t bin_sem_prop; status = OS_BinSemGetInfo(bin_sem_id, &bin_sem_prop); if (status != OS_SUCCESS) { @@ -97,6 +99,8 @@ void task_1(void) uint32 status; OS_bin_sem_prop_t bin_sem_prop; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + OS_printf("Starting task 1\n"); OS_printf("Delay for 1 second before starting\n"); @@ -192,7 +196,9 @@ void BinSemTimeoutSetup(void) { uint32 status; OS_bin_sem_prop_t bin_sem_prop; - uint32 accuracy; + uint32 accuracy = 0; + + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); task_1_timeouts = 0; task_1_work = 0; diff --git a/src/tests/file-api-test/file-api-test.c b/src/tests/file-api-test/file-api-test.c index 2c2e533bd..ca632af0e 100644 --- a/src/tests/file-api-test/file-api-test.c +++ b/src/tests/file-api-test/file-api-test.c @@ -129,7 +129,7 @@ void TestCreatRemove(void) char maxfilename[OS_MAX_PATH_LEN]; char longfilename[OS_MAX_PATH_LEN + 10]; int32 status; - osal_id_t fd; + osal_id_t fd = OS_OBJECT_ID_UNDEFINED; int i; /* Short file name */ @@ -199,7 +199,7 @@ void TestOpenClose(void) { char filename[OS_MAX_PATH_LEN]; int32 status; - osal_id_t fd; + osal_id_t fd = OS_OBJECT_ID_UNDEFINED; strncpy(filename, "/drive0/Filename1", sizeof(filename) - 1); filename[sizeof(filename) - 1] = 0; @@ -251,7 +251,7 @@ void TestChmod(void) { char filename[OS_MAX_PATH_LEN]; int32 status; - osal_id_t fd; + osal_id_t fd = OS_OBJECT_ID_UNDEFINED; /*Make a file to test on. Start in Read only mode */ strncpy(filename, "/drive0/Filename1", sizeof(filename) - 1); @@ -324,7 +324,9 @@ void TestReadWriteLseek(void) size_t offset; size_t size; int32 status; - osal_id_t fd; + osal_id_t fd = OS_OBJECT_ID_UNDEFINED; + + memset(newbuffer, 0, sizeof(newbuffer)); strncpy(filename, "/drive0/Filename1", sizeof(filename) - 1); filename[sizeof(filename) - 1] = 0; @@ -446,11 +448,13 @@ void TestMkRmDirFreeBytes(void) char buffer2[OS_MAX_PATH_LEN]; char copybuffer1[OS_MAX_PATH_LEN]; char copybuffer2[OS_MAX_PATH_LEN]; - osal_id_t fd1; - osal_id_t fd2; + osal_id_t fd1 = OS_OBJECT_ID_UNDEFINED; + osal_id_t fd2 = OS_OBJECT_ID_UNDEFINED; size_t size; OS_statvfs_t statbuf; + memset(&statbuf, 0, sizeof(statbuf)); + /* make the directory names for testing, as well as the filenames and the buffers * to put in the files */ strcpy(dir1, "/drive0/DIRECTORY_ONE"); @@ -561,9 +565,9 @@ void TestOpenReadCloseDir(void) char buffer1[OS_MAX_PATH_LEN]; char buffer2[OS_MAX_PATH_LEN]; size_t size; - osal_id_t fd1; - osal_id_t fd2; - osal_id_t dirh; + osal_id_t fd1 = OS_OBJECT_ID_UNDEFINED; + osal_id_t fd2 = OS_OBJECT_ID_UNDEFINED; + osal_id_t dirh = OS_OBJECT_ID_UNDEFINED; os_dirent_t dirent; /* make the directory names for testing, as well as the filenames and the buffers @@ -768,7 +772,7 @@ void TestRename(void) char midname1[OS_MAX_PATH_LEN]; char newfilename1[OS_MAX_PATH_LEN]; - osal_id_t fd1; + osal_id_t fd1 = OS_OBJECT_ID_UNDEFINED; size_t size; /* make the directory names for testing, as well as the filenames and the buffers @@ -854,7 +858,7 @@ void TestStat(void) char dir1slash[OS_MAX_PATH_LEN]; char buffer1[OS_MAX_PATH_LEN]; os_fstat_t StatBuff; - osal_id_t fd1; + osal_id_t fd1 = OS_OBJECT_ID_UNDEFINED; size_t size; strcpy(dir1, "/drive0/DirectoryName"); diff --git a/src/tests/idmap-api-test/idmap-api-test.c b/src/tests/idmap-api-test/idmap-api-test.c index 917c1614a..004d55e52 100644 --- a/src/tests/idmap-api-test/idmap-api-test.c +++ b/src/tests/idmap-api-test/idmap-api-test.c @@ -188,9 +188,9 @@ void Test_OS_ConvertToArrayIndex(void) * Test Case For: * int32 OS_ConvertToArrayIndex(void) */ - osal_index_t TestArrayIndex; - osal_index_t TestMutex1Index; - osal_index_t TestMutex2Index; + osal_index_t TestArrayIndex = OSAL_INDEX_C(0); + osal_index_t TestMutex1Index = OSAL_INDEX_C(0); + osal_index_t TestMutex2Index = OSAL_INDEX_C(0); /* * Check different id types and verify array indices @@ -203,34 +203,29 @@ void Test_OS_ConvertToArrayIndex(void) * Test with nominal values */ UtAssert_INT32_EQ(OS_ConvertToArrayIndex(task_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TASKS, "0 < TestArrayIndex(%lu) <= OS_MAX_TASKS", - (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_TASKS, "TestArrayIndex(%lu) < OS_MAX_TASKS", (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ConvertToArrayIndex(queue_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_QUEUES, "0 < TestArrayIndex(%lu) <= OS_MAX_QUEUES", - (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_QUEUES, "TestArrayIndex(%lu) < OS_MAX_QUEUES", (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ConvertToArrayIndex(count_sem_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_COUNT_SEMAPHORES, - "0 < TestArrayIndex(%lu) <= OS_MAX_COUNT_SEMAPHORES", (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_COUNT_SEMAPHORES, "TestArrayIndex(%lu) < OS_MAX_COUNT_SEMAPHORES", + (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ConvertToArrayIndex(bin_sem_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_BIN_SEMAPHORES, - "0 < TestArrayIndex(%lu) <= OS_MAX_BIN_SEMAPHORES", (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_BIN_SEMAPHORES, "TestArrayIndex(%lu) < OS_MAX_BIN_SEMAPHORES", + (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ConvertToArrayIndex(mutex_id1, &TestMutex1Index), OS_SUCCESS); - UtAssert_True(TestMutex1Index >= 0 && TestMutex1Index < OS_MAX_MUTEXES, - "0 < TestMutex1Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex1Index); + UtAssert_True(TestMutex1Index < OS_MAX_MUTEXES, "TestMutex1Index(%lu) < OS_MAX_MUTEXES", (long)TestMutex1Index); UtAssert_INT32_EQ(OS_ConvertToArrayIndex(mutex_id2, &TestMutex2Index), OS_SUCCESS); - UtAssert_True(TestMutex2Index >= 0 && TestMutex2Index < OS_MAX_MUTEXES, - "0 < TestMutex2Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex2Index); + UtAssert_True(TestMutex2Index < OS_MAX_MUTEXES, "TestMutex2Index(%lu) < OS_MAX_MUTEXES", (long)TestMutex2Index); UtAssert_True(TestMutex1Index != TestMutex2Index, "TestMutex1Index(%lu) != TestMutex2Index(%lu)", (long)TestMutex1Index, (long)TestMutex2Index); UtAssert_INT32_EQ(OS_ConvertToArrayIndex(time_base_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TIMEBASES, - "0 < TestArrayIndex(%lu) <= OS_MAX_TIMEBASES", (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_TIMEBASES, "TestArrayIndex(%lu) < OS_MAX_TIMEBASES", (long)TestArrayIndex); /* * Test with extreme cases using invalid inputs and checking @@ -249,40 +244,35 @@ void Test_OS_ObjectIdToArrayIndex(void) * Test case for: * int32 OS_ObjectIdToArrayIndex(osal_objtype_t idtype, osal_id_t object_id, osal_index_t *ArrayIndex); */ - osal_index_t TestArrayIndex; - osal_index_t TestMutex1Index; - osal_index_t TestMutex2Index; + osal_index_t TestArrayIndex = OSAL_INDEX_C(0); + osal_index_t TestMutex1Index = OSAL_INDEX_C(0); + osal_index_t TestMutex2Index = OSAL_INDEX_C(0); /* Test with nominal (correct) object types */ UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, task_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TASKS, "0 < TestArrayIndex(%lu) <= OS_MAX_TASKS", - (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_TASKS, "TestArrayIndex(%lu) < OS_MAX_TASKS", (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_QUEUE, queue_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_QUEUES, "0 < TestArrayIndex(%lu) <= OS_MAX_QUEUES", - (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_QUEUES, "TestArrayIndex(%lu) < OS_MAX_QUEUES", (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_COUNTSEM, count_sem_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_COUNT_SEMAPHORES, - "0 < TestArrayIndex(%lu) <= OS_MAX_COUNT_SEMAPHORES", (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_COUNT_SEMAPHORES, "TestArrayIndex(%lu) < OS_MAX_COUNT_SEMAPHORES", + (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_BINSEM, bin_sem_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_BIN_SEMAPHORES, - "0 < TestArrayIndex(%lu) <= OS_MAX_BIN_SEMAPHORES", (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_BIN_SEMAPHORES, "TestArrayIndex(%lu) < OS_MAX_BIN_SEMAPHORES", + (long)TestArrayIndex); UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_MUTEX, mutex_id1, &TestMutex1Index), OS_SUCCESS); - UtAssert_True(TestMutex1Index >= 0 && TestMutex1Index < OS_MAX_MUTEXES, - "0 < TestMutex1Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex1Index); + UtAssert_True(TestMutex1Index < OS_MAX_MUTEXES, "TestMutex1Index(%lu) < OS_MAX_MUTEXES", (long)TestMutex1Index); UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_MUTEX, mutex_id2, &TestMutex2Index), OS_SUCCESS); - UtAssert_True(TestMutex2Index >= 0 && TestMutex2Index < OS_MAX_MUTEXES, - "0 < TestMutex2Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex2Index); + UtAssert_True(TestMutex2Index < OS_MAX_MUTEXES, "TestMutex2Index(%lu) < OS_MAX_MUTEXES", (long)TestMutex2Index); UtAssert_True(TestMutex1Index != TestMutex2Index, "TestMutex1Index(%lu) != TestMutex2Index(%lu)", (long)TestMutex1Index, (long)TestMutex2Index); UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TIMEBASE, time_base_id, &TestArrayIndex), OS_SUCCESS); - UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TIMEBASES, - "0 < TestArrayIndex(%lu) <= OS_MAX_TIMEBASES", (long)TestArrayIndex); + UtAssert_True(TestArrayIndex < OS_MAX_TIMEBASES, "TestArrayIndex(%lu) < OS_MAX_TIMEBASES", (long)TestArrayIndex); /* Check cases where the object type and the ID are _not_ matched */ UtAssert_INT32_EQ(OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_QUEUE, task_id, &TestArrayIndex), OS_ERR_INVALID_ID); @@ -403,6 +393,8 @@ void Test_OS_GetResourceName(void) */ char name[OS_MAX_API_NAME]; + memset(name, 0, sizeof(name)); + /* Nominal cases */ UtAssert_INT32_EQ(OS_GetResourceName(queue_id, name, sizeof(name)), OS_SUCCESS); UtAssert_StrCmp(name, "Queue", "%s == %s", name, "Queue"); diff --git a/src/tests/network-api-test/network-api-test.c b/src/tests/network-api-test/network-api-test.c index 29968f2d6..25f04197f 100644 --- a/src/tests/network-api-test/network-api-test.c +++ b/src/tests/network-api-test/network-api-test.c @@ -121,7 +121,7 @@ void TestNetworkApiBadArgs(void) void TestNetworkApiInet6(void) { - osal_id_t socket_id; + osal_id_t socket_id = OS_OBJECT_ID_UNDEFINED; OS_SockAddr_t addr; int32 actual; @@ -228,16 +228,22 @@ void TestDatagramNetworkApi(void) char AddrBuffer2[32]; char AddrBuffer3[32]; char AddrBuffer4[32]; - uint32 Buf1 = 111; - uint32 Buf2 = 000; - uint32 Buf3 = 222; - uint32 Buf4 = 000; - osal_id_t objid; + uint32 Buf1 = 111; + uint32 Buf2 = 0; + uint32 Buf3 = 222; + uint32 Buf4 = 0; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; osal_id_t invalid_fd; - uint16 PortNum; + uint16 PortNum = 0; OS_socket_prop_t prop; OS_SockAddr_t l_addr; + memset(AddrBuffer1, 0, sizeof(AddrBuffer1)); + memset(AddrBuffer2, 0, sizeof(AddrBuffer2)); + memset(AddrBuffer3, 0, sizeof(AddrBuffer3)); + memset(AddrBuffer4, 0, sizeof(AddrBuffer4)); + memset(&prop, 0, sizeof(prop)); + if (!networkImplemented) { UtAssert_NA("Network API not implemented"); diff --git a/src/tests/osal-core-test/osal-core-test.c b/src/tests/osal-core-test/osal-core-test.c index be7abb3c1..9d175652f 100644 --- a/src/tests/osal-core-test/osal-core-test.c +++ b/src/tests/osal-core-test/osal-core-test.c @@ -618,6 +618,8 @@ void TestGenericQueries(void) TestCallbackState_t State; char ResourceName[OS_MAX_API_NAME]; + memset(ResourceName, 0, sizeof(ResourceName)); + status = OS_TaskCreate(&task_0_id, "Task 0", task_generic_no_exit, OSAL_STACKPTR_C(task_0_stack), sizeof(task_0_stack), OSAL_PRIORITY_C(TASK_0_PRIORITY), 0); UtAssert_True(status == OS_SUCCESS, "OS_TaskCreate (%ld) == OS_SUCCESS", (long)status); diff --git a/src/tests/queue-test/queue-test.c b/src/tests/queue-test/queue-test.c index 3d54c377e..d2101a3d5 100644 --- a/src/tests/queue-test/queue-test.c +++ b/src/tests/queue-test/queue-test.c @@ -65,8 +65,8 @@ void task_1(void) { int32 status; size_t data_size; - uint32 data_received; - uint32 expected = 0; + uint32 data_received = 0; + uint32 expected = 0; OS_printf("Starting task 1\n"); @@ -134,7 +134,7 @@ void QueueTimeoutCheck(void) void QueueTimeoutSetup(void) { int32 status; - uint32 accuracy; + uint32 accuracy = 0; task_1_failures = 0; task_1_messages = 0; @@ -193,7 +193,7 @@ void QueueMessageCheck(void) void QueueMessageSetup(void) { int32 status; - uint32 accuracy; + uint32 accuracy = 0; int i; uint32 Data = 0; task_1_failures = 0; diff --git a/src/tests/select-test/select-test.c b/src/tests/select-test/select-test.c index 15c462164..505f7354b 100644 --- a/src/tests/select-test/select-test.c +++ b/src/tests/select-test/select-test.c @@ -64,6 +64,8 @@ void BinSemSetup(void) { OS_bin_sem_prop_t bin_sem_prop; + memset(&bin_sem_prop, 0, sizeof(bin_sem_prop)); + /* * Create the binary semaphore * BinSem1 is used to control when the server can accept connections @@ -165,7 +167,7 @@ bool FillOutputBuffer(osal_id_t conn_id) void Server_Fn(void) { - osal_id_t connsock_id; + osal_id_t connsock_id = OS_OBJECT_ID_UNDEFINED; OS_SockAddr_t addr; /* Accept incoming connections */ @@ -177,7 +179,7 @@ void Server_Fn(void) void Server_Fn2(void) { - osal_id_t connsock_id; + osal_id_t connsock_id = OS_OBJECT_ID_UNDEFINED; OS_SockAddr_t addr; /* Accept incoming connections */ diff --git a/src/tests/shell-test/shell-test.c b/src/tests/shell-test/shell-test.c index 49d07f780..359175734 100644 --- a/src/tests/shell-test/shell-test.c +++ b/src/tests/shell-test/shell-test.c @@ -59,7 +59,7 @@ void TestOutputToFile(void) size_t size; int32 filepos; int32 status; - osal_id_t fd; + osal_id_t fd = OS_OBJECT_ID_UNDEFINED; OS_mkfs(NULL, "/ramdev0", "RAM", 512, 20); OS_mount("/ramdev0", "/drive0"); diff --git a/src/tests/symbol-api-test/symbol-api-test.c b/src/tests/symbol-api-test/symbol-api-test.c index 43905b814..99cd8c40b 100644 --- a/src/tests/symbol-api-test/symbol-api-test.c +++ b/src/tests/symbol-api-test/symbol-api-test.c @@ -31,7 +31,7 @@ void TestSymbolApi(void) { int32 status; - cpuaddr SymAddress; + cpuaddr SymAddress = 0; /* Make the file system */ status = OS_mkfs(0, "/ramdev0", "RAM", 512, 2048); 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 fb6eae488..ee0652ecb 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 @@ -69,8 +69,8 @@ void TestTimeBaseApi(void) uint32 freerun; osal_id_t objid; osal_id_t badid; - osal_id_t time_base_id; - osal_id_t time_base_id2; + osal_id_t time_base_id = OS_OBJECT_ID_UNDEFINED; + osal_id_t time_base_id2 = OS_OBJECT_ID_UNDEFINED; osal_id_t tb_id[OS_MAX_TIMEBASES]; char timebase_name[OS_MAX_API_NAME + 5]; OS_timebase_prop_t timebase_prop; @@ -201,8 +201,6 @@ void TestTimeBaseApi(void) (unsigned long)timebase_prop.nominal_interval_time); UtAssert_True(timebase_prop.freerun_time == 0, "timebase_prop.freerun_time (%lu) == 0", (unsigned long)timebase_prop.freerun_time); - UtAssert_True(timebase_prop.accuracy >= 0, "timebase_prop.accuracy (%lu) >= 0", - (unsigned long)timebase_prop.accuracy); /* Test for invalid inputs */ UtAssert_INT32_EQ(OS_TimeBaseGetInfo(OS_OBJECT_ID_UNDEFINED, &timebase_prop), OS_ERR_INVALID_ID); diff --git a/src/tests/timer-add-api-test/timer-add-api-test.c b/src/tests/timer-add-api-test/timer-add-api-test.c index 327f6516f..9c661a185 100644 --- a/src/tests/timer-add-api-test/timer-add-api-test.c +++ b/src/tests/timer-add-api-test/timer-add-api-test.c @@ -66,8 +66,8 @@ void TestTimerAddApi(void) uint32 expected; osal_id_t badid; osal_id_t timer_id; - osal_id_t time_base_id; - int i = 0; + osal_id_t time_base_id = OS_OBJECT_ID_UNDEFINED; + int i = 0; int32 TimerStatus[NUMBER_OF_TIMERS]; osal_id_t TimerID[OS_MAX_TIMERS]; char temp_name[OS_MAX_API_NAME + 5]; @@ -85,6 +85,7 @@ void TestTimerAddApi(void) for (i = 0; i < OS_MAX_TIMERS; i++) { + TimerID[i] = OS_OBJECT_ID_UNDEFINED; snprintf(temp_name, sizeof(temp_name), "Timer%d", i); UtAssert_INT32_EQ(OS_TimerAdd(&TimerID[i], temp_name, time_base_id, &null_func, NULL), OS_SUCCESS); UtPrintf("Timer %d Created ID=%lx", i, OS_ObjectIdToInteger(TimerID[i])); diff --git a/src/tests/timer-test/timer-test.c b/src/tests/timer-test/timer-test.c index 356a661c3..3f37dd8ac 100644 --- a/src/tests/timer-test/timer-test.c +++ b/src/tests/timer-test/timer-test.c @@ -57,7 +57,7 @@ uint32 timer_idlookup[OS_MAX_TIMERS]; */ void test_func(osal_id_t timer_id) { - osal_index_t idx; + osal_index_t idx = OSAL_INDEX_C(0); OS_ConvertToArrayIndex(timer_id, &idx); timer_counter[timer_idlookup[idx]]++; } @@ -114,10 +114,12 @@ void TimerTestTask(void) int i = 0; int32 TimerStatus[NUMBER_OF_TIMERS]; - osal_index_t TableId; + osal_index_t TableId = OSAL_INDEX_C(0); osal_id_t TimerID[NUMBER_OF_TIMERS]; char TimerName[NUMBER_OF_TIMERS][20] = {"TIMER1", "TIMER2", "TIMER3", "TIMER4", "TIMER5"}; - uint32 ClockAccuracy; + uint32 ClockAccuracy = 0; + + memset(TimerID, 0, sizeof(TimerID)); for (i = 0; i < NUMBER_OF_TIMERS && i < OS_MAX_TIMERS; i++) { diff --git a/src/unit-test-coverage/shared/src/coveragetest-binsem.c b/src/unit-test-coverage/shared/src/coveragetest-binsem.c index 87cb1e7a3..d8df019ca 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-binsem.c +++ b/src/unit-test-coverage/shared/src/coveragetest-binsem.c @@ -49,7 +49,7 @@ void Test_OS_BinSemCreate(void) * int32 OS_BinSemCreate (uint32 *sem_id, const char *sem_name, * uint32 sem_initial_value, uint32 options) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; OSAPI_TEST_FUNCTION_RC(OS_BinSemCreate(&objid, "UT", 0, 0), OS_SUCCESS); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); @@ -131,7 +131,7 @@ void Test_OS_BinSemGetIdByName(void) */ int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_BinSemGetIdByName(&objid, "UT"); @@ -157,6 +157,8 @@ void Test_OS_BinSemGetInfo(void) int32 actual = ~OS_SUCCESS; OS_bin_sem_prop_t prop; + memset(&prop, 0, sizeof(prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_BINSEM, UT_INDEX_1, "ABC", UT_OBJID_OTHER); actual = OS_BinSemGetInfo(UT_OBJID_1, &prop); diff --git a/src/unit-test-coverage/shared/src/coveragetest-countsem.c b/src/unit-test-coverage/shared/src/coveragetest-countsem.c index d6cfd21fb..87d570956 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/shared/src/coveragetest-countsem.c @@ -49,7 +49,7 @@ void Test_OS_CountSemCreate(void) * int32 OS_CountSemCreate (uint32 *sem_id, const char *sem_name, * uint32 sem_initial_value, uint32 options) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; OSAPI_TEST_FUNCTION_RC(OS_CountSemCreate(&objid, "UT", 0, 0), OS_SUCCESS); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); @@ -119,7 +119,7 @@ void Test_OS_CountSemGetIdByName(void) */ int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); actual = OS_CountSemGetIdByName(&objid, "UT"); @@ -145,6 +145,8 @@ void Test_OS_CountSemGetInfo(void) int32 actual = ~OS_SUCCESS; OS_count_sem_prop_t prop; + memset(&prop, 0, sizeof(prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_COUNTSEM, UT_INDEX_1, "ABC", UT_OBJID_OTHER); actual = OS_CountSemGetInfo(UT_OBJID_1, &prop); diff --git a/src/unit-test-coverage/shared/src/coveragetest-dir.c b/src/unit-test-coverage/shared/src/coveragetest-dir.c index 1f3449fe8..2d6830359 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-dir.c +++ b/src/unit-test-coverage/shared/src/coveragetest-dir.c @@ -58,7 +58,7 @@ void Test_OS_DirectoryOpen(void) * Test Case For: * int32 OS_DirectoryOpen(uint32 *dir_id, const char *path) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; OSAPI_TEST_FUNCTION_RC(OS_DirectoryOpen(&objid, "Dir"), OS_SUCCESS); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); diff --git a/src/unit-test-coverage/shared/src/coveragetest-errors.c b/src/unit-test-coverage/shared/src/coveragetest-errors.c index e38f82e4d..f6d9ffa9c 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-errors.c +++ b/src/unit-test-coverage/shared/src/coveragetest-errors.c @@ -33,6 +33,8 @@ void Test_OS_GetErrorName(void) */ os_err_name_t err_name; + memset(&err_name, 0, sizeof(err_name)); + OSAPI_TEST_FUNCTION_RC(OS_GetErrorName(OS_ERROR, &err_name), OS_SUCCESS); UtAssert_True(strcmp(err_name, "OS_ERROR") == 0, "string(%s) == OS_ERROR", err_name); diff --git a/src/unit-test-coverage/shared/src/coveragetest-file.c b/src/unit-test-coverage/shared/src/coveragetest-file.c index d12f31feb..96bf1eb53 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-file.c +++ b/src/unit-test-coverage/shared/src/coveragetest-file.c @@ -304,6 +304,8 @@ void Test_OS_FDGetInfo(void) */ OS_file_prop_t file_prop; + memset(&file_prop, 0, sizeof(file_prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_STREAM, UT_INDEX_1, "ABC", UT_OBJID_OTHER); OSAPI_TEST_FUNCTION_RC(OS_FDGetInfo(UT_OBJID_1, &file_prop), OS_SUCCESS); UtAssert_True(strcmp(file_prop.Path, "ABC") == 0, "file_prop.Path (%s) == ABC", file_prop.Path); diff --git a/src/unit-test-coverage/shared/src/coveragetest-filesys.c b/src/unit-test-coverage/shared/src/coveragetest-filesys.c index 1b83754a2..1952788af 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/shared/src/coveragetest-filesys.c @@ -260,6 +260,8 @@ void Test_OS_FileSysStatVolume(void) int32 expected; int32 actual; + memset(&statbuf, 0, sizeof(statbuf)); + statref.block_size = OSAL_SIZE_C(1024); statref.blocks_free = OSAL_BLOCKCOUNT_C(1111); statref.total_blocks = OSAL_BLOCKCOUNT_C(2222); @@ -374,6 +376,8 @@ void Test_OS_GetFsInfo(void) os_fsinfo_t filesys_info; OS_common_record_t rec; + memset(&filesys_info, 0, sizeof(filesys_info)); + UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdIteratorGetNext), 1); UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdIteratorGetNext), 3, 0); UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdIteratorGetNext), 4, 0); @@ -415,6 +419,8 @@ void Test_OS_TranslatePath(void) int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; + memset(LocalBuffer, 0, sizeof(LocalBuffer)); + /* Set up the local record for success */ OS_filesys_table[1].flags = OS_FILESYS_FLAG_IS_READY | OS_FILESYS_FLAG_IS_MOUNTED_SYSTEM | OS_FILESYS_FLAG_IS_MOUNTED_VIRTUAL; diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index 65a258046..ae992f2eb 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -336,6 +336,8 @@ void Test_OS_ObjectIdGetBySearch(void) int32 actual; OS_object_token_t token; + memset(&token, 0, sizeof(token)); + OS_global_task_table[0].active_id = UT_OBJID_OTHER; actual = OS_ObjectIdGetBySearch(OS_LOCK_MODE_NONE, OS_OBJECT_TYPE_OS_TASK, TestAlwaysMatch, NULL, &token); expected = OS_SUCCESS; @@ -426,9 +428,9 @@ void Test_OS_ObjectIdToArrayIndex(void) * which is out of range. */ osal_id_t objid; - osal_index_t local_idx; - int32 expected = OS_SUCCESS; - int32 actual = ~OS_SUCCESS; + osal_index_t local_idx = OSAL_INDEX_C(0); + int32 expected = OS_SUCCESS; + int32 actual = ~OS_SUCCESS; /* need to get a "valid" objid for the nominal case */ OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TASK, 1, &objid); @@ -507,11 +509,13 @@ void Test_OS_ObjectIdGetById(void) int32 actual = ~OS_SUCCESS; int32 expected = OS_SUCCESS; osal_id_t refobjid; - osal_index_t local_idx; - OS_common_record_t *rptr = NULL; + osal_index_t local_idx = OSAL_INDEX_C(0); + OS_common_record_t *rptr = NULL; OS_object_token_t token1; OS_object_token_t token2; + memset(&token1, 0, sizeof(token1)); + /* verify that the call returns ERROR when not initialized */ OS_SharedGlobalVars.GlobalState = 0; actual = OS_ObjectIdGetById(OS_LOCK_MODE_NONE, 0, OS_OBJECT_ID_UNDEFINED, &token1); @@ -733,6 +737,8 @@ void Test_OS_ObjectIdAllocateNew(void) int32 actual = ~OS_SUCCESS; OS_object_token_t token; + memset(&token, 0, sizeof(token)); + actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, "UT_alloc", &token); /* Verify Outputs */ @@ -792,7 +798,7 @@ void Test_OS_ConvertToArrayIndex(void) int32 expected = OS_SUCCESS; int32 actual; osal_id_t refobjid; - osal_index_t local_idx; + osal_index_t local_idx = OSAL_INDEX_C(0); /* Need a valid ID to work with */ OS_ObjectIdCompose_Impl(OS_OBJECT_TYPE_OS_TASK, 1234, &refobjid); @@ -1065,6 +1071,8 @@ void Test_OS_GetResourceName(void) OS_common_record_t *rptr; char NameBuffer[OS_MAX_API_NAME]; + memset(NameBuffer, 0, sizeof(NameBuffer)); + /* * Set up for the OS_GetResourceName function to return success */ @@ -1150,6 +1158,8 @@ void Test_OS_ObjectIDInteger(void) osal_objtype_t idtype; char str[OS_MAX_API_NAME]; + memset(&token, 0, sizeof(token)); + for (idtype = 0; idtype < OS_OBJECT_TYPE_USER; ++idtype) { actual = OS_SUCCESS; diff --git a/src/unit-test-coverage/shared/src/coveragetest-module.c b/src/unit-test-coverage/shared/src/coveragetest-module.c index d689d397b..a50c47a90 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-module.c +++ b/src/unit-test-coverage/shared/src/coveragetest-module.c @@ -65,7 +65,7 @@ void Test_OS_ModuleLoad(void) * Test Case For: * int32 OS_ModuleLoad ( uint32 *module_id, const char *module_name, const char *filename ) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; OSAPI_TEST_FUNCTION_RC(OS_ModuleLoad(&objid, "UT", "File", OS_MODULE_FLAG_GLOBAL_SYMBOLS), OS_SUCCESS); UtAssert_STUB_COUNT(OS_ModuleLoad_Impl, 1); @@ -202,7 +202,7 @@ void Test_OS_StaticSymbolLookup(void) */ int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; - cpuaddr addr; + cpuaddr addr = 0; /* nominal */ actual = OS_SymbolLookup_Static(&addr, "UT_staticsym", NULL); @@ -268,6 +268,8 @@ void Test_OS_ModuleGetInfo(void) */ OS_module_prop_t module_prop; + memset(&module_prop, 0, sizeof(module_prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_MODULE, UT_INDEX_1, "ABC", UT_OBJID_OTHER); strncpy(OS_module_table[1].file_name, "DEF", sizeof(OS_module_table[1].file_name)); diff --git a/src/unit-test-coverage/shared/src/coveragetest-mutex.c b/src/unit-test-coverage/shared/src/coveragetest-mutex.c index 4ccf9b26e..1419b30b2 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-mutex.c +++ b/src/unit-test-coverage/shared/src/coveragetest-mutex.c @@ -48,7 +48,7 @@ void Test_OS_MutSemCreate(void) * Test Case For: * int32 OS_MutSemCreate (uint32 *sem_id, const char *sem_name, uint32 options) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; OSAPI_TEST_FUNCTION_RC(OS_MutSemCreate(&objid, "UT", 0), OS_SUCCESS); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); @@ -132,7 +132,7 @@ void Test_OS_MutSemGetIdByName(void) * Test Case For: * int32 OS_MutSemGetIdByName (uint32 *sem_id, const char *sem_name) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdFindByName), OS_SUCCESS); OSAPI_TEST_FUNCTION_RC(OS_MutSemGetIdByName(&objid, "UT"), OS_SUCCESS); @@ -153,6 +153,8 @@ void Test_OS_MutSemGetInfo(void) */ OS_mut_sem_prop_t prop; + memset(&prop, 0, sizeof(prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_MUTEX, UT_INDEX_1, "ABC", UT_OBJID_OTHER); OSAPI_TEST_FUNCTION_RC(OS_MutSemGetInfo(UT_OBJID_1, &prop), OS_SUCCESS); diff --git a/src/unit-test-coverage/shared/src/coveragetest-queue.c b/src/unit-test-coverage/shared/src/coveragetest-queue.c index 50db7f370..f7ddbef9e 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-queue.c +++ b/src/unit-test-coverage/shared/src/coveragetest-queue.c @@ -159,9 +159,9 @@ void Test_OS_QueueGetInfo(void) * int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop) */ OS_queue_prop_t queue_prop; - osal_id_t id; + osal_id_t id = UT_OBJID_OTHER; - id = UT_OBJID_OTHER; + memset(&queue_prop, 0, sizeof(queue_prop)); OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_QUEUE, UT_INDEX_1, "ABC", UT_OBJID_OTHER); diff --git a/src/unit-test-coverage/shared/src/coveragetest-sockets.c b/src/unit-test-coverage/shared/src/coveragetest-sockets.c index eab2448cd..ceeebf08c 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-sockets.c +++ b/src/unit-test-coverage/shared/src/coveragetest-sockets.c @@ -90,7 +90,7 @@ void Test_OS_SocketOpen(void) * Test Case For: * int32 OS_SocketOpen(uint32 *sock_id, OS_SocketDomain_t Domain, OS_SocketType_t Type) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; OSAPI_TEST_FUNCTION_RC(OS_SocketOpen(&objid, OS_SocketDomain_INET, OS_SocketType_STREAM), OS_SUCCESS); OSAPI_TEST_OBJID(objid, !=, OS_OBJECT_ID_UNDEFINED); @@ -418,7 +418,7 @@ void Test_OS_SocketGetIdByName(void) * Test Case For: * int32 OS_SocketGetIdByName (uint32 *sock_id, const char *sock_name) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdFindByName), 1, OS_SUCCESS); OSAPI_TEST_FUNCTION_RC(OS_SocketGetIdByName(&objid, "UT"), OS_SUCCESS); @@ -443,6 +443,8 @@ void Test_OS_SocketGetInfo(void) */ OS_socket_prop_t prop; + memset(&prop, 0, sizeof(prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_STREAM, UT_INDEX_1, "ABC", UT_OBJID_OTHER); OSAPI_TEST_FUNCTION_RC(OS_SocketGetInfo(UT_OBJID_1, &prop), OS_SUCCESS); diff --git a/src/unit-test-coverage/shared/src/coveragetest-task.c b/src/unit-test-coverage/shared/src/coveragetest-task.c index 338cabea4..df09d3d99 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-task.c +++ b/src/unit-test-coverage/shared/src/coveragetest-task.c @@ -96,7 +96,7 @@ void Test_OS_TaskCreate(void) * int32 OS_TaskCreate (uint32 *task_id, const char *task_name, osal_task_entry function_pointer, * uint32 *stack_pointer, uint32 stack_size, uint32 priority, uint32 flags) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; OSAPI_TEST_FUNCTION_RC( OS_TaskCreate(&objid, "UT", UT_TestHook, OSAL_TASK_STACK_ALLOCATE, OSAL_SIZE_C(128), OSAL_PRIORITY_C(0), 0), @@ -235,6 +235,8 @@ void Test_OS_TaskGetInfo(void) */ OS_task_prop_t task_prop; + memset(&task_prop, 0, sizeof(task_prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_TASK, UT_INDEX_1, "ABC", UT_OBJID_OTHER); OS_task_table[1].stack_size = OSAL_SIZE_C(222); OS_task_table[1].priority = OSAL_PRIORITY_C(133); diff --git a/src/unit-test-coverage/shared/src/coveragetest-time.c b/src/unit-test-coverage/shared/src/coveragetest-time.c index 034e5fd32..76accad47 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-time.c +++ b/src/unit-test-coverage/shared/src/coveragetest-time.c @@ -100,8 +100,8 @@ void Test_OS_TimerCreate(void) * Test Case For: * int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, uint32 *accuracy, OS_TimerCallback_t callback_ptr) */ - osal_id_t objid = OS_OBJECT_ID_UNDEFINED; - osal_index_t local_id; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; + osal_index_t local_id = OSAL_INDEX_C(0); uint32 accuracy = 0xFFFFFFFF; OSAPI_TEST_FUNCTION_RC(OS_TimerCreate(&objid, "UT", &accuracy, UT_TimerCallback), OS_SUCCESS); @@ -169,13 +169,15 @@ void Test_OS_TimerDelete(void) * Test Case For: * int32 OS_TimerDelete(uint32 timer_id) */ - osal_id_t timebase_id; - osal_id_t timer_objid_1; - osal_id_t timer_objid_2; + osal_id_t timebase_id = OS_OBJECT_ID_UNDEFINED; + osal_id_t timer_objid_1 = OS_OBJECT_ID_UNDEFINED; + osal_id_t timer_objid_2 = OS_OBJECT_ID_UNDEFINED; OS_timebase_internal_record_t *timebase; OS_object_token_t timebase_token; uint32 accuracy; + memset(&timebase_token, 0, sizeof(timebase_token)); + /* The ObjIds in the ring need to match what will be in the token */ /* Get a "timebase" from the stub so the objid will validate */ OS_TimeBaseCreate(&timebase_id, "ut", NULL); @@ -260,6 +262,8 @@ void Test_OS_TimerGetInfo(void) */ OS_timer_prop_t timer_prop; + memset(&timer_prop, 0, sizeof(timer_prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_TIMECB, UT_INDEX_1, "ABC", UT_OBJID_OTHER); OS_timecb_table[1].interval_time = 2222; diff --git a/src/unit-test-coverage/shared/src/coveragetest-timebase.c b/src/unit-test-coverage/shared/src/coveragetest-timebase.c index 854309e2a..d25cbd88e 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/shared/src/coveragetest-timebase.c @@ -144,7 +144,7 @@ void Test_OS_TimeBaseGetIdByName(void) * Test Case For: * int32 OS_TimeBaseGetIdByName (uint32 *timer_id, const char *timebase_name) */ - osal_id_t objid; + osal_id_t objid = OS_OBJECT_ID_UNDEFINED; UT_SetDeferredRetcode(UT_KEY(OS_ObjectIdFindByName), 1, OS_SUCCESS); OSAPI_TEST_FUNCTION_RC(OS_TimeBaseGetIdByName(&objid, "UT"), OS_SUCCESS); @@ -171,6 +171,8 @@ void Test_OS_TimeBaseGetInfo(void) */ OS_timebase_prop_t timebase_prop; + memset(&timebase_prop, 0, sizeof(timebase_prop)); + OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_TIMEBASE, UT_INDEX_1, "ABC", UT_OBJID_OTHER); OS_timebase_table[1].nominal_interval_time = 2222; @@ -224,6 +226,9 @@ void Test_OS_TimeBase_CallbackThread(void) OS_object_token_t timecb_token; OS_object_token_t timecb_token2; + memset(&timecb_token, 0, sizeof(timecb_token)); + memset(&timecb_token2, 0, sizeof(timecb_token2)); + recptr = &OS_global_timebase_table[2]; memset(recptr, 0, sizeof(*recptr)); recptr->active_id = UT_OBJID_2; @@ -284,7 +289,7 @@ void Test_OS_Milli2Ticks(void) * int32 OS_Milli2Ticks(uint32 milli_seconds) */ uint32 msec; - int ticks; + int ticks = 0; int expected; msec = 5678; diff --git a/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c index 452233cd9..aadc1e957 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-stat-stubs.c @@ -56,7 +56,7 @@ int OCS_stat(const char *file, struct OCS_stat *buf) Status = UT_DEFAULT_IMPL(OCS_stat); - if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_stat), buf, sizeof(*buf)) < sizeof(*buf)) + if (UT_Stub_CopyToLocal(UT_KEY(OCS_stat), buf, sizeof(*buf)) < sizeof(*buf)) { memset(buf, 0, sizeof(*buf)); } @@ -70,7 +70,7 @@ int OCS_fstat(int fd, struct OCS_stat *buf) Status = UT_DEFAULT_IMPL(OCS_fstat); - if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_fstat), buf, sizeof(*buf)) < sizeof(*buf)) + if (UT_Stub_CopyToLocal(UT_KEY(OCS_fstat), buf, sizeof(*buf)) < sizeof(*buf)) { memset(buf, 0, sizeof(*buf)); } @@ -84,7 +84,7 @@ int OCS_statvfs(const char *file, struct OCS_statvfs *buf) Status = UT_DEFAULT_IMPL(OCS_statvfs); - if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_statvfs), buf, sizeof(*buf)) < sizeof(*buf)) + if (UT_Stub_CopyToLocal(UT_KEY(OCS_statvfs), buf, sizeof(*buf)) < sizeof(*buf)) { memset(buf, 0, sizeof(*buf)); } diff --git a/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c b/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c index c8c16c367..c76e4b6b7 100644 --- a/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/posix-time-stubs.c @@ -38,7 +38,7 @@ int OCS_clock_gettime(OCS_clockid_t clock_id, struct OCS_timespec *tp) Status = UT_DEFAULT_IMPL(OCS_clock_gettime); - if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_clock_gettime), tp, sizeof(*tp)) < sizeof(*tp)) + if (UT_Stub_CopyToLocal(UT_KEY(OCS_clock_gettime), tp, sizeof(*tp)) < sizeof(*tp)) { memset(tp, 0, sizeof(*tp)); } @@ -101,7 +101,7 @@ int OCS_timer_gettime(OCS_timer_t timerid, struct OCS_itimerspec *value) Status = UT_DEFAULT_IMPL(OCS_timer_gettime); - if (Status == 0 && UT_Stub_CopyToLocal(UT_KEY(OCS_timer_gettime), value, sizeof(*value)) < sizeof(*value)) + if (UT_Stub_CopyToLocal(UT_KEY(OCS_timer_gettime), value, sizeof(*value)) < sizeof(*value)) { memset(value, 0, sizeof(*value)); } diff --git a/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c b/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c index 761f244dc..3da610b80 100644 --- a/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/vxworks-memPartLib-stubs.c @@ -30,6 +30,7 @@ OCS_STATUS OCS_memPartShow(OCS_PART_ID partId, int type) OCS_STATUS OCS_memPartInfoGet(OCS_PART_ID partId, OCS_MEM_PART_STATS *ppartStats) { + memset(ppartStats, 0, sizeof(*ppartStats)); return (UT_DEFAULT_IMPL(OCS_memPartInfoGet)); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c index d1583d63f..c620c9545 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-countsem.c @@ -124,7 +124,7 @@ void Osapi_Test_Setup(void) UT_ResetState(0); memset(OS_count_sem_table, 0, sizeof(OS_count_sem_table)); - memset(OS_global_count_sem_table, 0, sizeof(OS_common_record_t) * OS_MAX_BIN_SEMAPHORES); + memset(OS_global_count_sem_table, 0, sizeof(OS_common_record_t) * OS_MAX_COUNT_SEMAPHORES); memset(UT_Ref_OS_impl_count_sem_table, 0, UT_Ref_OS_impl_count_sem_table_SIZE); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-network.c b/src/unit-test-coverage/vxworks/src/coveragetest-network.c index 107ae5ae4..c66694db0 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-network.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-network.c @@ -59,7 +59,7 @@ void Test_OS_NetworkGetID_Impl(void) * Test Case For: * int32 OS_NetworkGetID_Impl (int32 *IdBuf) */ - int32 IdBuf; + int32 IdBuf = 0; UT_SetDefaultReturnValue(UT_KEY(OCS_hostGetByName), 1234); OSAPI_TEST_FUNCTION_RC(OS_NetworkGetID_Impl(&IdBuf), OS_SUCCESS); diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c index 11c02824f..e04c70805 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-timebase.c @@ -287,7 +287,7 @@ void Osapi_Test_Setup(void) UT_ResetState(0); memset(OS_timebase_table, 0, sizeof(OS_timebase_table)); - memset(OS_global_timebase_table, 0, sizeof(OS_common_record_t) * OS_MAX_BIN_SEMAPHORES); + memset(OS_global_timebase_table, 0, sizeof(OS_common_record_t) * OS_MAX_TIMEBASES); memset(UT_Ref_OS_impl_timebase_table, 0, UT_Ref_OS_impl_timebase_table_SIZE); } diff --git a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c index 9bd5f1585..83f5f49d7 100644 --- a/src/unit-tests/oscore-test/ut_oscore_binsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_binsem_test.c @@ -70,6 +70,8 @@ void UT_os_bin_sem_create_test() char long_sem_name[UT_OS_NAME_BUFF_SIZE]; osal_id_t sem_ids[OS_MAX_BIN_SEMAPHORES + 1]; + memset(sem_ids, 0, sizeof(sem_ids)); + /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemCreate(NULL, "BinSem1", 1, 0), OS_INVALID_POINTER); @@ -128,7 +130,7 @@ void UT_os_bin_sem_create_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_delete_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemDelete(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID); @@ -152,7 +154,7 @@ void UT_os_bin_sem_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_flush_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemFlush(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID); @@ -177,7 +179,7 @@ void UT_os_bin_sem_flush_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_give_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemGive(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID); @@ -203,7 +205,7 @@ void UT_os_bin_sem_give_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_take_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemTake(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID); @@ -228,7 +230,7 @@ void UT_os_bin_sem_take_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_timed_wait_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ UT_RETVAL(OS_BinSemTimedWait(UT_OBJID_INCORRECT, 1000), OS_ERR_INVALID_ID); @@ -261,7 +263,7 @@ void UT_os_bin_sem_timed_wait_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_get_id_by_name_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ @@ -297,7 +299,7 @@ void UT_os_bin_sem_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_bin_sem_get_info_test() { - osal_id_t bin_sem_id; + osal_id_t bin_sem_id = OS_OBJECT_ID_UNDEFINED; OS_bin_sem_prop_t bin_sem_prop; /*-----------------------------------------------------*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c index 39c4bef9c..70138304c 100644 --- a/src/unit-tests/oscore-test/ut_oscore_countsem_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_countsem_test.c @@ -70,6 +70,8 @@ void UT_os_count_sem_create_test() char sem_name[UT_OS_NAME_BUFF_SIZE]; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; + memset(count_sem_ids, 0, sizeof(count_sem_ids)); + /*-----------------------------------------------------*/ /* #1 Null-pointer-arg-1 */ @@ -155,7 +157,7 @@ void UT_os_count_sem_create_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_delete_test() { - osal_id_t count_sem_id; + osal_id_t count_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -184,7 +186,7 @@ void UT_os_count_sem_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_give_test() { - osal_id_t count_sem_id; + osal_id_t count_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -215,7 +217,7 @@ void UT_os_count_sem_give_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_take_test() { - osal_id_t count_sem_id; + osal_id_t count_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -245,7 +247,7 @@ void UT_os_count_sem_take_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_timed_wait_test() { - osal_id_t count_sem_id; + osal_id_t count_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -289,7 +291,7 @@ void UT_os_count_sem_timed_wait_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_get_id_by_name_test() { - osal_id_t count_sem_id; + osal_id_t count_sem_id = OS_OBJECT_ID_UNDEFINED; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ @@ -336,7 +338,7 @@ void UT_os_count_sem_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_count_sem_get_info_test() { - osal_id_t count_sem_id; + osal_id_t count_sem_id = OS_OBJECT_ID_UNDEFINED; OS_count_sem_prop_t count_sem_prop; /*-----------------------------------------------------*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_misc_test.c b/src/unit-tests/oscore-test/ut_oscore_misc_test.c index de5092f0c..dcfd7e792 100644 --- a/src/unit-tests/oscore-test/ut_oscore_misc_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_misc_test.c @@ -86,12 +86,13 @@ *--------------------------------------------------------------------------------*/ void UT_os_apiinit_test() { - osal_id_t qId; - osal_blockcount_t qDepth = OSAL_BLOCKCOUNT_C(10); - size_t qSize = OSAL_SIZE_C(4); - uint32 qFlags = 0; - osal_id_t semIds[3]; - uint32 semInitValue = 1, semOptions = 0; + osal_id_t qId = OS_OBJECT_ID_UNDEFINED; + osal_blockcount_t qDepth = OSAL_BLOCKCOUNT_C(10); + size_t qSize = OSAL_SIZE_C(4); + uint32 qFlags = 0; + osal_id_t semIds[3] = {OS_OBJECT_ID_UNDEFINED, OS_OBJECT_ID_UNDEFINED, OS_OBJECT_ID_UNDEFINED}; + uint32 semInitValue = 1; + uint32 semOptions = 0; /*-----------------------------------------------------*/ /* #1 Init-not-call-first */ @@ -245,6 +246,8 @@ void UT_os_getlocaltime_test() OS_time_t time_struct; int32 i = 0; + memset(&time_struct, 0, sizeof(time_struct)); + /*-----------------------------------------------------*/ /* API not implemented */ @@ -309,6 +312,8 @@ void UT_os_setlocaltime_test() OS_time_t time_struct; int32 i = 0; + memset(&time_struct, 0, sizeof(time_struct)); + /*-----------------------------------------------------*/ /* API not implemented */ @@ -386,6 +391,8 @@ void UT_os_geterrorname_test(void) { os_err_name_t errNames[4]; + memset(errNames, 0, sizeof(errNames)); + /*-----------------------------------------------------*/ /* #1 Null-pointer-arg */ diff --git a/src/unit-tests/oscore-test/ut_oscore_mutex_test.c b/src/unit-tests/oscore-test/ut_oscore_mutex_test.c index 3c4b8e593..62ebd5207 100644 --- a/src/unit-tests/oscore-test/ut_oscore_mutex_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_mutex_test.c @@ -66,8 +66,8 @@ void UT_os_mut_sem_create_test() { int i; - osal_id_t mut_sem_id; - osal_id_t mut_sem_id2; + osal_id_t mut_sem_id = OS_OBJECT_ID_UNDEFINED; + osal_id_t mut_sem_id2 = OS_OBJECT_ID_UNDEFINED; char sem_name[UT_OS_NAME_BUFF_SIZE]; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; @@ -141,7 +141,7 @@ void UT_os_mut_sem_create_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_delete_test() { - osal_id_t mut_sem_id; + osal_id_t mut_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -169,7 +169,7 @@ void UT_os_mut_sem_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_give_test() { - osal_id_t mut_sem_id; + osal_id_t mut_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -202,7 +202,7 @@ void UT_os_mut_sem_give_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_take_test() { - osal_id_t mut_sem_id; + osal_id_t mut_sem_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -233,7 +233,7 @@ void UT_os_mut_sem_take_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_get_id_by_name_test() { - osal_id_t mut_sem_id; + osal_id_t mut_sem_id = OS_OBJECT_ID_UNDEFINED; char long_sem_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ @@ -278,7 +278,7 @@ void UT_os_mut_sem_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_mut_sem_get_info_test() { - osal_id_t mut_sem_id; + osal_id_t mut_sem_id = OS_OBJECT_ID_UNDEFINED; OS_mut_sem_prop_t mut_sem_prop; /*-----------------------------------------------------*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_queue_test.c b/src/unit-tests/oscore-test/ut_oscore_queue_test.c index 47c82f2e8..0d858dc66 100644 --- a/src/unit-tests/oscore-test/ut_oscore_queue_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_queue_test.c @@ -69,9 +69,9 @@ **--------------------------------------------------------------------------------*/ void UT_os_queue_create_test() { - int i = 0; - osal_id_t queue_id; - osal_id_t queue_id2; + int i = 0; + osal_id_t queue_id = OS_OBJECT_ID_UNDEFINED; + osal_id_t queue_id2 = OS_OBJECT_ID_UNDEFINED; char queue_name[UT_OS_NAME_BUFF_SIZE]; char long_queue_name[UT_OS_NAME_BUFF_SIZE]; @@ -153,7 +153,7 @@ void UT_os_queue_create_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_delete_test() { - osal_id_t queue_id; + osal_id_t queue_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Invalid-ID-arg */ @@ -183,7 +183,7 @@ void UT_os_queue_delete_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_get_test() { - osal_id_t queue_id; + osal_id_t queue_id = OS_OBJECT_ID_UNDEFINED; uint32 queue_data_out; uint32 queue_data_in; size_t size_copied; @@ -298,7 +298,7 @@ void UT_os_queue_get_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_put_test() { - osal_id_t queue_id; + osal_id_t queue_id = OS_OBJECT_ID_UNDEFINED; uint32 queue_data_out = 0; int i; @@ -364,7 +364,7 @@ void UT_os_queue_put_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_get_id_by_name_test() { - osal_id_t queue_id; + osal_id_t queue_id = OS_OBJECT_ID_UNDEFINED; char long_queue_name[UT_OS_NAME_BUFF_SIZE]; /*-----------------------------------------------------*/ @@ -410,7 +410,7 @@ void UT_os_queue_get_id_by_name_test() **--------------------------------------------------------------------------------*/ void UT_os_queue_get_info_test() { - osal_id_t queue_id; + osal_id_t queue_id = OS_OBJECT_ID_UNDEFINED; OS_queue_prop_t queue_prop; /*-----------------------------------------------------*/ diff --git a/src/unit-tests/oscore-test/ut_oscore_task_test.c b/src/unit-tests/oscore-test/ut_oscore_task_test.c index 4a4ee8588..71f5369ce 100644 --- a/src/unit-tests/oscore-test/ut_oscore_task_test.c +++ b/src/unit-tests/oscore-test/ut_oscore_task_test.c @@ -396,6 +396,10 @@ void UT_os_task_delay_test() OS_time_t after_time; int64 elapsed; + /* Initialize to avoid static analysis warnings */ + memset(&before_time, 0, sizeof(before_time)); + memset(&after_time, 0, sizeof(after_time)); + /* * Note, if running under a VM/hypervisor, the real time clock may not * be very precise, depending on its implementation. Therefore the allowed diff --git a/src/unit-tests/osfile-test/ut_osfile_dirio_test.c b/src/unit-tests/osfile-test/ut_osfile_dirio_test.c index 4f0ef3db2..17c452a05 100644 --- a/src/unit-tests/osfile-test/ut_osfile_dirio_test.c +++ b/src/unit-tests/osfile-test/ut_osfile_dirio_test.c @@ -124,7 +124,7 @@ void UT_os_read_n_sort_dirs(osal_id_t); **--------------------------------------------------------------------------------*/ void UT_os_makedir_test() { - osal_id_t fileDesc; + osal_id_t fileDesc = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Null-pointer-arg */ @@ -205,7 +205,7 @@ void UT_os_makedir_test() **--------------------------------------------------------------------------------*/ void UT_os_opendir_test() { - osal_id_t dirh; + osal_id_t dirh = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Null-pointer-arg */ @@ -278,7 +278,7 @@ void UT_os_opendir_test() **--------------------------------------------------------------------------------*/ void UT_os_closedir_test() { - osal_id_t dirh; + osal_id_t dirh = OS_OBJECT_ID_UNDEFINED; os_dirent_t dirEntry; UT_RETVAL(OS_DirectoryClose(UT_OBJID_INCORRECT), OS_ERR_INVALID_ID); @@ -543,7 +543,7 @@ void UT_os_rewinddir_test() **--------------------------------------------------------------------------------*/ void UT_os_removedir_test() { - osal_id_t fileDesc; + osal_id_t fileDesc = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* #1 Null-pointer-arg */ @@ -600,6 +600,7 @@ void UT_os_read_n_sort_dirs(osal_id_t dirh) const char *Name; memset(g_dirItems, 0, sizeof(g_dirItems)); + memset(&dirEntry, 0, sizeof(dirEntry)); NumMatched = 0; NumEntries = 0; diff --git a/src/unit-tests/osfile-test/ut_osfile_fileio_test.c b/src/unit-tests/osfile-test/ut_osfile_fileio_test.c index 1ecd51251..e11baed56 100644 --- a/src/unit-tests/osfile-test/ut_osfile_fileio_test.c +++ b/src/unit-tests/osfile-test/ut_osfile_fileio_test.c @@ -878,9 +878,13 @@ void UT_os_chmodfile_test() **--------------------------------------------------------------------------------*/ void UT_os_statfile_test() { - os_fstat_t fstats1, fstats2; + os_fstat_t fstats1; + os_fstat_t fstats2; size_t expected_len; + memset(&fstats1, 0, sizeof(fstats1)); + memset(&fstats2, 0, sizeof(fstats2)); + /*-----------------------------------------------------*/ /* #1 Null-pointer-arg */ UT_RETVAL(OS_stat(NULL, &fstats1), OS_INVALID_POINTER); diff --git a/src/unit-tests/osloader-test/ut_osloader_module_test.c b/src/unit-tests/osloader-test/ut_osloader_module_test.c index 52dcb9001..99863af52 100644 --- a/src/unit-tests/osloader-test/ut_osloader_module_test.c +++ b/src/unit-tests/osloader-test/ut_osloader_module_test.c @@ -66,8 +66,8 @@ void UT_os_module_load_test() { int i; - osal_id_t module_id; - osal_id_t module_id2; + osal_id_t module_id = OS_OBJECT_ID_UNDEFINED; + osal_id_t module_id2 = OS_OBJECT_ID_UNDEFINED; char module_name[UT_OS_NAME_BUFF_SIZE]; char module_file_name[UT_OS_PATH_BUFF_SIZE]; @@ -169,7 +169,7 @@ void UT_os_module_load_test() **--------------------------------------------------------------------------------*/ void UT_os_module_unload_test() { - osal_id_t module_id; + osal_id_t module_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* API Not implemented */ @@ -208,7 +208,7 @@ void UT_os_module_unload_test() **--------------------------------------------------------------------------------*/ void UT_os_module_info_test() { - osal_id_t module_id; + osal_id_t module_id = OS_OBJECT_ID_UNDEFINED; OS_module_prop_t module_info; /*-----------------------------------------------------*/ diff --git a/src/unit-tests/osloader-test/ut_osloader_symtable_test.c b/src/unit-tests/osloader-test/ut_osloader_symtable_test.c index d0710ba78..4f1b6f72a 100644 --- a/src/unit-tests/osloader-test/ut_osloader_symtable_test.c +++ b/src/unit-tests/osloader-test/ut_osloader_symtable_test.c @@ -73,7 +73,7 @@ void UT_os_symbol_lookup_test() { cpuaddr symbol_addr; - osal_id_t module_id; + osal_id_t module_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* API Not implemented */ @@ -137,7 +137,7 @@ void UT_os_symbol_lookup_test() void UT_os_module_symbol_lookup_test() { cpuaddr symbol_addr; - osal_id_t module_id; + osal_id_t module_id = OS_OBJECT_ID_UNDEFINED; /*-----------------------------------------------------*/ /* API Not implemented */