diff --git a/src/os/shared/src/osapi-binsem.c b/src/os/shared/src/osapi-binsem.c index 49510ae1c..1461f8aeb 100644 --- a/src/os/shared/src/osapi-binsem.c +++ b/src/os/shared/src/osapi-binsem.c @@ -100,7 +100,7 @@ int32 OS_BinSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_initia OS_object_token_t token; OS_bin_sem_internal_record_t *binsem; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(sem_id); OS_CHECK_APINAME(sem_name); @@ -255,7 +255,7 @@ int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { int32 return_code; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(sem_id); OS_CHECK_POINTER(sem_name); @@ -278,7 +278,7 @@ int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop) OS_object_token_t token; int32 return_code; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(bin_prop); memset(bin_prop, 0, sizeof(OS_bin_sem_prop_t)); diff --git a/src/os/shared/src/osapi-clock.c b/src/os/shared/src/osapi-clock.c index 1aec8bfc8..d5a844376 100644 --- a/src/os/shared/src/osapi-clock.c +++ b/src/os/shared/src/osapi-clock.c @@ -50,7 +50,7 @@ *-----------------------------------------------------------------*/ int32 OS_GetLocalTime(OS_time_t *time_struct) { - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(time_struct); return OS_GetLocalTime_Impl(time_struct); @@ -67,7 +67,7 @@ int32 OS_GetLocalTime(OS_time_t *time_struct) *-----------------------------------------------------------------*/ int32 OS_SetLocalTime(const OS_time_t *time_struct) { - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(time_struct); return OS_SetLocalTime_Impl(time_struct); diff --git a/src/os/shared/src/osapi-countsem.c b/src/os/shared/src/osapi-countsem.c index 9afcd2850..10ec1c461 100644 --- a/src/os/shared/src/osapi-countsem.c +++ b/src/os/shared/src/osapi-countsem.c @@ -92,7 +92,7 @@ int32 OS_CountSemCreate(osal_id_t *sem_id, const char *sem_name, uint32 sem_init OS_object_token_t token; OS_count_sem_internal_record_t *countsem; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(sem_id); OS_CHECK_APINAME(sem_name); @@ -224,7 +224,7 @@ int32 OS_CountSemGetIdByName(osal_id_t *sem_id, const char *sem_name) { int32 return_code; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(sem_id); OS_CHECK_POINTER(sem_name); @@ -247,7 +247,7 @@ int32 OS_CountSemGetInfo(osal_id_t sem_id, OS_count_sem_prop_t *count_prop) OS_object_token_t token; int32 return_code; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(count_prop); memset(count_prop, 0, sizeof(OS_count_sem_prop_t)); diff --git a/src/os/shared/src/osapi-dir.c b/src/os/shared/src/osapi-dir.c index 06f55cdb3..7566aa606 100644 --- a/src/os/shared/src/osapi-dir.c +++ b/src/os/shared/src/osapi-dir.c @@ -118,7 +118,7 @@ int32 OS_DirectoryOpen(osal_id_t *dir_id, const char *path) OS_dir_internal_record_t *dir; int32 return_code; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(dir_id); return_code = OS_TranslatePath(path, local_path); @@ -183,7 +183,7 @@ int32 OS_DirectoryRead(osal_id_t dir_id, os_dirent_t *dirent) OS_object_token_t token; int32 return_code; - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(dirent); /* Make sure the file descriptor is legit before using it */ diff --git a/src/os/shared/src/osapi-errors.c b/src/os/shared/src/osapi-errors.c index ddfe12f9b..c20c2bb66 100644 --- a/src/os/shared/src/osapi-errors.c +++ b/src/os/shared/src/osapi-errors.c @@ -101,6 +101,7 @@ int32 OS_GetErrorName(int32 error_num, os_err_name_t *err_name) uint32 return_code; const OS_ErrorTable_Entry_t *Error; + /* Check parameters */ OS_CHECK_POINTER(err_name); Error = OS_GLOBAL_ERROR_NAME_TABLE; diff --git a/src/os/shared/src/osapi-file.c b/src/os/shared/src/osapi-file.c index 1db28e3da..13c46d9f8 100644 --- a/src/os/shared/src/osapi-file.c +++ b/src/os/shared/src/osapi-file.c @@ -112,6 +112,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc OS_object_token_t token; OS_stream_internal_record_t *stream; + /* Check parameters */ OS_CHECK_POINTER(filedes); /* @@ -630,6 +631,7 @@ int32 OS_FileOpenCheck(const char *Filename) OS_object_iter_t iter; OS_stream_internal_record_t *stream; + /* Check parameters */ OS_CHECK_POINTER(Filename); return_code = OS_ERROR; @@ -666,6 +668,7 @@ int32 OS_CloseFileByName(const char *Filename) OS_object_iter_t iter; OS_stream_internal_record_t *stream; + /* Check parameters */ OS_CHECK_POINTER(Filename); return_code = OS_FS_ERR_PATH_INVALID; diff --git a/src/os/shared/src/osapi-filesys.c b/src/os/shared/src/osapi-filesys.c index 135e4ca77..8d1b44c7e 100644 --- a/src/os/shared/src/osapi-filesys.c +++ b/src/os/shared/src/osapi-filesys.c @@ -126,8 +126,10 @@ int32 OS_FileSys_Initialize(char *address, const char *fsdevname, const char *fs OS_object_token_t token; /* - ** Check parameters - */ + * Check parameters + * + * Note "address" is not checked, because in certain configurations it can be validly null. + */ OS_CHECK_STRING(fsdevname, sizeof(filesys->device_name), OS_FS_ERR_PATH_TOO_LONG); OS_CHECK_STRING(fsvolname, sizeof(filesys->volume_name), OS_FS_ERR_PATH_TOO_LONG); @@ -350,6 +352,7 @@ int32 OS_rmfs(const char *devname) int32 return_code; OS_object_token_t token; + /* Check parameters */ OS_CHECK_PATHNAME(devname); return_code = OS_ObjectIdGetByName(OS_LOCK_MODE_EXCLUSIVE, LOCAL_OBJID_TYPE, devname, &token); @@ -782,7 +785,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath) /* ** Check to see if the path pointers are NULL */ - /* Check inputs */ + /* Check parameters */ OS_CHECK_POINTER(VirtualPath); OS_CHECK_POINTER(LocalPath); diff --git a/src/os/shared/src/osapi-heap.c b/src/os/shared/src/osapi-heap.c index 15ec6750e..888d0d7ec 100644 --- a/src/os/shared/src/osapi-heap.c +++ b/src/os/shared/src/osapi-heap.c @@ -50,6 +50,7 @@ *-----------------------------------------------------------------*/ int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop) { + /* Check parameters */ OS_CHECK_POINTER(heap_prop); return OS_HeapGetInfo_Impl(heap_prop); diff --git a/src/os/shared/src/osapi-idmap.c b/src/os/shared/src/osapi-idmap.c index a8fb26c4b..d44cab065 100644 --- a/src/os/shared/src/osapi-idmap.c +++ b/src/os/shared/src/osapi-idmap.c @@ -91,7 +91,6 @@ typedef struct void * user_arg; } OS_creator_filter_t; - /* * Global ID storage tables */ @@ -270,7 +269,6 @@ int32 OS_ForEachDoCallback(osal_id_t obj_id, void *ref) return OS_SUCCESS; } - /*---------------------------------------------------------------- * * Function: OS_ObjectIdGlobalFromToken @@ -747,16 +745,17 @@ void OS_Lock_Global(OS_object_token_t *token) * This makes it different for every operation, and different depending * on what task is calling the function. */ - token->lock_key.key_value = OS_LOCK_KEY_FIXED_VALUE | - ((OS_ObjectIdToInteger(self_task_id) ^ objtype->transaction_count) & 0xFFFFFF); + token->lock_key.key_value = + OS_LOCK_KEY_FIXED_VALUE | ((OS_ObjectIdToInteger(self_task_id) ^ objtype->transaction_count) & 0xFFFFFF); ++objtype->transaction_count; if (objtype->owner_key.key_value != 0) { /* this is almost certainly a bug */ - OS_DEBUG("ERROR: global %u acquired by task 0x%lx when already assigned key 0x%lx\n", (unsigned int)token->obj_type, - OS_ObjectIdToInteger(self_task_id), (unsigned long)objtype->owner_key.key_value); + OS_DEBUG("ERROR: global %u acquired by task 0x%lx when already assigned key 0x%lx\n", + (unsigned int)token->obj_type, OS_ObjectIdToInteger(self_task_id), + (unsigned long)objtype->owner_key.key_value); } else { @@ -765,8 +764,8 @@ void OS_Lock_Global(OS_object_token_t *token) } else { - OS_DEBUG("ERROR: cannot lock global %u for mode %u\n", - (unsigned int)token->obj_type, (unsigned int)token->lock_mode); + OS_DEBUG("ERROR: cannot lock global %u for mode %u\n", (unsigned int)token->obj_type, + (unsigned int)token->lock_mode); } } @@ -795,8 +794,9 @@ void OS_Unlock_Global(OS_object_token_t *token) objtype->owner_key.key_value != token->lock_key.key_value) { /* this is almost certainly a bug */ - OS_DEBUG("ERROR: global %u released using mismatched key=0x%lx expected=0x%lx\n", (unsigned int)token->obj_type, - (unsigned long)token->lock_key.key_value, (unsigned long)objtype->owner_key.key_value); + OS_DEBUG("ERROR: global %u released using mismatched key=0x%lx expected=0x%lx\n", + (unsigned int)token->obj_type, (unsigned long)token->lock_key.key_value, + (unsigned long)objtype->owner_key.key_value); } objtype->owner_key = OS_LOCK_KEY_INVALID; @@ -806,8 +806,8 @@ void OS_Unlock_Global(OS_object_token_t *token) } else { - OS_DEBUG("ERROR: cannot unlock global %u for mode %u\n", - (unsigned int)token->obj_type, (unsigned int)token->lock_mode); + OS_DEBUG("ERROR: cannot unlock global %u for mode %u\n", (unsigned int)token->obj_type, + (unsigned int)token->lock_mode); } } @@ -1433,7 +1433,8 @@ void OS_ForEachObject(osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void * See description in API and header file for detail * *-----------------------------------------------------------------*/ -void OS_ForEachObjectOfType(osal_objtype_t idtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, void *callback_arg) +void OS_ForEachObjectOfType(osal_objtype_t idtype, osal_id_t creator_id, OS_ArgCallback_t callback_ptr, + void *callback_arg) { OS_object_iter_t iter; OS_creator_filter_t filter; diff --git a/src/os/shared/src/osapi-module.c b/src/os/shared/src/osapi-module.c index 362334115..18b6eef26 100644 --- a/src/os/shared/src/osapi-module.c +++ b/src/os/shared/src/osapi-module.c @@ -194,11 +194,11 @@ int32 OS_ModuleLoad(osal_id_t *module_id, const char *module_name, const char *f OS_module_internal_record_t *module; /* - ** Check parameters - ** - ** Note "filename" is not checked, because in certain configurations it can be validly - ** null. filename is checked for NULL-ness by the OS_TranslatePath() later. - */ + * Check parameters + * + * Note "filename" is not checked, because in certain configurations it can be validly + * null. filename is checked for NULL-ness by the OS_TranslatePath() later. + */ OS_CHECK_POINTER(module_id); OS_CHECK_APINAME(module_name); @@ -454,9 +454,7 @@ int32 OS_SymbolTableDump(const char *filename, size_t SizeLimit) char translated_path[OS_MAX_LOCAL_PATH_LEN]; OS_object_token_t token; - /* - ** Check parameters - */ + /* Check parameters */ OS_CHECK_POINTER(filename); /* diff --git a/src/os/shared/src/osapi-printf.c b/src/os/shared/src/osapi-printf.c index a174a4c61..5b766193d 100644 --- a/src/os/shared/src/osapi-printf.c +++ b/src/os/shared/src/osapi-printf.c @@ -256,6 +256,8 @@ void OS_printf(const char *String, ...) char msg_buffer[OS_BUFFER_SIZE]; int actualsz; + BUGCHECK((String) != NULL, ) + if (!OS_SharedGlobalVars.Initialized) { /* diff --git a/src/os/shared/src/osapi-select.c b/src/os/shared/src/osapi-select.c index d60b03288..f74453366 100644 --- a/src/os/shared/src/osapi-select.c +++ b/src/os/shared/src/osapi-select.c @@ -89,6 +89,12 @@ int32 OS_SelectMultiple(OS_FdSet *ReadSet, OS_FdSet *WriteSet, int32 msecs) { int32 return_code; + /* + * Check parameters + * + * Note "ReadSet" and "WriteSet" are not checked, because in certain configurations they can be validly null. + */ + /* * This does not currently increment any refcounts. * That means a file/socket can be closed while actively inside a diff --git a/src/os/shared/src/osapi-sockets.c b/src/os/shared/src/osapi-sockets.c index f610b8660..ddfdd44ab 100644 --- a/src/os/shared/src/osapi-sockets.c +++ b/src/os/shared/src/osapi-sockets.c @@ -359,7 +359,11 @@ int32 OS_SocketRecvFrom(osal_id_t sock_id, void *buffer, size_t buflen, OS_SockA OS_object_token_t token; int32 return_code; - /* Check Parameters */ + /* + * Check parameters + * + * Note "RemoteAddr" is not checked, because in certain configurations it can be validly null. + */ OS_CHECK_POINTER(buffer); OS_CHECK_SIZE(buflen); @@ -493,6 +497,7 @@ int32 OS_SocketGetInfo(osal_id_t sock_id, OS_socket_prop_t *sock_prop) *-----------------------------------------------------------------*/ int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) { + /* Check parameters */ OS_CHECK_POINTER(Addr); return OS_SocketAddrInit_Impl(Addr, Domain); @@ -508,6 +513,7 @@ int32 OS_SocketAddrInit(OS_SockAddr_t *Addr, OS_SocketDomain_t Domain) *-----------------------------------------------------------------*/ int32 OS_SocketAddrToString(char *buffer, size_t buflen, const OS_SockAddr_t *Addr) { + /* Check parameters */ OS_CHECK_POINTER(Addr); OS_CHECK_POINTER(buffer); OS_CHECK_SIZE(buflen); @@ -525,6 +531,7 @@ int32 OS_SocketAddrToString(char *buffer, size_t buflen, const OS_SockAddr_t *Ad *-----------------------------------------------------------------*/ int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) { + /* Check parameters */ OS_CHECK_POINTER(Addr); OS_CHECK_POINTER(string); @@ -541,6 +548,7 @@ int32 OS_SocketAddrFromString(OS_SockAddr_t *Addr, const char *string) *-----------------------------------------------------------------*/ int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) { + /* Check parameters */ OS_CHECK_POINTER(Addr); OS_CHECK_POINTER(PortNum); @@ -557,6 +565,7 @@ int32 OS_SocketAddrGetPort(uint16 *PortNum, const OS_SockAddr_t *Addr) *-----------------------------------------------------------------*/ int32 OS_SocketAddrSetPort(OS_SockAddr_t *Addr, uint16 PortNum) { + /* Check parameters */ OS_CHECK_POINTER(Addr); return OS_SocketAddrSetPort_Impl(Addr, PortNum); diff --git a/src/os/shared/src/osapi-task.c b/src/os/shared/src/osapi-task.c index b46db2677..29c60dd4f 100644 --- a/src/os/shared/src/osapi-task.c +++ b/src/os/shared/src/osapi-task.c @@ -178,7 +178,11 @@ int32 OS_TaskCreate(osal_id_t *task_id, const char *task_name, osal_task_entry f OS_object_token_t token; OS_task_internal_record_t *task; - /* Check for NULL pointers */ + /* + * Check parameters + * + * Note "stack_pointer" is not checked, because in certain configurations it can be validly null. + */ OS_CHECK_POINTER(task_id); OS_CHECK_POINTER(function_pointer); OS_CHECK_APINAME(task_name); @@ -381,6 +385,7 @@ int32 OS_TaskGetIdByName(osal_id_t *task_id, const char *task_name) { int32 return_code; + /* Check parameters */ OS_CHECK_POINTER(task_id); OS_CHECK_POINTER(task_name); diff --git a/src/os/shared/src/osapi-time.c b/src/os/shared/src/osapi-time.c index 11e654caa..fd834944f 100644 --- a/src/os/shared/src/osapi-time.c +++ b/src/os/shared/src/osapi-time.c @@ -106,7 +106,9 @@ static int32 OS_DoTimerAdd(osal_id_t *timer_id, const char *timer_name, osal_id_ OS_timebase_internal_record_t *timebase; /* - ** Check Parameters + * Check parameters + * + * Note "callback_arg" is not checked, because in certain configurations it can be validly null. */ OS_CHECK_POINTER(timer_id); OS_CHECK_APINAME(timer_name); @@ -478,6 +480,7 @@ int32 OS_TimerGetIdByName(osal_id_t *timer_id, const char *timer_name) int32 return_code; osal_objtype_t objtype; + /* Check parameters */ OS_CHECK_POINTER(timer_id); OS_CHECK_POINTER(timer_name); diff --git a/src/os/shared/src/osapi-timebase.c b/src/os/shared/src/osapi-timebase.c index affca25fb..219f3e549 100644 --- a/src/os/shared/src/osapi-timebase.c +++ b/src/os/shared/src/osapi-timebase.c @@ -263,6 +263,7 @@ int32 OS_TimeBaseGetIdByName(osal_id_t *timer_id, const char *timebase_name) int32 return_code; osal_objtype_t objtype; + /* Check parameters */ OS_CHECK_POINTER(timer_id); OS_CHECK_APINAME(timebase_name); diff --git a/src/unit-test-coverage/shared/src/coveragetest-idmap.c b/src/unit-test-coverage/shared/src/coveragetest-idmap.c index 6f7a4db4f..ee8270dd8 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-idmap.c +++ b/src/unit-test-coverage/shared/src/coveragetest-idmap.c @@ -429,8 +429,7 @@ void Test_OS_ObjectIdFindByName(void) char TaskName[] = "UT_find"; osal_id_t objid; int32 expected = OS_ERR_NAME_NOT_FOUND; - int32 actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_UNDEFINED, NULL, NULL); - + int32 actual = OS_ObjectIdFindByName(OS_OBJECT_TYPE_UNDEFINED, NULL, &objid); UtAssert_True(actual == expected, "OS_ObjectFindIdByName(%s) (%ld) == OS_ERR_NAME_NOT_FOUND", "NULL", (long)actual); /*