eina: replace memsets in thread debugging lock create/free with manual zeroing

Summary:
memset overwrites the thread value, triggering errors when running tools like
helgrind

attempting an operation on an invalid thread will cause errors naturally,
so zeroing the rest of the struct and ignoring the thread member is fine

Reviewers: ManMower, devilhorns

Reviewed By: ManMower

Subscribers: cedric, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6297
This commit is contained in:
Mike Blumenkrantz 2018-06-19 13:30:20 -04:00
parent 90cb995ac9
commit 44bafb0741
2 changed files with 6 additions and 8 deletions

View File

@ -162,6 +162,9 @@ eina_lock_new(Eina_Lock *mutex)
Eina_Bool ret = _eina_lock_new(mutex, EINA_FALSE);
#ifdef EINA_HAVE_DEBUG_THREADS
mutex->recursive = EINA_FALSE;
mutex->lock_thread_id = 0;
mutex->lock_bt_num = 0;
mutex->locked = 0;
#endif
return ret;
}
@ -172,6 +175,9 @@ eina_lock_recursive_new(Eina_Lock *mutex)
Eina_Bool ret = _eina_lock_new(mutex, EINA_TRUE);
#ifdef EINA_HAVE_DEBUG_THREADS
mutex->recursive = EINA_TRUE;
mutex->lock_thread_id = 0;
mutex->lock_bt_num = 0;
mutex->locked = 0;
#endif
return ret;
}

View File

@ -95,7 +95,6 @@ _eina_lock_new(Eina_Lock *mutex, Eina_Bool recursive)
}
#ifdef EINA_HAVE_DEBUG_THREADS
else if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0) goto fail_release;
memset(mutex, 0, sizeof(Eina_Lock));
#endif
if (pthread_mutex_init(&(mutex->mutex), &attr) != 0) goto fail_release;
ok = EINA_TRUE;
@ -111,9 +110,6 @@ _eina_lock_free(Eina_Lock *mutex)
ok = pthread_mutex_destroy(&(mutex->mutex));
if (ok != 0) EINA_LOCK_ABORT_DEBUG(ok, mutex_destroy, mutex);
#ifdef EINA_HAVE_DEBUG_THREADS
memset(mutex, 0, sizeof(Eina_Lock));
#endif
}
EAPI Eina_Bool
@ -124,7 +120,6 @@ _eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
#ifdef EINA_HAVE_DEBUG_THREADS
assert(mutex != NULL);
memset(cond, 0, sizeof (Eina_Condition));
#endif
cond->lock = mutex;
@ -167,9 +162,6 @@ EAPI void
_eina_condition_free(Eina_Condition *cond)
{
pthread_cond_destroy(&(cond->condition));
#ifdef EINA_HAVE_DEBUG_THREADS
memset(cond, 0, sizeof (Eina_Condition));
#endif
}
EAPI Eina_Bool