[systemd-devel] [PATCH] _noreturn_ --> noreturn for C11 compat

Shawn Landden shawn at churchofgit.com
Mon Dec 16 08:53:53 PST 2013


also define noreturn w/o <stdnoreturn.h>
---
 src/core/main.c                         |  2 +-
 src/journal/test-journal-interleaving.c |  2 +-
 src/shared/log.c                        |  4 ++--
 src/shared/log.h                        |  4 ++--
 src/shared/macro.h                      | 10 +++++++++-
 src/shared/pager.c                      |  2 +-
 src/shared/util.c                       |  2 +-
 src/shared/util.h                       |  2 +-
 src/udev/collect/collect.c              |  2 +-
 9 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/core/main.c b/src/core/main.c
index 6c3d9bf..eb5413e 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -112,7 +112,7 @@ static FILE* serialization = NULL;
 static void nop_handler(int sig) {
 }
 
-_noreturn_ static void crash(int sig) {
+noreturn static void crash(int sig) {
 
         if (getpid() != 1)
                 /* Pass this on immediately, if this is not PID 1 */
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index af0d43e..5b74714 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -36,7 +36,7 @@
 
 static bool arg_keep = false;
 
-_noreturn_ static void log_assert_errno(const char *text, int eno, const char *file, int line, const char *func) {
+noreturn static void log_assert_errno(const char *text, int eno, const char *file, int line, const char *func) {
         log_meta(LOG_CRIT, file, line, func,
                  "'%s' failed at %s:%u (%s): %s.",
                  text, file, line, func, strerror(eno));
diff --git a/src/shared/log.c b/src/shared/log.c
index 2404de8..2517f5d 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -702,12 +702,12 @@ static void log_assert(int level, const char *text, const char *file, int line,
 }
 #pragma GCC diagnostic pop
 
-_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) {
+noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) {
         log_assert(LOG_CRIT, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
         abort();
 }
 
-_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) {
+noreturn void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) {
         log_assert(LOG_CRIT, text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
         abort();
 }
diff --git a/src/shared/log.h b/src/shared/log.h
index de0e000..3dcfa11 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -124,13 +124,13 @@ int log_dump_internal(
                 const char *func,
                 char *buffer);
 
-_noreturn_ void log_assert_failed(
+noreturn void log_assert_failed(
                 const char *text,
                 const char *file,
                 int line,
                 const char *func);
 
-_noreturn_ void log_assert_failed_unreachable(
+noreturn void log_assert_failed_unreachable(
                 const char *text,
                 const char *file,
                 int line,
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 362d62b..51af289 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -38,10 +38,18 @@
 # endif
 #endif
 
+/* define noreturn without <stdnoreturn.h> */
+#ifndef noreturn
+# if __STDC_VERSION__ >= 201112L
+#  define noreturn _Noreturn
+# else
+#  define noreturn __attribute__((noreturn))
+# endif
+#endif
+
 #define _printf_(a,b) __attribute__ ((format (printf, a, b)))
 #define _alloc_(...) __attribute__ ((alloc_size(__VA_ARGS__)))
 #define _sentinel_ __attribute__ ((sentinel))
-#define _noreturn_ __attribute__((noreturn))
 #define _unused_ __attribute__ ((unused))
 #define _destructor_ __attribute__ ((destructor))
 #define _pure_ __attribute__ ((pure))
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 9fa6114..72a29f2 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -32,7 +32,7 @@
 
 static pid_t pager_pid = 0;
 
-_noreturn_ static void pager_fallback(void) {
+noreturn static void pager_fallback(void) {
         ssize_t n;
 
         do {
diff --git a/src/shared/util.c b/src/shared/util.c
index 0ce6f70..e1f92fd 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3469,7 +3469,7 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid) {
         return -EPROTO;
 }
 
-_noreturn_ void freeze(void) {
+noreturn void freeze(void) {
 
         /* Make sure nobody waits for us on a socket anymore */
         close_all_fds(NULL, 0);
diff --git a/src/shared/util.h b/src/shared/util.h
index d5fa81c..d43aeff 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -417,7 +417,7 @@ char *normalize_env_assignment(const char *s);
 int wait_for_terminate(pid_t pid, siginfo_t *status);
 int wait_for_terminate_and_warn(const char *name, pid_t pid);
 
-_noreturn_ void freeze(void);
+noreturn void freeze(void);
 
 bool null_or_empty(struct stat *st) _pure_;
 int null_or_empty_path(const char *fn);
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index 2bbbcd7..cb5df01 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -61,7 +61,7 @@ static inline struct _mate *node_to_mate(struct udev_list_node *node)
         return container_of(node, struct _mate, node);
 }
 
-_noreturn_ static void sig_alrm(int signo)
+noreturn static void sig_alrm(int signo)
 {
         exit(4);
 }
-- 
1.8.5.1



More information about the systemd-devel mailing list