mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Protect against mixed FUNCTION_TEST* and FUNCTION_LOG* macros.
If the macros are mixed then the debug stack may not be cleaned up correctly. Add variables to ensure that the macros cannot be mixed. Fix cases where the macros were mixed and add one missing semicolon.
This commit is contained in:
parent
c8492aac41
commit
0eae815ef4
@ -289,6 +289,15 @@ Ignore DEBUG_TEST_TRACE_MACRO if DEBUG is not defined because the underlying fun
|
||||
|
||||
#ifdef DEBUG_TEST_TRACE_MACRO
|
||||
#define FUNCTION_TEST_BEGIN() \
|
||||
/* Ensure that FUNCTION_LOG_BEGIN() and FUNCTION_TEST_BEGIN() are not both used in a single function by declaring the */ \
|
||||
/* same variable that FUNCTION_LOG_BEGIN() uses to track logging */ \
|
||||
LogLevel FUNCTION_LOG_LEVEL(); \
|
||||
(void)FUNCTION_LOG_LEVEL(); \
|
||||
\
|
||||
/* Ensure that FUNCTION_TEST_RETURN*() is not used with FUNCTION_LOG_BEGIN*() by declaring a variable that will be */ \
|
||||
/* referenced in FUNCTION_TEST_RETURN*() */ \
|
||||
bool FUNCTION_TEST_BEGIN_exists; \
|
||||
\
|
||||
if (stackTraceTest()) \
|
||||
{ \
|
||||
STACK_TRACE_PUSH(logLevelDebug); \
|
||||
@ -305,6 +314,9 @@ Ignore DEBUG_TEST_TRACE_MACRO if DEBUG is not defined because the underlying fun
|
||||
FUNCTION_LOG_PARAM_PP(typeName, param)
|
||||
|
||||
#define FUNCTION_TEST_END() \
|
||||
/* CHECK for presense of FUNCTION_TEST_BEGIN*() */ \
|
||||
(void)FUNCTION_TEST_BEGIN_exists; \
|
||||
\
|
||||
stackTraceTestStart(); \
|
||||
}
|
||||
|
||||
@ -315,13 +327,23 @@ Ignore DEBUG_TEST_TRACE_MACRO if DEBUG is not defined because the underlying fun
|
||||
#define FUNCTION_TEST_RETURN(result) \
|
||||
do \
|
||||
{ \
|
||||
/* CHECK for presense of FUNCTION_TEST_BEGIN*() */ \
|
||||
(void)FUNCTION_TEST_BEGIN_exists; \
|
||||
\
|
||||
STACK_TRACE_POP(true); \
|
||||
return result; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define FUNCTION_TEST_RETURN_VOID() \
|
||||
STACK_TRACE_POP(true)
|
||||
do \
|
||||
{ \
|
||||
/* CHECK for presense of FUNCTION_TEST_BEGIN*() */ \
|
||||
(void)FUNCTION_TEST_BEGIN_exists; \
|
||||
\
|
||||
STACK_TRACE_POP(true); \
|
||||
} \
|
||||
while (0)
|
||||
#else
|
||||
#define FUNCTION_TEST_BEGIN()
|
||||
#define FUNCTION_TEST_PARAM(typeMacroPrefix, param)
|
||||
|
@ -347,7 +347,7 @@ infoPgSaveCallback(void *data, const String *sectionNext, InfoSave *infoSaveData
|
||||
if (saveData->callbackFunction != NULL)
|
||||
saveData->callbackFunction(saveData->callbackData, sectionNext, infoSaveData);
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID()
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -115,7 +115,7 @@ storageRemoteFeatureProtocol(PackRead *const param, ProtocolServer *const server
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -257,7 +257,7 @@ storageRemoteInfoProtocol(PackRead *const param, ProtocolServer *const server)
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -319,7 +319,7 @@ storageRemoteInfoListProtocol(PackRead *const param, ProtocolServer *const serve
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -389,7 +389,7 @@ storageRemoteOpenReadProtocol(PackRead *const param, ProtocolServer *const serve
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -476,7 +476,7 @@ storageRemoteOpenWriteProtocol(PackRead *const param, ProtocolServer *const serv
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -504,7 +504,7 @@ storageRemotePathCreateProtocol(PackRead *const param, ProtocolServer *const ser
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -532,7 +532,7 @@ storageRemotePathRemoveProtocol(PackRead *const param, ProtocolServer *const ser
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -557,7 +557,7 @@ storageRemotePathSyncProtocol(PackRead *const param, ProtocolServer *const serve
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user