1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add FN_NO_RETURN macro.

Change all instances of __attribute__((__noreturn__)) to a macro in meson.build / build.auto.h.in.

As compiler attributes written in the form of __attribute__ are not supported by MSVC, this is one of several commits to make the code-base more robust and allow using MSVC-style attributes later.
This commit is contained in:
Sam Bassaly 2022-06-08 23:43:23 +02:00 committed by GitHub
parent 8babd558bc
commit 0dabf88e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 12 deletions

View File

@ -88,6 +88,17 @@
<p>Improve memory usage of mem contexts.</p>
</release-item>
<release-item>
<github-pull-request id="1773"/>
<release-item-contributor-list>
<release-item-contributor id="sam.bassaly"/>
<release-item-reviewer id="david.steele"/>
</release-item-contributor-list>
<p>Add <code>FN_NO_RETURN</code> macro.</p>
</release-item>
</release-development-list>
</release-core-list>

View File

@ -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
####################################################################################################################################

View File

@ -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__))

View File

@ -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);

View File

@ -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

View File

@ -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 *