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
This commit is contained in:
Daniel P. Berrange 2010-07-16 17:16:19 +01:00
parent 7d76d5d506
commit 329e9dc629
4 changed files with 12 additions and 4 deletions

View File

@ -63,7 +63,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"

View File

@ -116,6 +116,15 @@
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
# 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:
*

View File

@ -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);
}

View File

@ -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;
}