Function pthread_getname_np() is already calling strlen() on the source
string. So use simple memcpy() with length of already calculated source
string size. There is no need to use StringCchCopyNA() in this case.
---
mingw-w64-libraries/winpthreads/src/thread.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/mingw-w64-libraries/winpthreads/src/thread.c
b/mingw-w64-libraries/winpthreads/src/thread.c
index 80a132d3de09..f32dcc6ecb02 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -42,7 +42,6 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#include <strsafe.h>
#define WINPTHREAD_THREAD_DECL WINPTHREAD_API
@@ -1889,8 +1888,8 @@ pthread_setname_np (pthread_t thread, const char *name)
int
pthread_getname_np (pthread_t thread, char *name, size_t len)
{
- HRESULT result;
struct _pthread_v *tv;
+ size_t thread_name_len;
if (name == NULL)
return EINVAL;
@@ -1909,12 +1908,10 @@ pthread_getname_np (pthread_t thread, char *name,
size_t len)
return 0;
}
- if (strlen (tv->thread_name) >= len)
+ thread_name_len = strlen (tv->thread_name);
+ if (thread_name_len >= len)
return ERANGE;
- result = StringCchCopyNA (name, len, tv->thread_name, len - 1);
- if (SUCCEEDED (result))
- return 0;
-
- return ERANGE;
+ memcpy (name, tv->thread_name, thread_name_len + 1);
+ return 0;
}
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public