mbedtls: replace macro constant with `CURL_ARRAYSIZE()`
No binary (build failed)
—
(log yok)
| @@ -37,17 +37,14 @@ | |
| #include "mbedtls_threadlock.h" | |
| - | /* number of thread locks */ |
| - | #define NUMT 2 |
| - | |
| - | /* This array stores the mutexes available to Mbedtls */ |
| - | static MBEDTLS_MUTEX_T mutex_buf[NUMT]; |
| + | /* This array stores the mutexes available to mbedTLS */ |
| + | static MBEDTLS_MUTEX_T mutex_buf[2]; |
| int Curl_mbedtlsthreadlock_thread_setup(void) | |
| { | |
| - | int i; |
| + | size_t i; |
| - | for(i = 0; i < NUMT; i++) { |
| + | for(i = 0; i < CURL_ARRAYSIZE(mutex_buf); i++) { |
| #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) | |
| if(pthread_mutex_init(&mutex_buf[i], NULL)) | |
| return 0; /* pthread_mutex_init failed */ | |
| @@ -63,9 +60,9 @@ int Curl_mbedtlsthreadlock_thread_setup(void) | |
| int Curl_mbedtlsthreadlock_thread_cleanup(void) | |
| { | |
| - | int i; |
| + | size_t i; |
| - | for(i = 0; i < NUMT; i++) { |
| + | for(i = 0; i < CURL_ARRAYSIZE(mutex_buf); i++) { |
| #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) | |
| if(pthread_mutex_destroy(&mutex_buf[i])) | |
| return 0; /* pthread_mutex_destroy failed */ | |
| @@ -78,9 +75,9 @@ int Curl_mbedtlsthreadlock_thread_cleanup(void) | |
| return 1; /* OK */ | |
| } | |
| - | int Curl_mbedtlsthreadlock_lock_function(int n) |
| + | int Curl_mbedtlsthreadlock_lock_function(size_t n) |
| { | |
| - | if(n < NUMT) { |
| + | if(n < CURL_ARRAYSIZE(mutex_buf)) { |
| #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) | |
| if(pthread_mutex_lock(&mutex_buf[n])) { | |
| DEBUGF(curl_mfprintf(stderr, "Error: " | |
| @@ -98,9 +95,9 @@ int Curl_mbedtlsthreadlock_lock_function(int n) | |
| return 1; /* OK */ | |
| } | |
| - | int Curl_mbedtlsthreadlock_unlock_function(int n) |
| + | int Curl_mbedtlsthreadlock_unlock_function(size_t n) |
| { | |
| - | if(n < NUMT) { |
| + | if(n < CURL_ARRAYSIZE(mutex_buf)) { |
| #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) | |
| if(pthread_mutex_unlock(&mutex_buf[n])) { | |
| DEBUGF(curl_mfprintf(stderr, "Error: " | |
| @@ -33,8 +33,8 @@ | |
| int Curl_mbedtlsthreadlock_thread_setup(void); | |
| int Curl_mbedtlsthreadlock_thread_cleanup(void); | |
| - | int Curl_mbedtlsthreadlock_lock_function(int n); |
| - | int Curl_mbedtlsthreadlock_unlock_function(int n); |
| + | int Curl_mbedtlsthreadlock_lock_function(size_t n); |
| + | int Curl_mbedtlsthreadlock_unlock_function(size_t n); |
| #else | |