From 75de63dff10638b79acc726de6068c0f9b6a4f45 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Sat, 4 Apr 2020 15:56:52 +0300 Subject: [PATCH] mdbx: refine type-casting inside mdbx_thread_self() to avoid warning. 2 of 2 for https://github.com/erthink/libmdbx/issues/88 Change-Id: Ic4994141d23a5417b18f6b03a3e4038859fb9210 --- src/elements/osal.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/elements/osal.h b/src/elements/osal.h index ade7a6d1..44d3bd50 100644 --- a/src/elements/osal.h +++ b/src/elements/osal.h @@ -633,12 +633,14 @@ static __maybe_unused __inline uint32_t mdbx_getpid(void) { } static __maybe_unused __inline size_t mdbx_thread_self(void) { - STATIC_ASSERT(sizeof(mdbx_tid_t) <= sizeof(size_t)); + mdbx_tid_t thunk; + STATIC_ASSERT(sizeof(size_t) >= sizeof(thunk)); #if defined(_WIN32) || defined(_WIN64) - return GetCurrentThreadId(); + thunk = GetCurrentThreadId(); #else - return (size_t)pthread_self(); + thunk = pthread_self(); #endif + return (size_t)thunk; } MDBX_INTERNAL_FUNC void __maybe_unused mdbx_osal_jitter(bool tiny);