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
SetThreadName(const std::string& name)
{
#ifdef POSIX
#if defined(POSIX) || __MINGW32__
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
/* on bsd this function has void return type */
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
// in CR 8158 <https://www.illumos.org/issues/8158>
// 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());
#else
#error "unsupported platform"
@ -46,8 +46,6 @@ namespace llarp
#endif
#elif _MSC_VER
::SetThreadName(::GetCurrentThreadId(), name.c_str());
#elif __MINGW32__
const int rc = pthread_setname_np(pthread_self(), name.c_str());
#else
LogInfo("Thread name setting not supported on this platform");
(void)name;

Loading…
Cancel
Save