You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Fix scoping violations exposed by optimizations in gcc 9.
gcc < 9 makes all compound literals function scope, even though the C spec requires them to be invalid outside the current scope. Since the compiler and valgrind were not enforcing this we had a few violations which caused problems in gcc >= 9. Even though we are not quite ready to support gcc 9 officially, fix the scoping violations that currently exist in the codebase. Reported by chrlange, Ned T. Crigler.
This commit is contained in:
		| @@ -14,6 +14,17 @@ | ||||
|     <release-list> | ||||
|         <release date="XXXX-XX-XX" version="2.16dev" title="UNDER DEVELOPMENT"> | ||||
|             <release-core-list> | ||||
|                 <release-bug-list> | ||||
|                     <release-item> | ||||
|                         <release-item-contributor-list> | ||||
|                             <release-item-ideator id="chrlange"/> | ||||
|                             <release-item-ideator id="ned.t.crigler"/> | ||||
|                         </release-item-contributor-list> | ||||
|  | ||||
|                         <p>Fix scoping violations exposed by optimizations in <proper>gcc 9</proper>.</p> | ||||
|                     </release-item> | ||||
|                 </release-bug-list> | ||||
|  | ||||
|                 <release-development-list> | ||||
|                     <release-item> | ||||
|                         <release-item-contributor-list> | ||||
| @@ -7162,6 +7173,11 @@ | ||||
|             <contributor-id type="github">Xof</contributor-id> | ||||
|         </contributor> | ||||
|  | ||||
|         <contributor id="chrlange"> | ||||
|             <contributor-name-display>chrlange</contributor-name-display> | ||||
|             <contributor-id type="github">chrlange</contributor-id> | ||||
|         </contributor> | ||||
|  | ||||
|         <contributor id="clinton.adams"> | ||||
|             <contributor-name-display>Clinton Adams</contributor-name-display> | ||||
|             <contributor-id type="github">clad</contributor-id> | ||||
| @@ -7400,6 +7416,11 @@ | ||||
|             <contributor-id type="github">golpa</contributor-id> | ||||
|         </contributor> | ||||
|  | ||||
|         <contributor id="ned.t.crigler"> | ||||
|             <contributor-name-display>Ned T. Crigler</contributor-name-display> | ||||
|             <contributor-id type="github">crigler</contributor-id> | ||||
|         </contributor> | ||||
|  | ||||
|         <contributor id="nick.floersch"> | ||||
|             <contributor-name-display>Nick Floersch</contributor-name-display> | ||||
|             <contributor-id type="github">seinick</contributor-id> | ||||
|   | ||||
| @@ -196,15 +196,15 @@ storageFilterXsResultAll(const IoFilterGroup *filterGroup) | ||||
|  | ||||
|         if (strEq(filter, CRYPTO_HASH_FILTER_TYPE_STR)) | ||||
|         { | ||||
|             filterPerl = STRDEF("pgBackRest::Storage::Filter::Sha"); | ||||
|             filterPerl = strNew("pgBackRest::Storage::Filter::Sha"); | ||||
|         } | ||||
|         else if (strEq(filter, SIZE_FILTER_TYPE_STR)) | ||||
|         { | ||||
|             filterPerl = STRDEF("pgBackRest::Common::Io::Handle"); | ||||
|             filterPerl = strNew("pgBackRest::Common::Io::Handle"); | ||||
|         } | ||||
|         else if (strEq(filter, PAGE_CHECKSUM_FILTER_TYPE_STR)) | ||||
|         { | ||||
|             filterPerl = STRDEF("pgBackRest::Backup::Filter::PageChecksum"); | ||||
|             filterPerl = strNew("pgBackRest::Backup::Filter::PageChecksum"); | ||||
|         } | ||||
|  | ||||
|         if (filterPerl != NULL) | ||||
|   | ||||
| @@ -32,6 +32,8 @@ Global error file constant | ||||
| #define STATUS_FILE_GLOBAL                                          "global" | ||||
|     STRING_STATIC(STATUS_FILE_GLOBAL_STR,                           STATUS_FILE_GLOBAL); | ||||
|  | ||||
| STRING_STATIC(STATUS_FILE_GLOBAL_ERROR_STR,                         STATUS_FILE_GLOBAL STATUS_EXT_ERROR); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Get the correct spool queue based on the archive mode | ||||
| ***********************************************************************************************************************************/ | ||||
| @@ -79,7 +81,7 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool confe | ||||
|             // If that doesn't exist then check for a global error | ||||
|             if (!errorFileExists) | ||||
|             { | ||||
|                 errorFile = STRDEF(STATUS_FILE_GLOBAL STATUS_EXT_ERROR); | ||||
|                 errorFile = STATUS_FILE_GLOBAL_ERROR_STR; | ||||
|                 errorFileExists = storageExistsNP(storageSpool(), strNewFmt("%s/%s", strPtr(spoolQueue), strPtr(errorFile))); | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -188,7 +188,7 @@ helpRender(void) | ||||
|             } | ||||
|  | ||||
|             // Construct message for more help | ||||
|             more = STRDEF("[command]"); | ||||
|             more = strNew("[command]"); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
| @@ -224,13 +224,13 @@ helpRender(void) | ||||
|                         const String *section = NULL; | ||||
|  | ||||
|                         if (cfgDefOptionHelpSection(optionDefId) != NULL) | ||||
|                             section = STR(cfgDefOptionHelpSection(optionDefId)); | ||||
|                             section = strNew(cfgDefOptionHelpSection(optionDefId)); | ||||
|  | ||||
|                         if (section == NULL || | ||||
|                             (!strEqZ(section, "general") && !strEqZ(section, "log") && !strEqZ(section, "repository") && | ||||
|                              !strEqZ(section, "stanza"))) | ||||
|                         { | ||||
|                             section = STRDEF("command"); | ||||
|                             section = strNew("command"); | ||||
|                         } | ||||
|  | ||||
|                         kvAdd(optionKv, VARSTR(section), VARINT((int)optionDefId)); | ||||
|   | ||||
| @@ -98,7 +98,7 @@ lockAcquireFile(const String *lockFile, TimeMSec lockTimeout, bool failOnNoLock) | ||||
|                 const String *errorHint = NULL; | ||||
|  | ||||
|                 if (errNo == EWOULDBLOCK) | ||||
|                     errorHint = STRDEF("\nHINT: is another " PROJECT_NAME " process running?"); | ||||
|                     errorHint = strNew("\nHINT: is another " PROJECT_NAME " process running?"); | ||||
|                 else if (errNo == EACCES) | ||||
|                 { | ||||
|                     errorHint = strNewFmt( | ||||
|   | ||||
| @@ -39,6 +39,12 @@ Standard config include path name | ||||
| ***********************************************************************************************************************************/ | ||||
| #define PGBACKREST_CONFIG_INCLUDE_PATH                              "conf.d" | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Option value constants | ||||
| ***********************************************************************************************************************************/ | ||||
| VARIANT_STRDEF_STATIC(OPTION_VALUE_0,                               "0"); | ||||
| VARIANT_STRDEF_STATIC(OPTION_VALUE_1,                               "1"); | ||||
|  | ||||
| /*********************************************************************************************************************************** | ||||
| Parse option flags | ||||
| ***********************************************************************************************************************************/ | ||||
| @@ -899,9 +905,9 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel) | ||||
|                         if (dependOptionDefType == cfgDefOptTypeBoolean) | ||||
|                         { | ||||
|                             if (cfgOptionBool(dependOptionId)) | ||||
|                                 dependValue = VARSTRDEF("1"); | ||||
|                                 dependValue = OPTION_VALUE_1; | ||||
|                             else | ||||
|                                 dependValue = VARSTRDEF("0"); | ||||
|                                 dependValue = OPTION_VALUE_0; | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
|   | ||||
| @@ -42,19 +42,19 @@ perlOptionJson(void) | ||||
|             { | ||||
|                 case cfgSourceParam: | ||||
|                 { | ||||
|                     source = VARSTRDEF("param"); | ||||
|                     source = varNewStrZ("param"); | ||||
|                     break; | ||||
|                 } | ||||
|  | ||||
|                 case cfgSourceConfig: | ||||
|                 { | ||||
|                     source = VARSTRDEF("config"); | ||||
|                     source = varNewStrZ("config"); | ||||
|                     break; | ||||
|                 } | ||||
|  | ||||
|                 case cfgSourceDefault: | ||||
|                 { | ||||
|                     source = VARSTRDEF("default"); | ||||
|                     source = varNewStrZ("default"); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -526,7 +526,7 @@ storagePath(const Storage *this, const String *pathExp) | ||||
|                 String *expression = strNewN(strPtr(pathExp), (size_t)(end - strPtr(pathExp) + 1)); | ||||
|  | ||||
|                 // Create a string from the path if there is anything left after the expression | ||||
|                 const String *path = NULL; | ||||
|                 String *path = NULL; | ||||
|  | ||||
|                 if (strSize(expression) < strSize(pathExp)) | ||||
|                 { | ||||
| @@ -538,7 +538,7 @@ storagePath(const Storage *this, const String *pathExp) | ||||
|                     if (end[2] == 0) | ||||
|                         THROW_FMT(AssertError, "path '%s' should not end in '/'", strPtr(pathExp)); | ||||
|  | ||||
|                     path = STR(end + 2); | ||||
|                     path = strNew(end + 2); | ||||
|                 } | ||||
|  | ||||
|                 // Evaluate the path | ||||
| @@ -553,6 +553,7 @@ storagePath(const Storage *this, const String *pathExp) | ||||
|  | ||||
|                 // Free temp vars | ||||
|                 strFree(expression); | ||||
|                 strFree(path); | ||||
|             } | ||||
|  | ||||
|             if (this->path == NULL) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user