From f58ed932d80a85e1022c625892f0f2081589a408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ayd=C4=B1n=20Mercan?= Date: Thu, 11 Jul 2024 16:15:40 +0300 Subject: [PATCH] use only c23 or c11 noreturn specifiers Since we require C11 or greater, we can depend on using either _Noreturn or [[noreturn]]. --- bin/check/named-checkconf.c | 2 +- bin/check/named-checkzone.c | 2 +- bin/confgen/rndc-confgen.c | 2 +- bin/confgen/tsig-keygen.c | 2 +- bin/confgen/util.h | 2 +- bin/delv/delv.c | 2 +- bin/dig/dig.c | 2 +- bin/dig/dighost.h | 4 ++-- bin/dig/host.c | 2 +- bin/dig/nslookup.c | 2 +- bin/dnssec/dnssec-cds.c | 2 +- bin/dnssec/dnssec-dsfromkey.c | 2 +- bin/dnssec/dnssec-importkey.c | 2 +- bin/dnssec/dnssec-keyfromlabel.c | 2 +- bin/dnssec/dnssec-keygen.c | 2 +- bin/dnssec/dnssec-revoke.c | 2 +- bin/dnssec/dnssec-settime.c | 2 +- bin/dnssec/dnssec-signzone.c | 2 +- bin/dnssec/dnssec-verify.c | 2 +- bin/dnssec/dnssectool.h | 4 ++-- bin/named/include/named/main.h | 2 +- bin/named/main.c | 4 ++-- bin/named/server.c | 2 +- bin/nsupdate/nsupdate.c | 2 +- bin/rndc/rndc.c | 2 +- bin/rndc/util.h | 2 +- bin/tools/dnstap-read.c | 2 +- bin/tools/mdig.c | 4 ++-- bin/tools/named-rrchecker.c | 4 ++-- bin/tools/nsec3hash.c | 2 +- configure.ac | 9 --------- lib/isc/include/isc/assertions.h | 2 +- lib/isc/include/isc/attributes.h | 8 +++----- lib/isc/include/isc/error.h | 2 +- 34 files changed, 40 insertions(+), 51 deletions(-) diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 00335b6089..70b4b317ba 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -54,7 +54,7 @@ isc_log_t *logc = NULL; } while (0) /*% usage */ -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index db2e345561..a0ddf8a94b 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -62,7 +62,7 @@ static enum { progmode_check, progmode_compile } progmode; } \ } while (0) -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/confgen/rndc-confgen.c b/bin/confgen/rndc-confgen.c index c840e2c284..f96ee47d20 100644 --- a/bin/confgen/rndc-confgen.c +++ b/bin/confgen/rndc-confgen.c @@ -60,7 +60,7 @@ bool verbose = false; const char *keyfile, *keydef; -noreturn static void +ISC_NORETURN static void usage(int status); static void diff --git a/bin/confgen/tsig-keygen.c b/bin/confgen/tsig-keygen.c index c421702c8b..39f13a73fc 100644 --- a/bin/confgen/tsig-keygen.c +++ b/bin/confgen/tsig-keygen.c @@ -53,7 +53,7 @@ const char *progname; static enum { progmode_keygen, progmode_confgen } progmode; bool verbose = false; /* needed by util.c but not used here */ -noreturn static void +ISC_NORETURN static void usage(int status); static void diff --git a/bin/confgen/util.h b/bin/confgen/util.h index 4ac83e5143..0567ad33b1 100644 --- a/bin/confgen/util.h +++ b/bin/confgen/util.h @@ -36,7 +36,7 @@ ISC_LANG_BEGINDECLS void notify(const char *fmt, ...) ISC_FORMAT_PRINTF(1, 2); -noreturn void +ISC_NORETURN void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); ISC_LANG_ENDDECLS diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 36f26f042c..d494500675 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -250,7 +250,7 @@ usage(void) { exit(EXIT_FAILURE); } -noreturn static void +ISC_NORETURN static void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); static void diff --git a/bin/dig/dig.c b/bin/dig/dig.c index e9665c9e01..288b327ef2 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -111,7 +111,7 @@ usage(void) { fprintf(stderr, "Press for complete list of options\n"); } #else /* if TARGET_OS_IPHONE */ -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dig/dighost.h b/bin/dig/dighost.h index 99c0c3c864..56842f9419 100644 --- a/bin/dig/dighost.h +++ b/bin/dig/dighost.h @@ -293,13 +293,13 @@ getaddresses(dig_lookup_t *lookup, const char *host, isc_result_t *resultp); isc_result_t get_reverse(char *reverse, size_t len, char *value, bool strict); -noreturn void +ISC_NORETURN void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); void warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); -noreturn void +ISC_NORETURN void digexit(void); void diff --git a/bin/dig/host.c b/bin/dig/host.c index 6710c981f1..a44acde55c 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -99,7 +99,7 @@ rcode_totext(dns_rcode_t rcode) { return (totext.deconsttext); } -noreturn static void +ISC_NORETURN static void show_usage(void); static void diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 4b813511b7..2c89243751 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -836,7 +836,7 @@ fgets_next_command(void *arg) { cmdline = fgets(cmdlinebuf, COMMSIZE, stdin); } -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index fd877160d8..86aeff0b11 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -1028,7 +1028,7 @@ nsdiff(uint32_t ttl, dns_rdataset_t *oldset, dns_rdataset_t *newset) { } } -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index 466f7ce0fe..97f2a3780d 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -324,7 +324,7 @@ emits(bool showall, bool cds, dns_rdata_t *rdata) { } } -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index 3bb4029052..165707d553 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -262,7 +262,7 @@ emit(const char *dir, dns_rdata_t *rdata) { dst_key_free(&key); } -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index a4afc1f66a..ce823e8f83 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -43,7 +43,7 @@ const char *program = "dnssec-keyfromlabel"; -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 5dce14964f..ffcbaba23e 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -74,7 +74,7 @@ static int min_dh = 128; isc_log_t *lctx = NULL; -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-revoke.c b/bin/dnssec/dnssec-revoke.c index bc2ca62bf2..92169ca7b6 100644 --- a/bin/dnssec/dnssec-revoke.c +++ b/bin/dnssec/dnssec-revoke.c @@ -38,7 +38,7 @@ const char *program = "dnssec-revoke"; static isc_mem_t *mctx = NULL; -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-settime.c b/bin/dnssec/dnssec-settime.c index 3ca072f0e4..5b630ab115 100644 --- a/bin/dnssec/dnssec-settime.c +++ b/bin/dnssec/dnssec-settime.c @@ -42,7 +42,7 @@ const char *program = "dnssec-settime"; static isc_mem_t *mctx = NULL; -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index e17f85325d..82d4cf0721 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -3201,7 +3201,7 @@ print_version(FILE *fp) { fprintf(fp, "; %s version %s\n", program, PACKAGE_VERSION); } -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index 913f463ae5..ce7101c594 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -136,7 +136,7 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) { } } -noreturn static void +ISC_NORETURN static void usage(void); static void diff --git a/bin/dnssec/dnssectool.h b/bin/dnssec/dnssectool.h index aac6a709ad..1107fa7eb1 100644 --- a/bin/dnssec/dnssectool.h +++ b/bin/dnssec/dnssectool.h @@ -54,7 +54,7 @@ extern uint8_t dtype[8]; typedef void(fatalcallback_t)(void); -noreturn void +ISC_NORETURN void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); void @@ -66,7 +66,7 @@ check_result(isc_result_t result, const char *message); void vbprintf(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3); -noreturn void +ISC_NORETURN void version(const char *program); void diff --git a/bin/named/include/named/main.h b/bin/named/include/named/main.h index bed5dd9787..7cf35e0a21 100644 --- a/bin/named/include/named/main.h +++ b/bin/named/include/named/main.h @@ -26,7 +26,7 @@ */ #define NAMED_MAIN_ARGS "46A:c:Cd:D:E:fFgL:M:m:n:N:p:sS:t:T:U:u:vVx:X:" -noreturn void +ISC_NORETURN void named_main_earlyfatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); void diff --git a/bin/named/main.c b/bin/named/main.c index 274c2bbe2c..0d6af4115a 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -197,7 +197,7 @@ named_main_earlyfatal(const char *format, ...) { _exit(EXIT_FAILURE); } -noreturn static void +ISC_NORETURN static void assertion_failed(const char *file, int line, isc_assertiontype_t type, const char *cond); @@ -236,7 +236,7 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type, _exit(EXIT_FAILURE); } -noreturn static void +ISC_NORETURN static void library_fatal_error(const char *file, int line, const char *func, const char *format, va_list args) ISC_FORMAT_PRINTF(3, 0); diff --git a/bin/named/server.c b/bin/named/server.c index 7739d6b6f8..4081047762 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -426,7 +426,7 @@ const char *empty_zones[] = { NULL }; -noreturn static void +ISC_NORETURN static void fatal(const char *msg, isc_result_t result); static void diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index d23b1c6732..5e06051cf6 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -198,7 +198,7 @@ send_update(dns_name_t *zonename, isc_sockaddr_t *primary); static void getinput(void *arg); -noreturn static void +ISC_NORETURN static void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); static void diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 1d35ded62b..b11fbf47d2 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -87,7 +87,7 @@ static int32_t timeout = RNDC_TIMEOUT; static void rndc_startconnect(isc_sockaddr_t *addr); -noreturn static void +ISC_NORETURN static void usage(int status); static void diff --git a/bin/rndc/util.h b/bin/rndc/util.h index 4ac83e5143..0567ad33b1 100644 --- a/bin/rndc/util.h +++ b/bin/rndc/util.h @@ -36,7 +36,7 @@ ISC_LANG_BEGINDECLS void notify(const char *fmt, ...) ISC_FORMAT_PRINTF(1, 2); -noreturn void +ISC_NORETURN void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); ISC_LANG_ENDDECLS diff --git a/bin/tools/dnstap-read.c b/bin/tools/dnstap-read.c index cbc82c33c5..9127fba967 100644 --- a/bin/tools/dnstap-read.c +++ b/bin/tools/dnstap-read.c @@ -72,7 +72,7 @@ const char *program = "dnstap-read"; } \ } while (0) -noreturn static void +ISC_NORETURN static void fatal(const char *format, ...); static void diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 7a5e9e3948..3c9d9a9377 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -775,7 +775,7 @@ sendqueries(void *arg) { } } -noreturn static void +ISC_NORETURN static void usage(void); static void @@ -883,7 +883,7 @@ help(void) { "Server ID)\n"); } -noreturn static void +ISC_NORETURN static void fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); static void diff --git a/bin/tools/named-rrchecker.c b/bin/tools/named-rrchecker.c index 563c623be4..d06e4aee2f 100644 --- a/bin/tools/named-rrchecker.c +++ b/bin/tools/named-rrchecker.c @@ -35,7 +35,7 @@ static isc_lex_t *lex; static isc_lexspecials_t specials; -noreturn static void +ISC_NORETURN static void usage(void); static void @@ -63,7 +63,7 @@ cleanup(void) { } } -noreturn static void +ISC_NORETURN static void fatal(const char *format, ...); static void diff --git a/bin/tools/nsec3hash.c b/bin/tools/nsec3hash.c index 9d77a10d2a..88a47b5acb 100644 --- a/bin/tools/nsec3hash.c +++ b/bin/tools/nsec3hash.c @@ -36,7 +36,7 @@ const char *program = "nsec3hash"; -noreturn static void +ISC_NORETURN static void fatal(const char *format, ...); static void diff --git a/configure.ac b/configure.ac index 856920226b..738443a42f 100644 --- a/configure.ac +++ b/configure.ac @@ -388,10 +388,6 @@ AC_COMPILE_IFELSE( ], [AC_MSG_FAILURE([stdatomic.h header found, but compilation failed, please fix your toolchain.])]) -AC_CHECK_HEADERS([stdnoreturn.h], - [], - [AC_MSG_ERROR([C11 standard headers not found, update your toolchain.])]) - AC_C_CONST AC_C_INLINE AC_C_VOLATILE @@ -458,11 +454,6 @@ AC_COMPILE_IFELSE( AC_MSG_WARN([uname is not correctly supported]) ]) -# -# check for GCC noreturn attribute -# -AX_GCC_FUNC_ATTRIBUTE([noreturn]) - # # check for GCC malloc attribute # diff --git a/lib/isc/include/isc/assertions.h b/lib/isc/include/isc/assertions.h index 7eafa16011..03e90414eb 100644 --- a/lib/isc/include/isc/assertions.h +++ b/lib/isc/include/isc/assertions.h @@ -33,7 +33,7 @@ typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t, const char *); /* coverity[+kill] */ -noreturn void +ISC_NORETURN void isc_assertion_failed(const char *, int, isc_assertiontype_t, const char *); void isc_assertion_setcallback(isc_assertioncallback_t); diff --git a/lib/isc/include/isc/attributes.h b/lib/isc/include/isc/attributes.h index edb50ed826..eb1bb53e2e 100644 --- a/lib/isc/include/isc/attributes.h +++ b/lib/isc/include/isc/attributes.h @@ -21,12 +21,10 @@ #define __has_c_attribute(x) 0 #endif /* if !defined(__has_c_attribute) */ -#ifdef HAVE_STDNORETURN_H -#include -#elif HAVE_FUNC_ATTRIBUTE_NORETURN -#define noreturn __attribute__((noreturn)) +#if __has_c_attribute(noreturn) && __STDC_VERSION__ >= 202311L +#define ISC_NORETURN [[noreturn]] #else -#define noreturn +#define ISC_NORETURN _Noreturn #endif #if HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL diff --git a/lib/isc/include/isc/error.h b/lib/isc/include/isc/error.h index f4f668203f..fe7b5c6208 100644 --- a/lib/isc/include/isc/error.h +++ b/lib/isc/include/isc/error.h @@ -38,7 +38,7 @@ isc_error_unexpected(const char *, int, const char *, const char *, ...) ISC_FORMAT_PRINTF(4, 5); /*% fatal error */ -noreturn void +ISC_NORETURN void isc_error_fatal(const char *, int, const char *, const char *, ...) ISC_FORMAT_PRINTF(4, 5);