]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Use C11's noreturn
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 17 Dec 2013 21:10:16 +0000 (19:10 -0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 17 Dec 2013 21:10:16 +0000 (19:10 -0200)
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>.

libkmod/macro.h
testsuite/test-depmod.c
testsuite/test-init.c
testsuite/test-modinfo.c
testsuite/test-modprobe.c
testsuite/test-testsuite.c
testsuite/testsuite.h

index 5396598d935a4738912c2c48e1702514a6802eb5..b033bba6ba20de391a54b77ab77b442377d71cff 100644 (file)
 #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
index 0ea89829ca3aa70a8c106de568e4bee668dae79c..e21b4f0fe9f6cc69f2eaf6002991bfdf5f61fd4c 100644 (file)
@@ -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[] = {
index 47a65127aa4c1b3507c7614e780b44f6540c16f3..63b65013b0f755984ec358e65735ec81a27d3147 100644 (file)
@@ -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;
index e372310a0b7a001194b10b65777e22522926d7c5..918ed3a9eccc60c93b8ce48b23989c8f3d51ef50 100644 (file)
@@ -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[] = {
index 0ae03a639dbb2e1e712c53edc94d48888f7bc36e..637d363ea824cb1d08408358732e43c5b09b9b49 100644 (file)
@@ -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[] = {
index f52dd1fdf822aaba0c89a92811f2f335d49d26a1..a22911d4d0349c431e65a488951ac317e38b466d 100644 (file)
@@ -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);
index e4f3ecfac8492ac1558be8495fa4288a6104d38b..97183cdedea81e0f37771caff0770ac364dbabc1 100644 (file)
@@ -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