diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 137a749fe..c72758df9 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -88,6 +88,17 @@

Improve memory usage of mem contexts.

+ + + + + + + + + +

Add FN_NO_RETURN macro.

+
diff --git a/meson.build b/meson.build index c4c6c014f..aa1de2303 100644 --- a/meson.build +++ b/meson.build @@ -155,6 +155,9 @@ endif # Set configuration path configuration.set_quoted('CFGOPTDEF_CONFIG_PATH', get_option('configdir'), description: 'Configuration path') +# Set FN_NO_RETURN macro +configuration.set('FN_NO_RETURN', '__attribute__((__noreturn__))', description: 'Indicate that a function does not return') + #################################################################################################################################### # Include src #################################################################################################################################### diff --git a/src/build.auto.h.in b/src/build.auto.h.in index d4200ba8e..8491fc38c 100644 --- a/src/build.auto.h.in +++ b/src/build.auto.h.in @@ -25,3 +25,6 @@ Build Flags Generated by Configure // Configuration path #undef CFGOPTDEF_CONFIG_PATH + +// Indicate that a function does not return +#define FN_NO_RETURN __attribute__((__noreturn__)) diff --git a/src/common/crypto/common.h b/src/common/crypto/common.h index 399cc4132..c95772f5b 100644 --- a/src/common/crypto/common.h +++ b/src/common/crypto/common.h @@ -45,7 +45,7 @@ bool cryptoIsInit(void); // Throw crypto errors void cryptoError(bool error, const char *description); -void cryptoErrorCode(unsigned long code, const char *description) __attribute__((__noreturn__)); +FN_NO_RETURN void cryptoErrorCode(unsigned long code, const char *description); // Generate random bytes void cryptoRandomBytes(unsigned char *buffer, size_t size); diff --git a/src/common/error.h b/src/common/error.h index aab8020ef..96fef3f19 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -314,28 +314,27 @@ jmp_buf *errorInternalJump(void); bool errorInternalCatch(const ErrorType *errorTypeCatch, bool fatalCatch); // Propagate the error up so it can be caught -void errorInternalPropagate(void) __attribute__((__noreturn__)); +FN_NO_RETURN void errorInternalPropagate(void); // End the try block void errorInternalTryEnd(void); // Throw an error -void errorInternalThrow( +FN_NO_RETURN void errorInternalThrow( const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *message, - const char *stackTrace) __attribute__((__noreturn__)); -void errorInternalThrowFmt( + const char *stackTrace); +FN_NO_RETURN void errorInternalThrowFmt( const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *format, ...) - __attribute__((format(printf, 5, 6))) __attribute__((__noreturn__)); + __attribute__((format(printf, 5, 6))); // Throw a system error -void errorInternalThrowSys( - int errNo, const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *message) - __attribute__((__noreturn__)); +FN_NO_RETURN void errorInternalThrowSys( + int errNo, const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *message); // Throw a formatted system error -void errorInternalThrowSysFmt( +FN_NO_RETURN void errorInternalThrowSysFmt( int errNo, const ErrorType *errorType, const char *fileName, const char *functionName, int fileLine, const char *format, ...) - __attribute__((format(printf, 6, 7))) __attribute__((__noreturn__)); + __attribute__((format(printf, 6, 7))); // Versions of the above for coverage testing which checks the error condition inside the function #ifdef DEBUG_COVERAGE diff --git a/src/common/io/http/request.h b/src/common/io/http/request.h index 5ecd82d42..d4a2f2c03 100644 --- a/src/common/io/http/request.h +++ b/src/common/io/http/request.h @@ -128,7 +128,7 @@ Functions HttpResponse *httpRequestResponse(HttpRequest *this, bool contentCache); // Throw an error if the request failed -void httpRequestError(const HttpRequest *this, HttpResponse *response) __attribute__((__noreturn__)); +FN_NO_RETURN void httpRequestError(const HttpRequest *this, HttpResponse *response); // Move to a new parent mem context __attribute__((always_inline)) static inline HttpRequest *