pgbackrest.git / summary / log / commit / refs

commit    fe152b8f29ff794cd6108c8295e35c44fe37c847
Author:   Cynthia Shang <cynthia.shang@crunchydata.com>
Commit:   David Steele <david@pgmasters.net>
Date:     Mon Dec 10 23:08:26 2018 +0000

    Rename constants in Info module for consistency.
    
    INFO is generally used as the prefix for info file constants so rename these accordingly.
    
    Also follow newly-adopted coding standards for when #define is required for a static String constant.
    
    Contributed by Cynthia Shang.


doc/xml/release.xml | 8 ++++++++ src/info/info.c | 29 ++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index c34678a56..4f0ca0589 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -107,6 +107,14 @@ <p>Storage helper improvements. Allow <code>NULL</code> stanza in storage helper. Add path expression for repository backup.</p> </release-item> + <release-item> + <release-item-contributor-list> + <release-item-contributor id="cynthia.shang"/> + </release-item-contributor-list> + + <p>Rename constants in <code>Info</code> module for consistency.</p> + </release-item> + <release-item> <p>Allow I/O read interface to explicitly request blocking reads.</p> </release-item> diff --git a/src/info/info.c b/src/info/info.c index a13586757..64b46e46f 100644 --- a/src/info/info.c +++ b/src/info/info.c @@ -20,17 +20,12 @@ Internal constants ***********************************************************************************************************************************/ #define INI_COPY_EXT ".copy" -#define INI_SECTION_BACKREST "backrest" - STRING_STATIC(INI_SECTION_BACKREST_STR, INI_SECTION_BACKREST); -#define INI_SECTION_CIPHER "cipher" - STRING_STATIC(INI_SECTION_CIPHER_STR, INI_SECTION_CIPHER); - -#define INI_KEY_CIPHER_PASS "cipher-pass" - STRING_STATIC(INI_KEY_CIPHER_PASS_STR, INI_KEY_CIPHER_PASS); -#define INI_KEY_FORMAT "backrest-format" - STRING_STATIC(INI_KEY_FORMAT_STR, INI_KEY_FORMAT); -#define INI_KEY_CHECKSUM "backrest-checksum" - STRING_STATIC(INI_KEY_CHECKSUM_STR, INI_KEY_CHECKSUM); +STRING_STATIC(INFO_SECTION_BACKREST_STR, "backrest"); +STRING_STATIC(INFO_SECTION_CIPHER_STR, "cipher"); + +STRING_STATIC(INFO_KEY_CIPHER_PASS_STR, "cipher-pass"); +STRING_STATIC(INFO_KEY_CHECKSUM_STR, "backrest-checksum"); +STRING_STATIC(INFO_KEY_FORMAT_STR, "backrest-format"); /*********************************************************************************************************************************** Object type @@ -87,8 +82,8 @@ infoHash(const Ini *ini) String *key = strLstGet(keyList, keyIdx); // Skip the backrest checksum in the file - if ((strEq(section, INI_SECTION_BACKREST_STR) && !strEq(key, INI_KEY_CHECKSUM_STR)) || - !strEq(section, INI_SECTION_BACKREST_STR)) + if ((strEq(section, INFO_SECTION_BACKREST_STR) && !strEq(key, INFO_KEY_CHECKSUM_STR)) || + !strEq(section, INFO_SECTION_BACKREST_STR)) { cryptoHashProcessC(result, (const unsigned char *)"\"", 1); cryptoHashProcessStr(result, key); @@ -163,7 +158,7 @@ infoLoad(Info *this, const Storage *storage, bool copyFile, CipherType cipherTyp iniParse(this->ini, strNewBuf(buffer)); // Make sure the ini is valid by testing the checksum - String *infoChecksum = varStr(iniGet(this->ini, INI_SECTION_BACKREST_STR, INI_KEY_CHECKSUM_STR)); + String *infoChecksum = varStr(iniGet(this->ini, INFO_SECTION_BACKREST_STR, INFO_KEY_CHECKSUM_STR)); CryptoHash *hash = infoHash(this->ini); @@ -182,11 +177,11 @@ infoLoad(Info *this, const Storage *storage, bool copyFile, CipherType cipherTyp } // Make sure that the format is current, otherwise error - if (varIntForce(iniGet(this->ini, INI_SECTION_BACKREST_STR, INI_KEY_FORMAT_STR)) != REPOSITORY_FORMAT) + if (varIntForce(iniGet(this->ini, INFO_SECTION_BACKREST_STR, INFO_KEY_FORMAT_STR)) != REPOSITORY_FORMAT) { THROW_FMT( FormatError, "invalid format in '%s', expected %d but found %d", strPtr(fileName), REPOSITORY_FORMAT, - varIntForce(iniGet(this->ini, INI_SECTION_BACKREST_STR, INI_KEY_FORMAT_STR))); + varIntForce(iniGet(this->ini, INFO_SECTION_BACKREST_STR, INFO_KEY_FORMAT_STR))); } } MEM_CONTEXT_TEMP_END(); @@ -257,7 +252,7 @@ infoNew(const Storage *storage, const String *fileName, CipherType cipherType, c TRY_END(); // Load the cipher passphrase if it exists - String *cipherPass = varStr(iniGetDefault(this->ini, INI_SECTION_CIPHER_STR, INI_KEY_CIPHER_PASS_STR, NULL)); + String *cipherPass = varStr(iniGetDefault(this->ini, INFO_SECTION_CIPHER_STR, INFO_KEY_CIPHER_PASS_STR, NULL)); if (cipherPass != NULL) { [parent: e3435ec386c1]