From faee7ad2294ff4d70cdec078c8fe9afa5be1f462 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 21 May 2015 17:48:00 +0100 Subject: [PATCH] Correct tag non-returning functions The noreturn attribute can be used to allow the compiler to perform better optimisations and/or warnings. --- src/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 10b655a2..464249a2 100644 --- a/src/main.c +++ b/src/main.c @@ -35,6 +35,14 @@ #define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1)) #endif +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define NO_RETURN [[noreturn]] +#elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define NO_RETURN _Noreturn +#else +#define NO_RETURN +#endif + #include #include #include @@ -131,7 +139,7 @@ static struct mg_option main_config_options[] = { static void WINCDECL signal_handler(int sig_num) { g_exit_flag = sig_num; } -static void die(const char *fmt, ...) +static NO_RETURN void die(const char *fmt, ...) { va_list ap; char msg[200] = ""; @@ -163,7 +171,7 @@ static void show_server_name(void) fprintf(stderr, "CivetWeb v%s, built on %s\n", mg_version(), __DATE__); } -static void show_usage_and_exit(const char *exeName) +static NO_RETURN void show_usage_and_exit(const char *exeName) { const struct mg_option *options; int i;