summaryrefslogtreecommitdiff
path: root/src/common/compat_pthreads.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-03-13 09:41:49 -0400
committerNick Mathewson <nickm@torproject.org>2015-03-13 09:41:49 -0400
commit3a68f2f54ed67176a8ed0b7aa276ef58a54b26db (patch)
tree2384f4434651629918e6c2de50d2308836bca7cc /src/common/compat_pthreads.c
parent833b6d30bec568660e3a9cdeacd1e8c2837f1a6a (diff)
downloadtor-3a68f2f54ed67176a8ed0b7aa276ef58a54b26db.tar.gz
tor-3a68f2f54ed67176a8ed0b7aa276ef58a54b26db.zip
const-ify the new failure vars, and one old one
Diffstat (limited to 'src/common/compat_pthreads.c')
-rw-r--r--src/common/compat_pthreads.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c
index 70259a8a53..fdc504690b 100644
--- a/src/common/compat_pthreads.c
+++ b/src/common/compat_pthreads.c
@@ -91,10 +91,9 @@ static pthread_mutexattr_t attr_recursive;
void
tor_mutex_init(tor_mutex_t *mutex)
{
- int err;
if (PREDICT_UNLIKELY(!threads_initialized))
tor_threads_init();
- err = pthread_mutex_init(&mutex->mutex, &attr_recursive);
+ const int err = pthread_mutex_init(&mutex->mutex, &attr_recursive);
if (PREDICT_UNLIKELY(err)) {
log_err(LD_GENERAL, "Error %d creating a mutex.", err);
tor_fragile_assert();
@@ -276,16 +275,16 @@ void
tor_threads_init(void)
{
if (!threads_initialized) {
- int ret;
pthread_mutexattr_init(&attr_recursive);
pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE);
- ret = pthread_attr_init(&attr_detached);
- tor_assert(ret == 0);
+ const int ret1 = pthread_attr_init(&attr_detached);
+ tor_assert(ret1 == 0);
#ifndef PTHREAD_CREATE_DETACHED
#define PTHREAD_CREATE_DETACHED 1
#endif
- ret = pthread_attr_setdetachstate(&attr_detached, PTHREAD_CREATE_DETACHED);
- tor_assert(ret == 0);
+ const int ret2 =
+ pthread_attr_setdetachstate(&attr_detached, PTHREAD_CREATE_DETACHED);
+ tor_assert(ret2 == 0);
threads_initialized = 1;
set_main_thread();
}