Slightly DRY thread-setting code, fix warning

There were warnings from the rc variable being unused; this DRYes it to
use the same code as linux (including the failure check on rc).
pull/1969/head
Jason Rhinelander 2 years ago
parent 4065413977
commit 84ad0ab4d3
No known key found for this signature in database
GPG Key ID: C4992CE7A88D4262

@ -23,7 +23,7 @@ namespace llarp
void void
SetThreadName(const std::string& name) SetThreadName(const std::string& name)
{ {
#ifdef POSIX #if defined(POSIX) || __MINGW32__
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
/* on bsd this function has void return type */ /* on bsd this function has void return type */
pthread_set_name_np(pthread_self(), name.c_str()); pthread_set_name_np(pthread_self(), name.c_str());
@ -33,7 +33,7 @@ namespace llarp
// API present upstream since v2.11.3 and imported downstream // API present upstream since v2.11.3 and imported downstream
// in CR 8158 <https://www.illumos.org/issues/8158> // in CR 8158 <https://www.illumos.org/issues/8158>
// We only use the native function on Microsoft C++ builds // We only use the native function on Microsoft C++ builds
#elif defined(__linux__) || defined(__sun) #elif defined(__linux__) || defined(__sun) || __MINGW32__
const int rc = pthread_setname_np(pthread_self(), name.c_str()); const int rc = pthread_setname_np(pthread_self(), name.c_str());
#else #else
#error "unsupported platform" #error "unsupported platform"
@ -46,8 +46,6 @@ namespace llarp
#endif #endif
#elif _MSC_VER #elif _MSC_VER
::SetThreadName(::GetCurrentThreadId(), name.c_str()); ::SetThreadName(::GetCurrentThreadId(), name.c_str());
#elif __MINGW32__
const int rc = pthread_setname_np(pthread_self(), name.c_str());
#else #else
LogInfo("Thread name setting not supported on this platform"); LogInfo("Thread name setting not supported on this platform");
(void)name; (void)name;

Loading…
Cancel
Save