[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/6] Enable use of -Wmissing-noreturn



* src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
* src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
  with ATTRIBUTE_NO_RETURN
* tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
* m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
---
 m4/virt-compile-warnings.m4 |    1 -
 src/internal.h              |    9 +++++++++
 src/lxc/lxc_container.c     |    3 ++-
 tests/eventtest.c           |    3 +--
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 51e21a9..9643419 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -45,7 +45,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
         dontwarn="$dontwarn -Wconversion"
         dontwarn="$dontwarn -Wsign-conversion"
         dontwarn="$dontwarn -Wold-style-definition"
-        dontwarn="$dontwarn -Wmissing-noreturn"
         dontwarn="$dontwarn -Wpacked"
         dontwarn="$dontwarn -Wunused-macros"
         dontwarn="$dontwarn -Woverlength-strings"
diff --git a/src/internal.h b/src/internal.h
index 2afbd8d..4641fc1 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -117,6 +117,15 @@
 #  endif
 
 /**
+ * ATTRIBUTE_NORETURN:
+ *
+ * Macro to indicate that a function won't return to the caller
+ */
+#  ifndef ATTRIBUTE_NORETURN
+#   define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
+#  endif
+
+/**
  * ATTRIBUTE_SENTINEL:
  *
  * Macro to check for NULL-terminated varargs lists
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 9830b71..af453f3 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -914,7 +914,8 @@ int lxcContainerStart(virDomainDefPtr def,
     return pid;
 }
 
-static int lxcContainerDummyChild(void *argv ATTRIBUTE_UNUSED)
+ATTRIBUTE_NORETURN static int
+lxcContainerDummyChild(void *argv ATTRIBUTE_UNUSED)
 {
     _exit(0);
 }
diff --git a/tests/eventtest.c b/tests/eventtest.c
index 4d22070..eb4b755 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -119,7 +119,7 @@ static pthread_cond_t eventThreadJobCond = PTHREAD_COND_INITIALIZER;
 static int eventThreadJobDone = 0;
 
 
-static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
+ATTRIBUTE_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
     while (1) {
         pthread_mutex_lock(&eventThreadMutex);
         while (!eventThreadRunOnce) {
@@ -135,7 +135,6 @@ static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) {
         pthread_cond_signal(&eventThreadJobCond);
         pthread_mutex_unlock(&eventThreadMutex);
     }
-    return NULL;
 }
 
 
-- 
1.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]