From c60a8656a8147655d96c09db6b875ace5680f7ad Mon Sep 17 00:00:00 2001 From: Sandipan Patra Date: Fri, 18 Dec 2015 10:07:59 +0530 Subject: [PATCH] Fixed issues reported by Static analysis tool Change-Id: Ide1887b36b7cc292a7bc400be7200ed0bf80037b Signed-off-by: Sandipan Patra Reviewed-on: https://gerrit.iotivity.org/gerrit/4659 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- resource/csdk/connectivity/common/src/camutex_pthreads.c | 3 --- resource/csdk/connectivity/common/src/ulinklist.c | 14 ++++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/resource/csdk/connectivity/common/src/camutex_pthreads.c b/resource/csdk/connectivity/common/src/camutex_pthreads.c index 7132f42..bc0dc28 100644 --- a/resource/csdk/connectivity/common/src/camutex_pthreads.c +++ b/resource/csdk/connectivity/common/src/camutex_pthreads.c @@ -139,7 +139,6 @@ void ca_mutex_lock(ca_mutex mutex) if (mutexInfo) { int ret = pthread_mutex_lock(&mutexInfo->mutex); - assert(0 == ret); if(ret != 0) { OIC_LOG_V(ERROR, TAG, "Pthread Mutex lock failed: %d", ret); @@ -190,8 +189,6 @@ void ca_mutex_unlock(ca_mutex mutex) if (mutexInfo) { int ret = pthread_mutex_unlock(&mutexInfo->mutex); - - assert ( 0 == ret); if(ret != 0) { OIC_LOG_V(ERROR, TAG, "Pthread Mutex unlock failed: %d", ret); diff --git a/resource/csdk/connectivity/common/src/ulinklist.c b/resource/csdk/connectivity/common/src/ulinklist.c index e796f4b..5dedb6b 100644 --- a/resource/csdk/connectivity/common/src/ulinklist.c +++ b/resource/csdk/connectivity/common/src/ulinklist.c @@ -113,15 +113,17 @@ CAResult_t u_linklist_free(u_linklist_t **linklist) u_linklist_data_t *free_node=NULL; while((*linklist)->size) { - free_node = (*linklist)->list; - (*linklist)->list = (*linklist)->list->next; - - if(free_node != NULL) + //Size is more but no node in linked list + if(!(*linklist)->list) { - OICFree(free_node); - free_node=NULL; + OIC_LOG(ERROR, TAG, "Trying to free Empty List!!"); + return CA_STATUS_FAILED; } + free_node = (*linklist)->list; + (*linklist)->list = (*linklist)->list->next; + OICFree(free_node); + free_node=NULL; (*linklist)->size -= 1; } -- 2.7.4