From 81a04349827aa2a0e85aa32da3a11ae755975482 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 9 Dec 2019 16:57:25 -0500 Subject: [PATCH] Fix #298: Clean up warnings in UT code with strict settings Additional compiler warning fixes for the UT code itself. This is committed separately from the changes that affect the OSAL FSW code. --- .../shared/src/coveragetest-dir.c | 2 +- .../shared/src/coveragetest-filesys.c | 22 +++++++++++-------- .../shared/src/coveragetest-idmap.c | 6 ++--- .../shared/src/coveragetest-task.c | 5 +++-- .../shared/src/coveragetest-time.c | 4 ++-- .../vxworks/modules/inc/ut-osloader.h | 2 +- .../vxworks/modules/src/ut-osloader.c | 9 ++++++-- .../vxworks/src/coveragetest-osfilesys.c | 2 -- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/unit-test-coverage/shared/src/coveragetest-dir.c b/src/unit-test-coverage/shared/src/coveragetest-dir.c index a7b76a13a..703e6a3ba 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-dir.c +++ b/src/unit-test-coverage/shared/src/coveragetest-dir.c @@ -161,7 +161,7 @@ void Test_OS_readdir(void) os_dirp_t dirp = OS_opendir("Dir"); os_dirent_t *dirent = OS_readdir(dirp); - UtAssert_True(dirent != NULL, "OS_readdir() (%p) != NULL", dirent); + UtAssert_True(dirent != NULL, "OS_readdir() (%p) != NULL", (void*)dirent); } diff --git a/src/unit-test-coverage/shared/src/coveragetest-filesys.c b/src/unit-test-coverage/shared/src/coveragetest-filesys.c index 39aba02f3..f169221de 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/shared/src/coveragetest-filesys.c @@ -70,13 +70,15 @@ void Test_OS_mkfs(void) int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; - actual = OS_mkfs("adr","/ramdev0","vol",0,0); + char TestBuffer[128]; + + actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_SUCCESS", (long)actual); /* * Test an entry NOT found in the OS_VolumeTable */ - actual = OS_mkfs("adr","/rd1","vol1",0,0); + actual = OS_mkfs(TestBuffer,"/rd1","vol1",0,0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_SUCCESS", (long)actual); @@ -86,25 +88,25 @@ void Test_OS_mkfs(void) UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_mkfs("adr","/ramdev0","vol",0,0); + actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); /* set up for failure due to empty strings */ expected = OS_FS_ERR_PATH_INVALID; - actual = OS_mkfs("adr","","",0,0); + actual = OS_mkfs(TestBuffer,"","",0,0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual); /* set up for failure due to formatting */ UT_SetForceFail(UT_KEY(OS_FileSysFormatVolume_Impl), OS_FS_ERR_DRIVE_NOT_CREATED); expected = OS_FS_ERR_DRIVE_NOT_CREATED; - actual = OS_mkfs("adr","/ramdev0","vol",0,0); + actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_DRIVE_NOT_CREATED (format failure)", (long)actual); /* set up for failure due to no free slots */ UT_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); expected = OS_FS_ERR_DEVICE_NOT_FREE; - actual = OS_mkfs("adr","/ramdev0","vol",0,0); + actual = OS_mkfs(TestBuffer,"/ramdev0","vol",0,0); UtAssert_True(actual == expected, "OS_mkfs() (%ld) == OS_FS_ERR_DEVICE_NOT_FREE", (long)actual); } @@ -148,7 +150,9 @@ void Test_OS_initfs(void) int32 expected = OS_SUCCESS; int32 actual = ~OS_SUCCESS; - actual = OS_initfs("adr","/ramdev0","vol",0,0); + char TestBuffer[128]; + + actual = OS_initfs(TestBuffer,"/ramdev0","vol",0,0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_SUCCESS", (long)actual); actual = OS_initfs(NULL,"/hda2","vol2",0,0); @@ -160,14 +164,14 @@ void Test_OS_initfs(void) UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_FS_DEV_NAME_LEN); expected = OS_FS_ERR_PATH_TOO_LONG; - actual = OS_initfs("adr","/ramdev0","vol",0,0); + actual = OS_initfs(TestBuffer,"/ramdev0","vol",0,0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_FS_ERR_PATH_TOO_LONG", (long)actual); UT_ClearForceFail(UT_KEY(OCS_strlen)); /* set up for failure */ UT_SetForceFail(UT_KEY(OS_ObjectIdAllocateNew), OS_ERR_NO_FREE_IDS); expected = OS_FS_ERR_DEVICE_NOT_FREE; - actual = OS_initfs("adr","/ramdev0","vol",0,0); + actual = OS_initfs(TestBuffer,"/ramdev0","vol",0,0); UtAssert_True(actual == expected, "OS_initfs() (%ld) == OS_FS_ERR_DEVICE_NOT_FREE", (long)actual); } diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index 82fc67216..c8a2f1cf0 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -368,7 +368,7 @@ void Test_OS_ObjectIdGetById(void) /* Verify Outputs */ UtAssert_True(actual == expected, "OS_ObjectIdGetById() (%ld) == OS_SUCCESS", (long)actual); UtAssert_True(local_idx == 1, "local_idx (%lu) == 1", (unsigned long)local_idx); - UtAssert_True(rptr != NULL, "rptr (%p) != NULL", rptr); + UtAssert_True(rptr != NULL, "rptr (%p) != NULL", (void*)rptr); UtAssert_True(rptr->refcount == 1, "refcount (%u) == 1", (unsigned int)rptr->refcount); @@ -517,7 +517,7 @@ void Test_OS_ObjectIdFindNext(void) } if (rec1 == rec2) { - UtAssert_Failed("OS_ObjectIdFindNext() duplicate slot (%p)", rec1); + UtAssert_Failed("OS_ObjectIdFindNext() duplicate slot (%p)", (void*)rec1); break; } @@ -556,7 +556,7 @@ void Test_OS_ObjectIdAllocateNew(void) /* Verify Outputs */ UtAssert_True(actual == expected, "OS_ObjectIdAllocate() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(rptr != NULL, "rptr (%p) != NULL", rptr); + UtAssert_True(rptr != NULL, "rptr (%p) != NULL", (void*)rptr); /* Passing a NULL name also should work here (used for internal objects) */ actual = OS_ObjectIdAllocateNew(OS_OBJECT_TYPE_OS_TASK, NULL, &objid, &rptr); diff --git a/src/unit-test-coverage/shared/src/coveragetest-task.c b/src/unit-test-coverage/shared/src/coveragetest-task.c index d4dbb8dfe..7ea1fdf79 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-task.c +++ b/src/unit-test-coverage/shared/src/coveragetest-task.c @@ -280,8 +280,9 @@ void Test_OS_TaskInstallDeleteHandler(void) UT_SetForceFail(UT_KEY(OS_TaskGetId_Impl), 1); actual = OS_TaskInstallDeleteHandler(UT_TestHook); UtAssert_True(actual == expected, "OS_TaskInstallDeleteHandler() (%ld) == OS_SUCCESS", (long)actual); - UtAssert_True(OS_task_table[1].delete_hook_pointer == UT_TestHook, "OS_task_table[1].delete_hook_pointer (%p) == %p", - OS_task_table[1].delete_hook_pointer, UT_TestHook); + UtAssert_True(OS_task_table[1].delete_hook_pointer == UT_TestHook, "OS_task_table[1].delete_hook_pointer (%lx) == %lx", + (unsigned long)OS_task_table[1].delete_hook_pointer, + (unsigned long)UT_TestHook); OS_task_table[1].delete_hook_pointer = NULL; } diff --git a/src/unit-test-coverage/shared/src/coveragetest-time.c b/src/unit-test-coverage/shared/src/coveragetest-time.c index 4e354bbfe..b0a25b234 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-time.c +++ b/src/unit-test-coverage/shared/src/coveragetest-time.c @@ -113,9 +113,9 @@ void Test_OS_TimerCreate(void) OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TIMECB, objid, &local_id); UtAssert_True(OS_timecb_table[local_id].callback_ptr != NULL, - "OS_timecb_table[%lu].callback_ptr (%p) != NULL", + "OS_timecb_table[%lu].callback_ptr (%lx) != NULL", (unsigned long)local_id, - OS_timecb_table[local_id].callback_ptr); + (unsigned long)OS_timecb_table[local_id].callback_ptr); UT_TimerCount = 0; OS_timecb_table[local_id].callback_ptr(objid, OS_timecb_table[local_id].callback_arg); diff --git a/src/unit-test-coverage/vxworks/modules/inc/ut-osloader.h b/src/unit-test-coverage/vxworks/modules/inc/ut-osloader.h index f0f7a9630..00da55ee1 100644 --- a/src/unit-test-coverage/vxworks/modules/inc/ut-osloader.h +++ b/src/unit-test-coverage/vxworks/modules/inc/ut-osloader.h @@ -24,7 +24,7 @@ int32 OS_VxWorks_ModuleAPI_Impl_Init(void); * Invokes OS_SymTableIterator_Impl() with the given arguments. * This is normally a static function but exposed via a non-static wrapper for UT purposes. */ -int32 Osapi_Internal_CallIteratorFunc(char *name, void* val, uint32 TestSize, uint32 SizeLimit); +int32 Osapi_Internal_CallIteratorFunc(const char *name, void* val, uint32 TestSize, uint32 SizeLimit); #endif /* _OSAL_UT_OSLOADER_H_ */ diff --git a/src/unit-test-coverage/vxworks/modules/src/ut-osloader.c b/src/unit-test-coverage/vxworks/modules/src/ut-osloader.c index 313ad1c69..4f8970e3f 100644 --- a/src/unit-test-coverage/vxworks/modules/src/ut-osloader.c +++ b/src/unit-test-coverage/vxworks/modules/src/ut-osloader.c @@ -19,10 +19,15 @@ OS_SharedGlobalVars_t OS_SharedGlobalVars = * A UT-specific wrapper function to invoke the Symbol Table Iterator. * This is normally static so it needs this wrapper to call it. */ -int32 Osapi_Internal_CallIteratorFunc(char *name, void* val, uint32 TestSize, uint32 SizeLimit) +int32 Osapi_Internal_CallIteratorFunc(const char *name, void* val, uint32 TestSize, uint32 SizeLimit) { OS_impl_module_global.sym_dump.Sizelimit = SizeLimit; OS_impl_module_global.sym_dump.CurrSize = TestSize; - return OS_SymTableIterator_Impl(name,val,0,0,0); + /* + * note the internal function is takes a name declared as "char*" to be + * consistent with the VxWorks API, however the implementation does not + * modify this argument. + */ + return OS_SymTableIterator_Impl((char*)name,val,0,0,0); } diff --git a/src/unit-test-coverage/vxworks/src/coveragetest-osfilesys.c b/src/unit-test-coverage/vxworks/src/coveragetest-osfilesys.c index 84dcb8af6..648f328df 100644 --- a/src/unit-test-coverage/vxworks/src/coveragetest-osfilesys.c +++ b/src/unit-test-coverage/vxworks/src/coveragetest-osfilesys.c @@ -62,8 +62,6 @@ void Test_OS_FileSysStartVolume_Impl(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysStartVolume_Impl(1), OS_FS_ERR_DRIVE_NOT_CREATED); } - -; void Test_OS_FileSysStopVolume_Impl(void) { /* Test Case For: