Skip to contentSkip to conversation

util: fix use of pthread_get_name_np on OpenBSD

PATCH In review Daniel P. Berrangé 3 participants 3 messages Apr 17 – Apr 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 util: fix use of pthread_get_name_np on OpenBSD

The pthread_get_name_np function is present on FreeBSD and OpenBSD and has 'void' return not 'int'. We didn't notice this build problem on FreeBSD since it also has pthread_getname_np which does return int like Linux and we use the latter preferentially.

Fixes 215235d365e49c72a85ea2940751e45419676031

---

This is a regression in the 11.0 release, but on the assumption it is too late for further fixes, I'm CC'ing qemu-stable so this can go into the future stable-11.0 branch

 util/qemu-thread-posix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
util/qemu-thread-posix.c +2 -1
index bd1c2ad2a5..089606c93f 100644
@@ -568,7 +568,8 @@ const char *qemu_thread_get_name(void)
 # if defined(CONFIG_PTHREAD_GETNAME_NP)
     rv = pthread_getname_np(pthread_self(), namebuf, sizeof(namebuf));
 # elif defined(CONFIG_PTHREAD_GET_NAME_NP)
-    rv = pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    rv = 0;
 # else
     rv = -1;
 # endif
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Daniel P. Berrangé

The pthread_get_name_np function is present on FreeBSD and OpenBSD and has 'void' return not 'int'. We didn't notice this build problem on FreeBSD since it also has pthread_getname_np which does return int like Linux and we use the latter preferentially.

Fixes 215235d365e49c72a85ea2940751e45419676031

---

This is a regression in the 11.0 release, but on the assumption it is too late for further fixes, I'm CC'ing qemu-stable so this can go into the future stable-11.0 branch

  util/qemu-thread-posix.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
util/qemu-thread-posix.c +0 -0
index bd1c2ad2a5..089606c93f 100644

util/qemu-thread-posix.c const char *qemu_thread_get_name(void) · line 575

Quoted 9 lines
util/qemu-thread-posix.c +2 -1
@@ -568,7 +568,8 @@ const char *qemu_thread_get_name(void)
  # if defined(CONFIG_PTHREAD_GETNAME_NP)
      rv = pthread_getname_np(pthread_self(), namebuf, sizeof(namebuf));
  # elif defined(CONFIG_PTHREAD_GET_NAME_NP)
-    rv = pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    rv = 0;
  # else
      rv = -1;
  # endif
Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel P. Berrangé
Quoted 22 lines · Daniel P. Berrangé

The pthread_get_name_np function is present on FreeBSD and OpenBSD and has 'void' return not 'int'. We didn't notice this build problem on FreeBSD since it also has pthread_getname_np which does return int like Linux and we use the latter preferentially.

Fixes 215235d365e49c72a85ea2940751e45419676031

---

This is a regression in the 11.0 release, but on the assumption it is too late for further fixes, I'm CC'ing qemu-stable so this can go into the future stable-11.0 branch

  util/qemu-thread-posix.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
util/qemu-thread-posix.c +0 -0
index bd1c2ad2a5..089606c93f 100644

util/qemu-thread-posix.c const char *qemu_thread_get_name(void) · line 575

Quoted 9 lines
util/qemu-thread-posix.c +2 -1
@@ -568,7 +568,8 @@ const char *qemu_thread_get_name(void)
  # if defined(CONFIG_PTHREAD_GETNAME_NP)
      rv = pthread_getname_np(pthread_self(), namebuf, sizeof(namebuf));
  # elif defined(CONFIG_PTHREAD_GET_NAME_NP)
-    rv = pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    pthread_get_name_np(pthread_self(), namebuf, sizeof(namebuf));
+    rv = 0;
  # else
      rv = -1;
  # endif