pgbackrest.git / summary / log / commit / refs
commit 0dabf88e9d85e4db2ff65ebbb14b4320e1092a8b
Author: Sam Bassaly <shkshk90@gmail.com>
Commit: GitHub <noreply@github.com>
Date: Wed Jun 08 21:43:23 2022 +0000
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.
doc/xml/release.xml | 11 +++++++++++
meson.build | 3 +++
src/build.auto.h.in | 3 +++
src/common/crypto/common.h | 2 +-
src/common/error.h | 19 +++++++++----------
src/common/io/http/request.h | 2 +-
6 files changed, 28 insertions(+), 12 deletions(-)
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 @@
<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>
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 *
[parent: 8babd558bc3a]