You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-14 23:44:58 +02:00
Improve CONST type macro handling.
Rather than create a CONST_ variant for every type that needs to be returned const, create a FUNCTION_LOG_RETURN_CONST() macro that will return any type as const.
This commit is contained in:
@ -141,6 +141,10 @@
|
|||||||
<p>Rename <code>common/io/handle</code> module to <code>common/io/handleWrite</code>.</p>
|
<p>Rename <code>common/io/handle</code> module to <code>common/io/handleWrite</code>.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
|
||||||
|
<release-item>
|
||||||
|
<p>Improve <code>CONST</code> type macro handling.</p>
|
||||||
|
</release-item>
|
||||||
|
|
||||||
<release-item>
|
<release-item>
|
||||||
<p>Move <code>MACRO_TO_STR()</code> to <file>common/debug.h</file>.</p>
|
<p>Move <code>MACRO_TO_STR()</code> to <file>common/debug.h</file>.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
@ -128,7 +128,7 @@ helpRenderValue(const Variant *value)
|
|||||||
result = varStrForce(value);
|
result = varStrForce(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN(CONST_STRING, result);
|
FUNCTION_LOG_RETURN_CONST(STRING, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -126,9 +126,9 @@ size_t strzToLog(const char *string, char *buffer, size_t bufferSize);
|
|||||||
#define FUNCTION_LOG_CHARP_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_CHARP_FORMAT(value, buffer, bufferSize) \
|
||||||
ptrToLog(value, "char *", buffer, bufferSize)
|
ptrToLog(value, "char *", buffer, bufferSize)
|
||||||
|
|
||||||
#define FUNCTION_LOG_CONST_CHARPP_TYPE \
|
#define FUNCTION_LOG_CHARPP_TYPE \
|
||||||
const char **
|
char **
|
||||||
#define FUNCTION_LOG_CONST_CHARPP_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_CHARPP_FORMAT(value, buffer, bufferSize) \
|
||||||
ptrToLog(value, "char **", buffer, bufferSize)
|
ptrToLog(value, "char **", buffer, bufferSize)
|
||||||
|
|
||||||
#define FUNCTION_LOG_CHARPY_TYPE \
|
#define FUNCTION_LOG_CHARPY_TYPE \
|
||||||
@ -219,11 +219,6 @@ size_t strzToLog(const char *string, char *buffer, size_t bufferSize);
|
|||||||
#define FUNCTION_LOG_VOIDP_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_VOIDP_FORMAT(value, buffer, bufferSize) \
|
||||||
ptrToLog(value, "void *", buffer, bufferSize)
|
ptrToLog(value, "void *", buffer, bufferSize)
|
||||||
|
|
||||||
#define FUNCTION_LOG_CONST_VOIDP_TYPE \
|
|
||||||
const void *
|
|
||||||
#define FUNCTION_LOG_CONST_VOIDP_FORMAT(value, buffer, bufferSize) \
|
|
||||||
FUNCTION_LOG_VOIDP_FORMAT(value, buffer, bufferSize)
|
|
||||||
|
|
||||||
#define FUNCTION_LOG_VOIDPP_TYPE \
|
#define FUNCTION_LOG_VOIDPP_TYPE \
|
||||||
void **
|
void **
|
||||||
#define FUNCTION_LOG_VOIDPP_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_VOIDPP_FORMAT(value, buffer, bufferSize) \
|
||||||
@ -237,10 +232,10 @@ size_t strzToLog(const char *string, char *buffer, size_t bufferSize);
|
|||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Macros to return function results (or void)
|
Macros to return function results (or void)
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
#define FUNCTION_LOG_RETURN(typeMacroPrefix, result) \
|
#define FUNCTION_LOG_RETURN_BASE(typePre, typeMacroPrefix, result) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
FUNCTION_LOG_##typeMacroPrefix##_TYPE FUNCTION_LOG_RETURN_result = result; \
|
typePre FUNCTION_LOG_##typeMacroPrefix##_TYPE FUNCTION_LOG_RETURN_result = result; \
|
||||||
\
|
\
|
||||||
STACK_TRACE_POP(); \
|
STACK_TRACE_POP(); \
|
||||||
\
|
\
|
||||||
@ -256,6 +251,12 @@ Macros to return function results (or void)
|
|||||||
} \
|
} \
|
||||||
while(0)
|
while(0)
|
||||||
|
|
||||||
|
#define FUNCTION_LOG_RETURN(typeMacroPrefix, result) \
|
||||||
|
FUNCTION_LOG_RETURN_BASE(, typeMacroPrefix, result)
|
||||||
|
|
||||||
|
#define FUNCTION_LOG_RETURN_CONST(typeMacroPrefix, result) \
|
||||||
|
FUNCTION_LOG_RETURN_BASE(const, typeMacroPrefix, result)
|
||||||
|
|
||||||
#define FUNCTION_LOG_RETURN_VOID() \
|
#define FUNCTION_LOG_RETURN_VOID() \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
@ -294,12 +295,10 @@ test macros are compiled out.
|
|||||||
#define FUNCTION_TEST_RETURN(typeMacroPrefix, result) \
|
#define FUNCTION_TEST_RETURN(typeMacroPrefix, result) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
FUNCTION_LOG_##typeMacroPrefix##_TYPE FUNCTION_LOG_RETURN_result = result; \
|
|
||||||
\
|
|
||||||
if (stackTraceTest()) \
|
if (stackTraceTest()) \
|
||||||
STACK_TRACE_POP(); \
|
STACK_TRACE_POP(); \
|
||||||
\
|
\
|
||||||
return FUNCTION_LOG_RETURN_result; \
|
return result; \
|
||||||
} \
|
} \
|
||||||
while(0);
|
while(0);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ iniGetInternal(const Ini *this, const String *section, const String *key)
|
|||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_VARIANT, result);
|
FUNCTION_TEST_RETURN(VARIANT, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
@ -97,7 +97,7 @@ iniGet(const Ini *this, const String *section, const String *key)
|
|||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
THROW_FMT(FormatError, "section '%s', key '%s' does not exist", strPtr(section), strPtr(key));
|
THROW_FMT(FormatError, "section '%s', key '%s' does not exist", strPtr(section), strPtr(key));
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_VARIANT, result);
|
FUNCTION_TEST_RETURN(VARIANT, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
@ -124,7 +124,7 @@ iniGetDefault(const Ini *this, const String *section, const String *key, Variant
|
|||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
result = defaultValue;
|
result = defaultValue;
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_VARIANT, result);
|
FUNCTION_TEST_RETURN(VARIANT, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -190,5 +190,5 @@ ioFilterType(const IoFilter *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->type);
|
FUNCTION_TEST_RETURN(STRING, this->type);
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ ioFilterGroupResult(const IoFilterGroup *this, const String *filterType)
|
|||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN(CONST_VARIANT, result);
|
FUNCTION_LOG_RETURN_CONST(VARIANT, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -134,11 +134,6 @@ Macros for function logging
|
|||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
String *strToLog(const String *this);
|
String *strToLog(const String *this);
|
||||||
|
|
||||||
#define FUNCTION_LOG_CONST_STRING_TYPE \
|
|
||||||
const String *
|
|
||||||
#define FUNCTION_LOG_CONST_STRING_FORMAT(value, buffer, bufferSize) \
|
|
||||||
FUNCTION_LOG_STRING_FORMAT(value, buffer, bufferSize)
|
|
||||||
|
|
||||||
#define FUNCTION_LOG_STRING_TYPE \
|
#define FUNCTION_LOG_STRING_TYPE \
|
||||||
String *
|
String *
|
||||||
#define FUNCTION_LOG_STRING_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_STRING_FORMAT(value, buffer, bufferSize) \
|
||||||
|
@ -509,7 +509,7 @@ strLstPtr(const StringList *this)
|
|||||||
|
|
||||||
list[strLstSize(this)] = NULL;
|
list[strLstSize(this)] = NULL;
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_CHARPP, list);
|
FUNCTION_TEST_RETURN(CHARPP, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -89,11 +89,6 @@ Macros for function logging
|
|||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
String *varToLog(const Variant *this);
|
String *varToLog(const Variant *this);
|
||||||
|
|
||||||
#define FUNCTION_LOG_CONST_VARIANT_TYPE \
|
|
||||||
const FUNCTION_LOG_VARIANT_TYPE
|
|
||||||
#define FUNCTION_LOG_CONST_VARIANT_FORMAT(value, buffer, bufferSize) \
|
|
||||||
FUNCTION_LOG_VARIANT_FORMAT(value, buffer, bufferSize)
|
|
||||||
|
|
||||||
#define FUNCTION_LOG_VARIANT_TYPE \
|
#define FUNCTION_LOG_VARIANT_TYPE \
|
||||||
Variant *
|
Variant *
|
||||||
#define FUNCTION_LOG_VARIANT_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_VARIANT_FORMAT(value, buffer, bufferSize) \
|
||||||
|
@ -32,9 +32,4 @@ Macros for function logging
|
|||||||
#define FUNCTION_LOG_VARIANT_LIST_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_VARIANT_LIST_FORMAT(value, buffer, bufferSize) \
|
||||||
objToLog(value, "VariantList", buffer, bufferSize)
|
objToLog(value, "VariantList", buffer, bufferSize)
|
||||||
|
|
||||||
#define FUNCTION_LOG_CONST_VARIANT_LIST_TYPE \
|
|
||||||
const VariantList *
|
|
||||||
#define FUNCTION_LOG_CONST_VARIANT_LIST_FORMAT(value, buffer, bufferSize) \
|
|
||||||
objToLog(value, "VariantList", buffer, bufferSize)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -763,7 +763,7 @@ cfgOptionStr(ConfigOption optionId)
|
|||||||
if (configOptionValue[optionId].value != NULL)
|
if (configOptionValue[optionId].value != NULL)
|
||||||
result = varStr(configOptionValue[optionId].value);
|
result = varStr(configOptionValue[optionId].value);
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN(CONST_STRING, result);
|
FUNCTION_LOG_RETURN_CONST(STRING, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -90,7 +90,7 @@ cipherTypeName(CipherType type)
|
|||||||
else if (type != cipherTypeNone)
|
else if (type != cipherTypeNone)
|
||||||
THROW_FMT(AssertError, "invalid cipher type %u", type);
|
THROW_FMT(AssertError, "invalid cipher type %u", type);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, result);
|
FUNCTION_TEST_RETURN(STRING, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -279,7 +279,7 @@ infoCipherPass(const Info *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->cipherPass);
|
FUNCTION_TEST_RETURN(STRING, this->cipherPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ini *
|
Ini *
|
||||||
|
@ -206,7 +206,7 @@ infoArchiveCipherPass(const InfoArchive *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, infoPgCipherPass(this->infoPg));
|
FUNCTION_TEST_RETURN(STRING, infoPgCipherPass(this->infoPg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -179,7 +179,7 @@ infoPgCipherPass(const InfoPg *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, infoCipherPass(this->info));
|
FUNCTION_TEST_RETURN(STRING, infoCipherPass(this->info));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -170,7 +170,7 @@ protocolClientReadOutput(ProtocolClient *this, bool outputRequired)
|
|||||||
}
|
}
|
||||||
MEM_CONTEXT_TEMP_END();
|
MEM_CONTEXT_TEMP_END();
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN(CONST_VARIANT_LIST, result);
|
FUNCTION_LOG_RETURN_CONST(VARIANT_LIST, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
@ -214,7 +214,7 @@ protocolClientExecute(ProtocolClient *this, const KeyValue *command, bool output
|
|||||||
|
|
||||||
protocolClientWriteCommand(this, command);
|
protocolClientWriteCommand(this, command);
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN(CONST_VARIANT_LIST, protocolClientReadOutput(this, outputRequired));
|
FUNCTION_LOG_RETURN_CONST(VARIANT_LIST, protocolClientReadOutput(this, outputRequired));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -234,7 +234,7 @@ storageDriverPosixFileReadName(const StorageDriverPosixFileRead *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->name);
|
FUNCTION_TEST_RETURN(STRING, this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -307,7 +307,7 @@ storageDriverPosixFileWriteName(const StorageDriverPosixFileWrite *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->name);
|
FUNCTION_TEST_RETURN(STRING, this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -65,9 +65,4 @@ Macros for function logging
|
|||||||
#define FUNCTION_LOG_STORAGE_DRIVER_POSIX_FORMAT(value, buffer, bufferSize) \
|
#define FUNCTION_LOG_STORAGE_DRIVER_POSIX_FORMAT(value, buffer, bufferSize) \
|
||||||
objToLog(value, "StorageDriverPosix", buffer, bufferSize)
|
objToLog(value, "StorageDriverPosix", buffer, bufferSize)
|
||||||
|
|
||||||
#define FUNCTION_LOG_CONST_STORAGE_DRIVER_POSIX_TYPE \
|
|
||||||
const StorageDriverPosix *
|
|
||||||
#define FUNCTION_LOG_CONST_STORAGE_DRIVER_POSIX_FORMAT(value, buffer, bufferSize) \
|
|
||||||
objToLog(value, "StorageDriverPosix", buffer, bufferSize)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -303,5 +303,5 @@ storageDriverRemoteFileReadName(const StorageDriverRemoteFileRead *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->name);
|
FUNCTION_TEST_RETURN(STRING, this->name);
|
||||||
}
|
}
|
||||||
|
@ -189,5 +189,5 @@ storageDriverS3FileReadName(const StorageDriverS3FileRead *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->name);
|
FUNCTION_TEST_RETURN(STRING, this->name);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ storageFileReadName(const StorageFileRead *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->interface.name(this->driver));
|
FUNCTION_TEST_RETURN(STRING, this->interface.name(this->driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
@ -137,7 +137,7 @@ storageFileReadType(const StorageFileRead *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->type);
|
FUNCTION_TEST_RETURN(STRING, this->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -176,7 +176,7 @@ storageFileWriteName(const StorageFileWrite *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->interface.name(this->driver));
|
FUNCTION_TEST_RETURN(STRING, this->interface.name(this->driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
@ -221,7 +221,7 @@ storageFileWriteType(const StorageFileWrite *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(CONST_STRING, this->type);
|
FUNCTION_TEST_RETURN(STRING, this->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
Reference in New Issue
Block a user