Skip to contentSkip to conversation

qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute

RFC PATCH In review Philippe Mathieu-Daudé 2 participants 2 messages Jun 1, 2020

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute

After upgrading to Ubuntu 20.04 LTS, GCC 9.3 complains:

util/qemu-thread-posix.c: In function ‘qemu_thread_exit’:
util/qemu-thread-posix.c:577:6: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
577 | void qemu_thread_exit(void *retval)
| ^~~~~~~~~~~~~~~~

Fix by marking the qemu_thread_exit function with QEMU_NORETURN to set the 'noreturn' attribute.

---
RFC because I'm not sure the error is correct, or we should simply ignore it by default with -Wno-suggest-attribute=noreturn.

---
 include/qemu/thread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/qemu/thread.h +1 -1
index d22848138e..06c058fb58 100644
@@ -177,7 +177,7 @@ void qemu_thread_create(QemuThread *thread, const char *name,
 void *qemu_thread_join(QemuThread *thread);
 void qemu_thread_get_self(QemuThread *thread);
 bool qemu_thread_is_self(QemuThread *thread);
-void qemu_thread_exit(void *retval);
+void qemu_thread_exit(void *retval) QEMU_NORETURN;
 void qemu_thread_naming(bool enable);
 
 struct Notifier;
Signature · 1 line
2.21.3
#1 lore raw
Quoted 24 lines · Philippe Mathieu-Daudé

After upgrading to Ubuntu 20.04 LTS, GCC 9.3 complains:

util/qemu-thread-posix.c: In function ‘qemu_thread_exit’:
util/qemu-thread-posix.c:577:6: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
577 | void qemu_thread_exit(void *retval)
| ^~~~~~~~~~~~~~~~

Fix by marking the qemu_thread_exit function with QEMU_NORETURN to set the 'noreturn' attribute.

---
RFC because I'm not sure the error is correct, or we should simply ignore it by default with -Wno-suggest-attribute=noreturn.

---
 include/qemu/thread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/qemu/thread.h +0 -0
index d22848138e..06c058fb58 100644

include/qemu/thread.h void qemu_thread_create(QemuThread *thread, const char *name, · line 183

Quoted 8 lines
include/qemu/thread.h +1 -1
@@ -177,7 +177,7 @@ void qemu_thread_create(QemuThread *thread, const char *name,
 void *qemu_thread_join(QemuThread *thread);
 void qemu_thread_get_self(QemuThread *thread);
 bool qemu_thread_is_self(QemuThread *thread);
-void qemu_thread_exit(void *retval);
+void qemu_thread_exit(void *retval) QEMU_NORETURN;
 void qemu_thread_naming(bool enable);
 
 struct Notifier;

Yes, it's correct. Queued, thanks.

Paolo