1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-06 08:49:29 +02:00

Update command/check module to recent coding standards.

Add const as appropriate and remove an unneeded declaration.
This commit is contained in:
David Steele
2023-04-11 14:50:59 +04:00
parent a9c5cd9749
commit d6cb3de17a
2 changed files with 20 additions and 20 deletions

View File

@@ -43,7 +43,7 @@ checkManifest(void)
}
static void
checkStandby(const DbGetResult dbGroup, unsigned int pgPathDefinedTotal)
checkStandby(const DbGetResult dbGroup, const unsigned int pgPathDefinedTotal)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(DB_GET_RESULT, dbGroup);
@@ -126,7 +126,7 @@ checkPrimary(const DbGetResult dbGroup)
LOG_INFO_FMT(CFGCMD_CHECK " %s configuration (primary)", cfgOptionGroupName(cfgOptGrpRepo, repoIdx));
// Get the repo storage in case it is remote and encryption settings need to be pulled down (performed here for testing)
const Storage *storageRepo = storageRepoIdx(repoIdx);
const Storage *const storageRepo = storageRepoIdx(repoIdx);
// Check that the backup and archive info files exist and are valid for the current database of the stanza
checkStanzaInfoPg(
@@ -134,7 +134,7 @@ checkPrimary(const DbGetResult dbGroup)
cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
// Attempt to load the archive info file and retrieve the archiveId
InfoArchive *archiveInfo = infoArchiveLoadFile(
const InfoArchive *const archiveInfo = infoArchiveLoadFile(
storageRepo, INFO_ARCHIVE_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
@@ -142,23 +142,23 @@ checkPrimary(const DbGetResult dbGroup)
}
// Perform a WAL switch
const String *walSegment = dbWalSwitch(dbGroup.primary);
const String *const walSegment = dbWalSwitch(dbGroup.primary);
// Wait for the WAL to appear in each repo
for (unsigned int repoIdx = 0; repoIdx < cfgOptionGroupIdxTotal(cfgOptGrpRepo); repoIdx++)
{
LOG_INFO_FMT(CFGCMD_CHECK " %s archive for WAL (primary)", cfgOptionGroupName(cfgOptGrpRepo, repoIdx));
const Storage *storageRepo = storageRepoIdx(repoIdx);
const String *walSegmentFile = walSegmentFind(
storageRepo, repoArchiveId[repoIdx], walSegment, cfgOptionUInt64(cfgOptArchiveTimeout));
const String *const walSegmentFile = walSegmentFind(
storageRepoIdx(repoIdx), repoArchiveId[repoIdx], walSegment, cfgOptionUInt64(cfgOptArchiveTimeout));
LOG_INFO_FMT(
"WAL segment %s successfully archived to '%s' on %s",
strZ(walSegment),
strZ(
storagePathP(
storageRepo, strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(repoArchiveId[repoIdx]), strZ(walSegmentFile)))),
storageRepoIdx(repoIdx),
strNewFmt(STORAGE_REPO_ARCHIVE "/%s/%s", strZ(repoArchiveId[repoIdx]), strZ(walSegmentFile)))),
cfgOptionGroupName(cfgOptGrpRepo, repoIdx));
}
@@ -182,7 +182,7 @@ cmdCheck(void)
if (dbGroup.standby == NULL && dbGroup.primary == NULL)
THROW(ConfigError, "no database found\nHINT: check indexed pg-path/pg-host configurations");
unsigned int pgPathDefinedTotal = checkManifest();
const unsigned int pgPathDefinedTotal = checkManifest();
checkStandby(dbGroup, pgPathDefinedTotal);
checkPrimary(dbGroup);
}

View File

@@ -19,7 +19,7 @@ Check Common Handler
Helper function
***********************************************************************************************************************************/
static bool
checkArchiveCommand(const String *archiveCommand)
checkArchiveCommand(const String *const archiveCommand)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRING, archiveCommand);
@@ -42,7 +42,7 @@ checkArchiveCommand(const String *archiveCommand)
/**********************************************************************************************************************************/
FN_EXTERN void
checkDbConfig(const unsigned int pgVersion, const unsigned int pgIdx, const Db *dbObject, bool isStandby)
checkDbConfig(const unsigned int pgVersion, const unsigned int pgIdx, const Db *const dbObject, const bool isStandby)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(UINT, pgVersion);
@@ -55,8 +55,8 @@ checkDbConfig(const unsigned int pgVersion, const unsigned int pgIdx, const Db *
MEM_CONTEXT_TEMP_BEGIN()
{
unsigned int dbVersion = dbPgVersion(dbObject);
const String *dbPath = dbPgDataPath(dbObject);
const unsigned int dbVersion = dbPgVersion(dbObject);
const String *const dbPath = dbPgDataPath(dbObject);
// Error if the version from the control file and the configured pg-path do not match the values obtained from the database
if (pgVersion != dbVersion || strCmp(cfgOptionIdxStr(cfgOptPgPath, pgIdx), dbPath) != 0)
@@ -95,7 +95,7 @@ checkDbConfig(const unsigned int pgVersion, const unsigned int pgIdx, const Db *
/**********************************************************************************************************************************/
FN_EXTERN void
checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo)
checkStanzaInfo(const InfoPgData *const archiveInfo, const InfoPgData *const backupInfo)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM_P(INFO_PG_DATA, archiveInfo);
@@ -124,8 +124,8 @@ checkStanzaInfo(const InfoPgData *archiveInfo, const InfoPgData *backupInfo)
/**********************************************************************************************************************************/
FN_EXTERN void
checkStanzaInfoPg(
const Storage *storage, const unsigned int pgVersion, const uint64_t pgSystemId, CipherType cipherType,
const String *cipherPass)
const Storage *const storage, const unsigned int pgVersion, const uint64_t pgSystemId, CipherType const cipherType,
const String *const cipherPass)
{
FUNCTION_TEST_BEGIN();
FUNCTION_LOG_PARAM(STORAGE, storage);
@@ -140,10 +140,10 @@ checkStanzaInfoPg(
MEM_CONTEXT_TEMP_BEGIN()
{
// Check that the backup and archive info files exist
InfoArchive *infoArchive = infoArchiveLoadFile(storage, INFO_ARCHIVE_PATH_FILE_STR, cipherType, cipherPass);
InfoPgData archiveInfoPg = infoPgData(infoArchivePg(infoArchive), infoPgDataCurrentId(infoArchivePg(infoArchive)));
InfoBackup *infoBackup = infoBackupLoadFile(storage, INFO_BACKUP_PATH_FILE_STR, cipherType, cipherPass);
InfoPgData backupInfoPg = infoPgData(infoBackupPg(infoBackup), infoPgDataCurrentId(infoBackupPg(infoBackup)));
const InfoArchive *const infoArchive = infoArchiveLoadFile(storage, INFO_ARCHIVE_PATH_FILE_STR, cipherType, cipherPass);
const InfoPgData archiveInfoPg = infoPgData(infoArchivePg(infoArchive), infoPgDataCurrentId(infoArchivePg(infoArchive)));
const InfoBackup *const infoBackup = infoBackupLoadFile(storage, INFO_BACKUP_PATH_FILE_STR, cipherType, cipherPass);
const InfoPgData backupInfoPg = infoPgData(infoBackupPg(infoBackup), infoPgDataCurrentId(infoBackupPg(infoBackup)));
// Check that the info files pg data match each other
checkStanzaInfo(&archiveInfoPg, &backupInfoPg);