From 1cc97c30482aecbe26cf37dbe5b9d885e6be0849 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 9 Dec 2019 10:02:30 -0500 Subject: [PATCH] Fix #298: Fix minor warnings in OSAL code Fix warnings that are triggered by compiling the OSAL coverage unit test with strict settings. - The OS_FPUExcAttachHandler function needs to be prototyped as accepting a function pointer (not void*) - Const-Correctness on OS_ModuleLoad_Impl() - Use void* instead of char* for buffer pointer as the specific type is not known - Cast the function passed into taskSpawn on VxWorks --- src/os/inc/osapi-os-core.h | 2 +- src/os/portable/os-impl-posix-dl.c | 2 +- src/os/posix/osapi.c | 2 +- src/os/rtems/osapi.c | 2 +- src/os/rtems/osloader.c | 2 +- src/os/shared/os-impl.h | 4 ++-- src/os/shared/osapi-fpu.c | 2 +- src/os/vxworks/osapi.c | 4 ++-- src/os/vxworks/osloader.c | 2 +- src/os/vxworks/ostimer.c | 2 +- src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c | 2 +- .../ut-stubs/src/osapi-loader-impl-stubs.c | 2 +- src/ut-stubs/osapi-utstub-fpu.c | 6 ++---- 13 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/os/inc/osapi-os-core.h b/src/os/inc/osapi-os-core.h index 61ce966b5..44b9574e6 100644 --- a/src/os/inc/osapi-os-core.h +++ b/src/os/inc/osapi-os-core.h @@ -972,7 +972,7 @@ int32 OS_ExcDisable (int32 ExceptionNumber); * @returns OS_SUCCESS on success, or appropriate error code * OS_ERR_NOT_IMPLEMENTED on platforms that do not support this function */ -int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, void * ExceptionHandler , +int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, osal_task_entry ExceptionHandler, int32 parameter); /*-------------------------------------------------------------------------------------*/ diff --git a/src/os/portable/os-impl-posix-dl.c b/src/os/portable/os-impl-posix-dl.c index 23aba192a..1257b808f 100644 --- a/src/os/portable/os-impl-posix-dl.c +++ b/src/os/portable/os-impl-posix-dl.c @@ -150,7 +150,7 @@ int32 OS_SymbolLookup_Impl( cpuaddr *SymbolAddress, const char *SymbolName ) * See description in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) +int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) { int32 status = OS_ERROR; diff --git a/src/os/posix/osapi.c b/src/os/posix/osapi.c index c41cda190..c7ded038b 100644 --- a/src/os/posix/osapi.c +++ b/src/os/posix/osapi.c @@ -2327,7 +2327,7 @@ static int OS_PriorityRemap(uint32 InputPri) * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, void * ExceptionHandler, +int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, osal_task_entry ExceptionHandler, int32 parameter) { /* diff --git a/src/os/rtems/osapi.c b/src/os/rtems/osapi.c index 56ce59f83..119946bf8 100644 --- a/src/os/rtems/osapi.c +++ b/src/os/rtems/osapi.c @@ -1590,7 +1590,7 @@ int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, void * ExceptionHandler, +int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, osal_task_entry ExceptionHandler, int32 parameter) { /* diff --git a/src/os/rtems/osloader.c b/src/os/rtems/osloader.c index 887a8c12d..5bcda592c 100644 --- a/src/os/rtems/osloader.c +++ b/src/os/rtems/osloader.c @@ -205,7 +205,7 @@ static bool OS_rtems_rtl_check_unresolved (rtems_rtl_unresolv_rec_t* rec, * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ) +int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ) { int32 status = OS_ERROR; int unresolved; diff --git a/src/os/shared/os-impl.h b/src/os/shared/os-impl.h index 8e252bf5d..aba3434d6 100644 --- a/src/os/shared/os-impl.h +++ b/src/os/shared/os-impl.h @@ -1227,7 +1227,7 @@ int32 OS_SetLocalTime_Impl(const OS_time_t *time_struct); Returns: OS_SUCCESS on success, or relevant error code ------------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 module_id, char *translated_path ); +int32 OS_ModuleLoad_Impl ( uint32 module_id, const char *translated_path ); /*---------------------------------------------------------------- @@ -1874,7 +1874,7 @@ int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ); * FPU API low-level handlers * These may also not be implementable on some platforms */ -int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, void * ExceptionHandler, +int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, osal_task_entry ExceptionHandler, int32 parameter); int32 OS_FPUExcEnable_Impl(int32 ExceptionNumber); int32 OS_FPUExcDisable_Impl(int32 ExceptionNumber); diff --git a/src/os/shared/osapi-fpu.c b/src/os/shared/osapi-fpu.c index 4959b9ff2..fdd88a868 100644 --- a/src/os/shared/osapi-fpu.c +++ b/src/os/shared/osapi-fpu.c @@ -40,7 +40,7 @@ * See description in API and header file for detail * *-----------------------------------------------------------------*/ -int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, void * ExceptionHandler , +int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, osal_task_entry ExceptionHandler , int32 parameter) { if (ExceptionHandler == NULL) diff --git a/src/os/vxworks/osapi.c b/src/os/vxworks/osapi.c index a7cf8902e..66eeacb9a 100644 --- a/src/os/vxworks/osapi.c +++ b/src/os/vxworks/osapi.c @@ -155,7 +155,7 @@ VX_MUTEX_SEMAPHORE(OS_console_mut_mem); typedef struct { - char * const mem; + void * const mem; SEM_ID vxid; } VxWorks_GlobalMutex_t; @@ -1538,7 +1538,7 @@ int32 OS_IntGetMask_Impl ( uint32 * MaskSettingPtr ) * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, void * ExceptionHandler, +int32 OS_FPUExcAttachHandler_Impl(uint32 ExceptionNumber, osal_task_entry ExceptionHandler, int32 parameter) { /* diff --git a/src/os/vxworks/osloader.c b/src/os/vxworks/osloader.c index b95d7a7f1..652a550d8 100644 --- a/src/os/vxworks/osloader.c +++ b/src/os/vxworks/osloader.c @@ -297,7 +297,7 @@ int32 OS_SymbolTableDump_Impl ( const char *local_filename, uint32 SizeLimit ) * See prototype in os-impl.h for argument/return detail * *-----------------------------------------------------------------*/ -int32 OS_ModuleLoad_Impl ( uint32 local_id, char *translated_path ) +int32 OS_ModuleLoad_Impl ( uint32 local_id, const char *translated_path ) { int32 return_code; int fd; diff --git a/src/os/vxworks/ostimer.c b/src/os/vxworks/ostimer.c index 9b786ca66..43d1d574a 100644 --- a/src/os/vxworks/ostimer.c +++ b/src/os/vxworks/ostimer.c @@ -469,7 +469,7 @@ int32 OS_TimeBaseCreate_Impl(uint32 timer_id) OSAL_TIMEBASE_TASK_PRIORITY, /* priority */ OSAL_TIMEBASE_TASK_OPTION_WORD, /* task option word */ OSAL_TIMEBASE_TASK_STACK_SIZE, /* size (bytes) of stack needed */ - OS_VxWorks_TimeBaseTask, + (FUNCPTR)OS_VxWorks_TimeBaseTask, global->active_id, /* 1st arg is ID */ 0,0,0,0,0,0,0,0,0); diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c index 78a681061..cb660a5a0 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-base-impl-stubs.c @@ -163,7 +163,7 @@ UT_DEFAULT_STUB(OS_HeapGetInfo_Impl,(OS_heap_prop_t *heap_prop)) /* * FPU API low-level handlers */ -UT_DEFAULT_STUB(OS_FPUExcAttachHandler_Impl,(uint32 ExceptionNumber, void * ExceptionHandler,int32 parameter)) +UT_DEFAULT_STUB(OS_FPUExcAttachHandler_Impl,(uint32 ExceptionNumber, osal_task_entry ExceptionHandler,int32 parameter)) UT_DEFAULT_STUB(OS_FPUExcEnable_Impl,(int32 ExceptionNumber)) UT_DEFAULT_STUB(OS_FPUExcDisable_Impl,(int32 ExceptionNumber)) UT_DEFAULT_STUB(OS_FPUExcSetMask_Impl,(uint32 mask)) diff --git a/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c b/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c index 33ebe8f28..8e9a4aa9e 100644 --- a/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c +++ b/src/unit-test-coverage/ut-stubs/src/osapi-loader-impl-stubs.c @@ -17,7 +17,7 @@ /* * Module Loader API */ -UT_DEFAULT_STUB(OS_ModuleLoad_Impl,( uint32 module_id, char *translated_path )) +UT_DEFAULT_STUB(OS_ModuleLoad_Impl,( uint32 module_id, const char *translated_path )) UT_DEFAULT_STUB(OS_ModuleUnload_Impl,( uint32 module_id )) UT_DEFAULT_STUB(OS_ModuleGetInfo_Impl,( uint32 module_id, OS_module_prop_t *module_prop )) UT_DEFAULT_STUB(OS_SymbolLookup_Impl,( cpuaddr *SymbolAddress, const char *SymbolName )) diff --git a/src/ut-stubs/osapi-utstub-fpu.c b/src/ut-stubs/osapi-utstub-fpu.c index 85a43d249..16000e9cd 100644 --- a/src/ut-stubs/osapi-utstub-fpu.c +++ b/src/ut-stubs/osapi-utstub-fpu.c @@ -30,14 +30,12 @@ * Stub function for OS_FPUExcAttachHandler() * *****************************************************************************/ -int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, void * ExceptionHandler , +int32 OS_FPUExcAttachHandler (uint32 ExceptionNumber, osal_task_entry ExceptionHandler , int32 parameter) { int32 status; - UT_Stub_RegisterContext(UT_KEY(OS_FPUExcAttachHandler), ExceptionHandler); - - status = UT_DEFAULT_IMPL(OS_FPUExcAttachHandler); + status = UT_DEFAULT_IMPL_ARGS(OS_FPUExcAttachHandler, ExceptionNumber, ExceptionHandler, parameter); return status; }