Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From 848e863acc51ecfb0f3955c498874588201d9130 Mon Sep 17 00:00:00 2001 |
| 2 | From: Franck Bui <fbui@suse.com> |
| 3 | Date: Thu, 15 Mar 2018 06:23:46 +0100 |
| 4 | Subject: [PATCH] basic/macros: rename noreturn into _noreturn_ (#8456) |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | "noreturn" is reserved and can be used in other header files we include: |
| 10 | |
| 11 | [ 16s] In file included from /usr/include/gcrypt.h:30:0, |
| 12 | [ 16s] from ../src/journal/journal-file.h:26, |
| 13 | [ 16s] from ../src/journal/journal-vacuum.c:31: |
| 14 | [ 16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token |
| 15 | [ 16s] void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); |
| 16 | |
| 17 | Here we include grcrypt.h (which in turns include gpg-error.h) *after* we |
| 18 | "noreturn" was defined in macro.h. |
| 19 | --- |
| 20 | src/basic/log.c | 4 ++-- |
| 21 | src/basic/log.h | 4 ++-- |
| 22 | src/basic/macro.h | 19 +++++++++---------- |
| 23 | src/basic/process-util.c | 2 +- |
| 24 | src/basic/process-util.h | 2 +- |
| 25 | src/core/main.c | 4 ++-- |
| 26 | src/journal/test-journal-interleaving.c | 2 +- |
| 27 | src/shared/pager.c | 2 +- |
| 28 | src/udev/collect/collect.c | 2 +- |
| 29 | 9 files changed, 20 insertions(+), 21 deletions(-) |
| 30 | |
| 31 | Upstream-Status: Backport [https://github.com/systemd/systemd/pull/8456] |
| 32 | |
| 33 | diff --git a/src/basic/log.c b/src/basic/log.c |
| 34 | index 7a7f2cbec..16a2431c5 100644 |
| 35 | --- a/src/basic/log.c |
| 36 | +++ b/src/basic/log.c |
| 37 | @@ -814,7 +814,7 @@ static void log_assert( |
| 38 | log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer); |
| 39 | } |
| 40 | |
| 41 | -noreturn void log_assert_failed_realm( |
| 42 | +_noreturn_ void log_assert_failed_realm( |
| 43 | LogRealm realm, |
| 44 | const char *text, |
| 45 | const char *file, |
| 46 | @@ -826,7 +826,7 @@ noreturn void log_assert_failed_realm( |
| 47 | abort(); |
| 48 | } |
| 49 | |
| 50 | -noreturn void log_assert_failed_unreachable_realm( |
| 51 | +_noreturn_ void log_assert_failed_unreachable_realm( |
| 52 | LogRealm realm, |
| 53 | const char *text, |
| 54 | const char *file, |
| 55 | diff --git a/src/basic/log.h b/src/basic/log.h |
| 56 | index efcf0f1bf..314be128a 100644 |
| 57 | --- a/src/basic/log.h |
| 58 | +++ b/src/basic/log.h |
| 59 | @@ -186,7 +186,7 @@ int log_dump_internal( |
| 60 | char *buffer); |
| 61 | |
| 62 | /* Logging for various assertions */ |
| 63 | -noreturn void log_assert_failed_realm( |
| 64 | +_noreturn_ void log_assert_failed_realm( |
| 65 | LogRealm realm, |
| 66 | const char *text, |
| 67 | const char *file, |
| 68 | @@ -195,7 +195,7 @@ noreturn void log_assert_failed_realm( |
| 69 | #define log_assert_failed(text, ...) \ |
| 70 | log_assert_failed_realm(LOG_REALM, (text), __VA_ARGS__) |
| 71 | |
| 72 | -noreturn void log_assert_failed_unreachable_realm( |
| 73 | +_noreturn_ void log_assert_failed_unreachable_realm( |
| 74 | LogRealm realm, |
| 75 | const char *text, |
| 76 | const char *file, |
| 77 | diff --git a/src/basic/macro.h b/src/basic/macro.h |
| 78 | index 95be63a20..8911edfc4 100644 |
| 79 | --- a/src/basic/macro.h |
| 80 | +++ b/src/basic/macro.h |
| 81 | @@ -53,6 +53,15 @@ |
| 82 | #else |
| 83 | #define _fallthrough_ |
| 84 | #endif |
| 85 | +/* Define C11 noreturn without <stdnoreturn.h> and even on older gcc |
| 86 | + * compiler versions */ |
| 87 | +#ifndef _noreturn_ |
| 88 | +#if __STDC_VERSION__ >= 201112L |
| 89 | +#define _noreturn_ _Noreturn |
| 90 | +#else |
| 91 | +#define _noreturn_ __attribute__((noreturn)) |
| 92 | +#endif |
| 93 | +#endif |
| 94 | |
| 95 | /* Temporarily disable some warnings */ |
| 96 | #define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT \ |
| 97 | @@ -414,16 +423,6 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { |
| 98 | #endif |
| 99 | #endif |
| 100 | |
| 101 | -/* Define C11 noreturn without <stdnoreturn.h> and even on older gcc |
| 102 | - * compiler versions */ |
| 103 | -#ifndef noreturn |
| 104 | -#if __STDC_VERSION__ >= 201112L |
| 105 | -#define noreturn _Noreturn |
| 106 | -#else |
| 107 | -#define noreturn __attribute__((noreturn)) |
| 108 | -#endif |
| 109 | -#endif |
| 110 | - |
| 111 | #define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \ |
| 112 | static inline void func##p(type *p) { \ |
| 113 | if (*p) \ |
| 114 | diff --git a/src/basic/process-util.c b/src/basic/process-util.c |
| 115 | index aa9846db5..e6120af5b 100644 |
| 116 | --- a/src/basic/process-util.c |
| 117 | +++ b/src/basic/process-util.c |
| 118 | @@ -987,7 +987,7 @@ bool is_main_thread(void) { |
| 119 | return cached > 0; |
| 120 | } |
| 121 | |
| 122 | -noreturn void freeze(void) { |
| 123 | +_noreturn_ void freeze(void) { |
| 124 | |
| 125 | log_close(); |
| 126 | |
| 127 | diff --git a/src/basic/process-util.h b/src/basic/process-util.h |
| 128 | index 93029e36e..5170adec7 100644 |
| 129 | --- a/src/basic/process-util.h |
| 130 | +++ b/src/basic/process-util.h |
| 131 | @@ -91,7 +91,7 @@ int pid_from_same_root_fs(pid_t pid); |
| 132 | |
| 133 | bool is_main_thread(void); |
| 134 | |
| 135 | -noreturn void freeze(void); |
| 136 | +_noreturn_ void freeze(void); |
| 137 | |
| 138 | bool oom_score_adjust_is_valid(int oa); |
| 139 | |
| 140 | diff --git a/src/core/main.c b/src/core/main.c |
| 141 | index 076846a41..4b2d14923 100644 |
| 142 | --- a/src/core/main.c |
| 143 | +++ b/src/core/main.c |
| 144 | @@ -141,7 +141,7 @@ static uint64_t arg_default_tasks_max = UINT64_MAX; |
| 145 | static sd_id128_t arg_machine_id = {}; |
| 146 | static EmergencyAction arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE; |
| 147 | |
| 148 | -noreturn static void freeze_or_reboot(void) { |
| 149 | +_noreturn_ static void freeze_or_reboot(void) { |
| 150 | |
| 151 | if (arg_crash_reboot) { |
| 152 | log_notice("Rebooting in 10s..."); |
| 153 | @@ -156,7 +156,7 @@ noreturn static void freeze_or_reboot(void) { |
| 154 | freeze(); |
| 155 | } |
| 156 | |
| 157 | -noreturn static void crash(int sig) { |
| 158 | +_noreturn_ static void crash(int sig) { |
| 159 | struct sigaction sa; |
| 160 | pid_t pid; |
| 161 | |
| 162 | diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c |
| 163 | index 5a88b2774..d87bdbdd3 100644 |
| 164 | --- a/src/journal/test-journal-interleaving.c |
| 165 | +++ b/src/journal/test-journal-interleaving.c |
| 166 | @@ -37,7 +37,7 @@ |
| 167 | |
| 168 | static bool arg_keep = false; |
| 169 | |
| 170 | -noreturn static void log_assert_errno(const char *text, int error, const char *file, int line, const char *func) { |
| 171 | +_noreturn_ static void log_assert_errno(const char *text, int error, const char *file, int line, const char *func) { |
| 172 | log_internal(LOG_CRIT, error, file, line, func, |
| 173 | "'%s' failed at %s:%u (%s): %m", text, file, line, func); |
| 174 | abort(); |
| 175 | diff --git a/src/shared/pager.c b/src/shared/pager.c |
| 176 | index 75db3c985..681af9c40 100644 |
| 177 | --- a/src/shared/pager.c |
| 178 | +++ b/src/shared/pager.c |
| 179 | @@ -47,7 +47,7 @@ static int stored_stderr = -1; |
| 180 | static bool stdout_redirected = false; |
| 181 | static bool stderr_redirected = false; |
| 182 | |
| 183 | -noreturn static void pager_fallback(void) { |
| 184 | +_noreturn_ static void pager_fallback(void) { |
| 185 | int r; |
| 186 | |
| 187 | r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, (uint64_t) -1, 0); |
| 188 | diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c |
| 189 | index 2821640e9..c8fa47b3d 100644 |
| 190 | --- a/src/udev/collect/collect.c |
| 191 | +++ b/src/udev/collect/collect.c |
| 192 | @@ -58,7 +58,7 @@ static inline struct _mate *node_to_mate(struct udev_list_node *node) |
| 193 | return container_of(node, struct _mate, node); |
| 194 | } |
| 195 | |
| 196 | -noreturn static void sig_alrm(int signo) |
| 197 | +_noreturn_ static void sig_alrm(int signo) |
| 198 | { |
| 199 | exit(4); |
| 200 | } |
| 201 | -- |
| 202 | 2.17.0 |
| 203 | |