diff options
author | Tomas Vondra | 2016-03-01 02:03:59 +0000 |
---|---|---|
committer | Pavan Deolasee | 2016-10-18 10:00:50 +0000 |
commit | cc8cc86bb42c2e34f5dddbf712ba1ae0400c034c (patch) | |
tree | 09a37edb7c5a5576445077002bed93b5a15680e9 | |
parent | bec7d7d9a4e9ae6b21632fd1a60b8a5e7237064d (diff) |
fix missing ExceptionalCondition prototype / return type
During compilation, there's like a zillion warnings about missing
prototype of ExceptionalCondition. Of course, in regular postgres
this is defined in postgres.h like this:
void ExceptionalCondition(...)
but in XL apparently some places use Assert it without willing to
include the whole postgres.h (not sure why). So there's a copy of
the function in src/gtm/common/assert.c, but there's no prototype
in src/include/gtm/assert.h, thus the complaints.
Adding the prototype to the header file however reveals another
problem, as the function in src/gtm/common/assert.c is defined
like this
int ExceptionalCondition(...)
with a rather wonky explanation about TrapMacro(). So this would
fail to compile when a file ends up g both header files, like for
example src/gtm/client/gtm_client.c. (Fun fact: gtm_client.c does
not really need the include at all.)
Therefore the best solution at this point seems to be to simply
change the return type in assert.c to void (and get rid of the
rather suspicious explanation above the function), and add the
prototype into src/include/gtm/assert.c. This way the prototype
matches the one from postgres.h, there's no conflict and the
warnings disappear.
In the long term however, the right solution seems to be simply
removing the redundancy by dropping the gtm copy of the function.
-rw-r--r-- | src/gtm/common/assert.c | 6 | ||||
-rw-r--r-- | src/include/gtm/assert.h | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/gtm/common/assert.c b/src/gtm/common/assert.c index 8d4c9a71fd..adf967c67c 100644 --- a/src/gtm/common/assert.c +++ b/src/gtm/common/assert.c @@ -25,11 +25,8 @@ bool assert_enabled = false; /* * ExceptionalCondition - Handles the failure of an Assert() - * - * Note: this can't actually return, but we declare it as returning int - * because the TrapMacro() macro might get wonky otherwise. */ -int +void ExceptionalCondition(const char *conditionName, const char *errorType, const char *fileName, @@ -50,5 +47,4 @@ ExceptionalCondition(const char *conditionName, fflush(stderr); abort(); - return 0; } diff --git a/src/include/gtm/assert.h b/src/include/gtm/assert.h index 5e6425c934..7809742fe7 100644 --- a/src/include/gtm/assert.h +++ b/src/include/gtm/assert.h @@ -18,5 +18,10 @@ extern bool assert_enabled; +void ExceptionalCondition(const char *conditionName, + const char *errorType, + const char *fileName, + int lineNumber); + #endif |