1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-04 09:43:08 +02:00

Enable missing-variable-declarations compiler warning.

Warn if a global variable is defined without a previous declaration. Use this option to detect global variables that do not have a matching extern declaration in a header file.
This commit is contained in:
David Steele 2024-11-18 10:58:00 -05:00
parent 4ae160aa34
commit 33d7681347
7 changed files with 21 additions and 12 deletions

View File

@ -70,6 +70,9 @@ warning_enable = [
# Warn if a global function is defined without a previous prototype declaration # Warn if a global function is defined without a previous prototype declaration
'-Wmissing-prototypes', '-Wmissing-prototypes',
# Warn if a global variable is defined without a previous declaration
'-Wmissing-variable-declarations',
# Warn about anything that depends on the “size of” a function type or of void # Warn about anything that depends on the “size of” a function type or of void
'-Wpointer-arith', '-Wpointer-arith',

View File

@ -48,7 +48,7 @@ STRING_EXTERN(GCS_QUERY_NAME_STR, GCS_QUERY_NA
STRING_STATIC(GCS_QUERY_PAGE_TOKEN_STR, "pageToken"); STRING_STATIC(GCS_QUERY_PAGE_TOKEN_STR, "pageToken");
STRING_STATIC(GCS_QUERY_PREFIX_STR, "prefix"); STRING_STATIC(GCS_QUERY_PREFIX_STR, "prefix");
STRING_EXTERN(GCS_QUERY_UPLOAD_ID_STR, GCS_QUERY_UPLOAD_ID); STRING_EXTERN(GCS_QUERY_UPLOAD_ID_STR, GCS_QUERY_UPLOAD_ID);
STRING_EXTERN(GCS_QUERY_VERSIONS_STR, "versions"); STRING_STATIC(GCS_QUERY_VERSIONS_STR, "versions");
/*********************************************************************************************************************************** /***********************************************************************************************************************************
JSON tokens JSON tokens

View File

@ -23,14 +23,14 @@ libssh2 shim error prefix
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Script that defines how shim functions operate Script that defines how shim functions operate
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
HrnLibSsh2 hrnLibSsh2Script[1024]; static HrnLibSsh2 hrnLibSsh2Script[1024];
bool hrnLibSsh2ScriptDone = true; static bool hrnLibSsh2ScriptDone = true;
unsigned int hrnLibSsh2ScriptIdx; static unsigned int hrnLibSsh2ScriptIdx;
// If there is a script failure change the behavior of cleanup functions to return immediately so the real error will be reported // If there is a script failure change the behavior of cleanup functions to return immediately so the real error will be reported
// rather than a bogus scripting error during cleanup // rather than a bogus scripting error during cleanup
bool hrnLibSsh2ScriptFail; static bool hrnLibSsh2ScriptFail;
char hrnLibSsh2ScriptError[4096]; static char hrnLibSsh2ScriptError[4096];
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Set libssh2 script Set libssh2 script

View File

@ -26,9 +26,9 @@ Include shimmed C modules
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Log settings for testing Log settings for testing
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
LogLevel logLevelTest = logLevelInfo; static LogLevel logLevelTest = logLevelInfo;
LogLevel logLevelTestDefault = logLevelOff; static LogLevel logLevelTestDefault = logLevelOff;
bool logDryRunTest = false; static bool logDryRunTest = false;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Name of file where logs are stored for testing Name of file where logs are stored for testing
@ -38,7 +38,7 @@ static char logFile[1024];
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Buffer where log results are loaded for comparison purposes Buffer where log results are loaded for comparison purposes
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
char harnessLogBuffer[256 * 1024]; static char harnessLogBuffer[256 * 1024];
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Open a log file -- centralized here for error handling Open a log file -- centralized here for error handling

View File

@ -47,7 +47,7 @@ Constants
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Local data Local data
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
struct HrnServerLocal static struct HrnServerLocal
{ {
unsigned int portOffsetNext; // Next server port offset to be returned unsigned int portOffsetNext; // Next server port offset to be returned
} hrnServerLocal; } hrnServerLocal;

View File

@ -275,7 +275,7 @@ hrnFileWrite(const char *fileName, const unsigned char *buffer, size_t bufferSiz
} }
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
char harnessDiffBuffer[256 * 1024]; static char harnessDiffBuffer[256 * 1024];
const char * const char *
hrnDiff(const char *expected, const char *actual) hrnDiff(const char *expected, const char *actual)

View File

@ -49,6 +49,7 @@ The test code is included directly so it can freely interact with the included C
#define TEST_PROJECT_EXE "{[C_TEST_PROJECT_EXE]}" #define TEST_PROJECT_EXE "{[C_TEST_PROJECT_EXE]}"
#ifdef HRN_FEATURE_STRING #ifdef HRN_FEATURE_STRING
STRING_DECLARE(TEST_PROJECT_EXE_STR);
STRING_EXTERN(TEST_PROJECT_EXE_STR, TEST_PROJECT_EXE); STRING_EXTERN(TEST_PROJECT_EXE_STR, TEST_PROJECT_EXE);
#endif #endif
@ -56,6 +57,7 @@ STRING_EXTERN(TEST_PROJECT_EXE_STR, TEST_PROJECT_EXE);
#define TEST_PATH "{[C_TEST_PATH]}" #define TEST_PATH "{[C_TEST_PATH]}"
#ifdef HRN_FEATURE_STRING #ifdef HRN_FEATURE_STRING
STRING_DECLARE(TEST_PATH_STR);
STRING_EXTERN(TEST_PATH_STR, TEST_PATH); STRING_EXTERN(TEST_PATH_STR, TEST_PATH);
#endif #endif
@ -63,6 +65,7 @@ STRING_EXTERN(TEST_PATH_STR, TEST_PATH);
#define HRN_PATH_REPO "{[C_HRN_PATH_REPO]}" #define HRN_PATH_REPO "{[C_HRN_PATH_REPO]}"
#ifdef HRN_FEATURE_STRING #ifdef HRN_FEATURE_STRING
STRING_DECLARE(HRN_PATH_REPO_STR);
STRING_EXTERN(HRN_PATH_REPO_STR, HRN_PATH_REPO); STRING_EXTERN(HRN_PATH_REPO_STR, HRN_PATH_REPO);
#endif #endif
@ -70,6 +73,7 @@ STRING_EXTERN(HRN_PATH_REPO_STR, HRN_PATH_REPO);
#define HRN_PATH "{[C_HRN_PATH]}" #define HRN_PATH "{[C_HRN_PATH]}"
#ifdef HRN_FEATURE_STRING #ifdef HRN_FEATURE_STRING
STRING_DECLARE(HRN_PATH_STR);
STRING_EXTERN(HRN_PATH_STR, HRN_PATH); STRING_EXTERN(HRN_PATH_STR, HRN_PATH);
#endif #endif
@ -86,6 +90,7 @@ STRING_EXTERN(HRN_PATH_STR, HRN_PATH);
#define TEST_PG_VERSION "{[C_TEST_PG_VERSION]}" #define TEST_PG_VERSION "{[C_TEST_PG_VERSION]}"
#ifdef HRN_FEATURE_STRING #ifdef HRN_FEATURE_STRING
STRING_DECLARE(TEST_USER_STR);
STRING_EXTERN(TEST_USER_STR, TEST_USER); STRING_EXTERN(TEST_USER_STR, TEST_USER);
#endif #endif
@ -95,6 +100,7 @@ STRING_EXTERN(TEST_USER_STR, TEST_USER);
#define TEST_GROUP_ID_Z "{[C_TEST_GROUP_ID]}" #define TEST_GROUP_ID_Z "{[C_TEST_GROUP_ID]}"
#ifdef HRN_FEATURE_STRING #ifdef HRN_FEATURE_STRING
STRING_DECLARE(TEST_GROUP_STR);
STRING_EXTERN(TEST_GROUP_STR, TEST_GROUP); STRING_EXTERN(TEST_GROUP_STR, TEST_GROUP);
#endif #endif