fix missing ExceptionalCondition prototype / return type
authorTomas Vondra <[email protected]>
Tue, 1 Mar 2016 02:03:59 +0000 (03:03 +0100)
committerPavan Deolasee <[email protected]>
Fri, 11 Mar 2016 06:23:08 +0000 (11:53 +0530)
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.

src/gtm/common/assert.c
src/include/gtm/assert.h

index 8d4c9a71fd5d2ff7f96de130b3e6ce8227fe4a55..adf967c67cdfdd074b7b5d29a8a83291ec5ab227 100644 (file)
@@ -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;
 }
index 5e6425c934d538826ae0f1831da3a2b5d0244ba3..7809742fe79ff40c065760c95dcca36261d56355 100644 (file)
 
 extern bool assert_enabled;
 
+void ExceptionalCondition(const char *conditionName,
+                                                const char *errorType,
+                                                const char *fileName,
+                                                int lineNumber);
+
 #endif