diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2013-12-17 19:10:16 -0200 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2013-12-17 19:10:16 -0200 |
commit | d96ca9c42930a2a0942b807b9afb3053f38ec9b9 (patch) | |
tree | b60b2b71eee2f24076a25dcd70fa009dd9d9393b | |
parent | 9f02561d84235608c3c97ef97e957e331a4c1d82 (diff) | |
download | kmod-d96ca9c42930a2a0942b807b9afb3053f38ec9b9.tar.gz kmod-d96ca9c42930a2a0942b807b9afb3053f38ec9b9.tar.bz2 kmod-d96ca9c42930a2a0942b807b9afb3053f38ec9b9.zip |
Use C11's noreturn
Also define noreturn w/o <stdnoreturn.h> and move it to macro.h instead
of in the testsuite.
Based on similar commit on systemd by Shawn Landden
<shawn@churchofgit.com>.
-rw-r--r-- | libkmod/macro.h | 10 | ||||
-rw-r--r-- | testsuite/test-depmod.c | 2 | ||||
-rw-r--r-- | testsuite/test-init.c | 6 | ||||
-rw-r--r-- | testsuite/test-modinfo.c | 2 | ||||
-rw-r--r-- | testsuite/test-modprobe.c | 14 | ||||
-rw-r--r-- | testsuite/test-testsuite.c | 2 | ||||
-rw-r--r-- | testsuite/testsuite.h | 10 |
7 files changed, 32 insertions, 14 deletions
diff --git a/libkmod/macro.h b/libkmod/macro.h index 5396598..b033bba 100644 --- a/libkmod/macro.h +++ b/libkmod/macro.h @@ -58,3 +58,13 @@ #define _unused_ __attribute__((unused)) #define _always_inline_ __inline__ __attribute__((always_inline)) #define _cleanup_(x) __attribute__((cleanup(x))) + +/* Define C11 noreturn without <stdnoreturn.h> and even on older gcc + * compiler versions */ +#ifndef noreturn +#if __STDC_VERSION__ >= 201112L +#define noreturn _Noreturn +#else +#define noreturn __attribute__((noreturn)) +#endif +#endif diff --git a/testsuite/test-depmod.c b/testsuite/test-depmod.c index 0ea8982..e21b4f0 100644 --- a/testsuite/test-depmod.c +++ b/testsuite/test-depmod.c @@ -29,7 +29,7 @@ #define MODULES_ORDER_UNAME "3.5.4-1-ARCH" #define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-compressed" #define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS "/lib/modules/" MODULES_ORDER_UNAME -static __noreturn int depmod_modules_order_for_compressed(const struct test *t) +static noreturn int depmod_modules_order_for_compressed(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; const char *const args[] = { diff --git a/testsuite/test-init.c b/testsuite/test-init.c index 47a6512..63b6501 100644 --- a/testsuite/test-init.c +++ b/testsuite/test-init.c @@ -26,7 +26,7 @@ #include "testsuite.h" -static __noreturn int test_initlib(const struct test *t) +static noreturn int test_initlib(const struct test *t) { struct kmod_ctx *ctx; const char *null_config = NULL; @@ -42,7 +42,7 @@ static __noreturn int test_initlib(const struct test *t) static DEFINE_TEST(test_initlib, .description = "test if libkmod's init function work"); -static __noreturn int test_insert(const struct test *t) +static noreturn int test_insert(const struct test *t) { struct kmod_ctx *ctx; struct kmod_module *mod; @@ -76,7 +76,7 @@ static DEFINE_TEST(test_insert, }, .need_spawn = true); -static __noreturn int test_remove(const struct test *t) +static noreturn int test_remove(const struct test *t) { struct kmod_ctx *ctx; struct kmod_module *mod; diff --git a/testsuite/test-modinfo.c b/testsuite/test-modinfo.c index e372310..918ed3a 100644 --- a/testsuite/test-modinfo.c +++ b/testsuite/test-modinfo.c @@ -26,7 +26,7 @@ #include "testsuite.h" -static __noreturn int modinfo_jonsmodules(const struct test *t) +static noreturn int modinfo_jonsmodules(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modinfo"; const char *const args[] = { diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c index 0ae03a6..637d363 100644 --- a/testsuite/test-modprobe.c +++ b/testsuite/test-modprobe.c @@ -26,7 +26,7 @@ #include "testsuite.h" -static __noreturn int modprobe_show_depends(const struct test *t) +static noreturn int modprobe_show_depends(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -48,7 +48,7 @@ static DEFINE_TEST(modprobe_show_depends, .out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct.txt", }); -static __noreturn int modprobe_show_depends2(const struct test *t) +static noreturn int modprobe_show_depends2(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -71,7 +71,7 @@ static DEFINE_TEST(modprobe_show_depends2, }); -static __noreturn int modprobe_show_alias_to_none(const struct test *t) +static noreturn int modprobe_show_alias_to_none(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -94,7 +94,7 @@ static DEFINE_TEST(modprobe_show_alias_to_none, }); -static __noreturn int modprobe_builtin(const struct test *t) +static noreturn int modprobe_builtin(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -113,7 +113,7 @@ static DEFINE_TEST(modprobe_builtin, [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/builtin", }); -static __noreturn int modprobe_softdep_loop(const struct test *t) +static noreturn int modprobe_softdep_loop(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -133,7 +133,7 @@ static DEFINE_TEST(modprobe_softdep_loop, [TC_INIT_MODULE_RETCODES] = "", }); -static __noreturn int modprobe_install_cmd_loop(const struct test *t) +static noreturn int modprobe_install_cmd_loop(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { @@ -158,7 +158,7 @@ static DEFINE_TEST(modprobe_install_cmd_loop, }, ); -static __noreturn int modprobe_param_kcmdline(const struct test *t) +static noreturn int modprobe_param_kcmdline(const struct test *t) { const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; const char *const args[] = { diff --git a/testsuite/test-testsuite.c b/testsuite/test-testsuite.c index f52dd1f..a22911d 100644 --- a/testsuite/test-testsuite.c +++ b/testsuite/test-testsuite.c @@ -32,7 +32,7 @@ #define TEST_UNAME "4.0.20-kmod" -static __noreturn int testsuite_uname(const struct test *t) +static noreturn int testsuite_uname(const struct test *t) { struct utsname u; int err = uname(&u); diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h index e4f3ecf..97183cd 100644 --- a/testsuite/testsuite.h +++ b/testsuite/testsuite.h @@ -21,6 +21,8 @@ #include <stdbool.h> #include <stdarg.h> +#include "macro.h" + struct test; typedef int (*testfunc)(const struct test *t); @@ -152,4 +154,10 @@ int test_run(const struct test *t); exit(EXIT_SUCCESS); \ } \ -#define __noreturn __attribute__((noreturn)) +#ifdef noreturn +# define __noreturn noreturn +#elif __STDC_VERSION__ >= 201112L +# define __noreturn _Noreturn +#else +# define __noreturn __attribute__((noreturn)) +#endif |