From 456a300bb703024df46cbc34746649c7b54181b2 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 26 Jan 2021 12:10:24 -0500 Subject: [PATCH] Remove too-verbose braces in switch statements. The original intention was to enclose complex code in braces but somehow braces got propagated almost everywhere. Document the standard for braces in switch statements and update the code to reflect the standard. --- CODING.md | 20 +++++++ doc/xml/coding.xml | 22 ++++++++ src/command/backup/backup.c | 4 -- src/command/backup/common.c | 6 -- src/command/info/info.c | 20 ------- src/command/repo/ls.c | 8 --- src/command/restore/restore.c | 2 - src/common/compress/bz2/common.c | 20 ------- src/common/compress/gz/common.c | 16 ------ src/common/exit.c | 6 -- src/common/io/tls/session.c | 4 -- src/common/type/json.c | 48 +++------------- src/common/type/list.c | 2 - src/common/type/variant.c | 82 ---------------------------- src/config/config.c | 10 ---- src/config/parse.c | 12 ---- src/info/manifest.c | 2 - src/main.c | 34 ------------ src/postgres/client.c | 8 --- src/protocol/parallelJob.c | 6 -- test/src/common/harnessPack.c | 22 -------- test/src/common/harnessServer.c | 8 --- test/src/common/harnessStorage.c | 6 -- test/src/common/harnessTest.c | 16 ------ test/src/module/command/backupTest.c | 5 -- test/src/module/storage/azureTest.c | 4 -- test/src/module/storage/s3Test.c | 4 -- 27 files changed, 50 insertions(+), 347 deletions(-) diff --git a/CODING.md b/CODING.md index 0587b0af9..a1900d631 100644 --- a/CODING.md +++ b/CODING.md @@ -162,6 +162,26 @@ if (condition) valueThatUsesEntireLine2; } ``` +Braces should be added to `switch` statement cases that have a significant amount of code. As a general rule of thumb, if the code block in the `case` is large enough to have blank lines and/or multiple comments then it should be enclosed in braces. +```c +switch (int) +{ + case 1: + a = 2; + break; + + case 2: + { + # Comment this more complex code + a = 1; + b = 2; + + c = func(a, b); + + break; + } +} +``` #### Hints, Warnings, and Errors diff --git a/doc/xml/coding.xml b/doc/xml/coding.xml index 296ab4efd..d15f0250c 100644 --- a/doc/xml/coding.xml +++ b/doc/xml/coding.xml @@ -209,6 +209,28 @@ if (condition) return valueThatUsesEntireLine1 && valueThatUsesEntireLine2; +} + + +

Braces should be added to switch statement cases that have a significant amount of code. As a general rule of thumb, if the code block in the case is large enough to have blank lines and/or multiple comments then it should be enclosed in braces.

+ + +switch (int) +{ + case 1: + a = 2; + break; + + case 2: + { + # Comment this more complex code + a = 1; + b = 2; + + c = func(a, b); + + break; + } } diff --git a/src/command/backup/backup.c b/src/command/backup/backup.c index 476da5e25..d1071b69e 100644 --- a/src/command/backup/backup.c +++ b/src/command/backup/backup.c @@ -647,19 +647,15 @@ void backupResumeCallback(void *data, const StorageInfo *info) // The link will be recreated during the backup if needed. // ------------------------------------------------------------------------------------------------------------------------- case storageTypeLink: - { storageRemoveP(storageRepoWrite(), backupPath); break; - } // Remove special files // ------------------------------------------------------------------------------------------------------------------------- case storageTypeSpecial: - { LOG_WARN_FMT("remove special file '%s' from resumed backup", strZ(storagePathP(storageRepo(), backupPath))); storageRemoveP(storageRepoWrite(), backupPath); break; - } } FUNCTION_TEST_RETURN_VOID(); diff --git a/src/command/backup/common.c b/src/command/backup/common.c index 521795714..f7ded2db1 100644 --- a/src/command/backup/common.c +++ b/src/command/backup/common.c @@ -122,22 +122,16 @@ const String *backupTypeStr(BackupType type) switch (type) { case backupTypeFull: - { result = BACKUP_TYPE_FULL_STR; break; - } case backupTypeDiff: - { result = BACKUP_TYPE_DIFF_STR; break; - } case backupTypeIncr: - { result = BACKUP_TYPE_INCR_STR; break; - } } FUNCTION_TEST_RETURN(result); diff --git a/src/command/info/info.c b/src/command/info/info.c index bf9c2b0d1..59e20ed56 100644 --- a/src/command/info/info.c +++ b/src/command/info/info.c @@ -165,40 +165,28 @@ stanzaStatus(const int code, bool backupLockHeld, Variant *stanzaInfo) switch (code) { case INFO_STANZA_STATUS_CODE_OK: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_OK_STR)); break; - } case INFO_STANZA_STATUS_CODE_MISSING_STANZA_PATH: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_MISSING_STANZA_PATH_STR)); break; - } case INFO_STANZA_STATUS_CODE_MISSING_STANZA_DATA: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_MISSING_STANZA_DATA_STR)); break; - } case INFO_STANZA_STATUS_CODE_NO_BACKUP: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_NO_BACKUP_STR)); break; - } case INFO_STANZA_STATUS_CODE_MIXED: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_MESSAGE_MIXED_STR)); break; - } case INFO_STANZA_STATUS_CODE_PG_MISMATCH: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_PG_MISMATCH_STR)); break; - } } // Construct a specific lock part @@ -230,28 +218,20 @@ repoStanzaStatus(const int code, Variant *repoStanzaInfo) switch (code) { case INFO_STANZA_STATUS_CODE_OK: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_OK_STR)); break; - } case INFO_STANZA_STATUS_CODE_MISSING_STANZA_PATH: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_MISSING_STANZA_PATH_STR)); break; - } case INFO_STANZA_STATUS_CODE_MISSING_STANZA_DATA: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_MISSING_STANZA_DATA_STR)); break; - } case INFO_STANZA_STATUS_CODE_NO_BACKUP: - { kvAdd(statusKv, STATUS_KEY_MESSAGE_VAR, VARSTR(INFO_STANZA_STATUS_MESSAGE_NO_BACKUP_STR)); break; - } } FUNCTION_TEST_RETURN_VOID(); diff --git a/src/command/repo/ls.c b/src/command/repo/ls.c index 01e790981..6489a8bd0 100644 --- a/src/command/repo/ls.c +++ b/src/command/repo/ls.c @@ -60,28 +60,20 @@ storageListRenderCallback(void *data, const StorageInfo *info) switch (info->type) { case storageTypeFile: - { ioWrite(listData->write, BUFSTRDEF("file\"")); break; - } case storageTypeLink: - { ioWrite(listData->write, BUFSTRDEF("link\"")); break; - } case storageTypePath: - { ioWrite(listData->write, BUFSTRDEF("path\"")); break; - } case storageTypeSpecial: - { ioWrite(listData->write, BUFSTRDEF("special\"")); break; - } } if (info->type == storageTypeFile) diff --git a/src/command/restore/restore.c b/src/command/restore/restore.c index a87bd5524..695bf483a 100644 --- a/src/command/restore/restore.c +++ b/src/command/restore/restore.c @@ -867,11 +867,9 @@ restoreCleanInfoListCallback(void *data, const StorageInfo *info) // Special file types cannot exist in the manifest so just delete them case storageTypeSpecial: - { LOG_DETAIL_FMT("remove special file '%s'", strZ(pgPath)); storageRemoveP(storageLocalWrite(), pgPath, .errorOnMissing = true); break; - } } FUNCTION_TEST_RETURN_VOID(); diff --git a/src/common/compress/bz2/common.c b/src/common/compress/bz2/common.c index 622b7c99d..e02870ecf 100644 --- a/src/common/compress/bz2/common.c +++ b/src/common/compress/bz2/common.c @@ -25,67 +25,47 @@ bz2Error(int error) switch (error) { case BZ_SEQUENCE_ERROR: - { errorMsg = "sequence error"; break; - } case BZ_PARAM_ERROR: - { errorMsg = "parameter error"; break; - } case BZ_MEM_ERROR: - { errorMsg = "memory error"; errorType = &MemoryError; break; - } case BZ_DATA_ERROR: - { errorMsg = "data error"; errorType = &FormatError; break; - } case BZ_DATA_ERROR_MAGIC: - { errorMsg = "data error magic"; errorType = &FormatError; break; - } case BZ_IO_ERROR: - { errorMsg = "io error"; break; - } case BZ_UNEXPECTED_EOF: - { errorMsg = "unexpected eof"; break; - } case BZ_OUTBUFF_FULL: - { errorMsg = "outbuff full"; break; - } case BZ_CONFIG_ERROR: - { errorMsg = "config error"; break; - } default: - { errorMsg = "unknown error"; break; - } } THROWP_FMT(errorType, "bz2 error: [%d] %s", error, errorMsg); diff --git a/src/common/compress/gz/common.c b/src/common/compress/gz/common.c index b21353f7c..a597b2f0b 100644 --- a/src/common/compress/gz/common.c +++ b/src/common/compress/gz/common.c @@ -22,58 +22,42 @@ gzError(int error) { // Not exactly an error, but since we are not using custom dictionaries it shouldn't be possible to get this result case Z_NEED_DICT: - { errorMsg = "need dictionary"; break; - } // We should not get this error -- included for completeness case Z_ERRNO: - { errorMsg = "file error"; break; - } case Z_STREAM_ERROR: - { errorMsg = "stream error"; errorType = &FormatError; break; - } case Z_DATA_ERROR: - { errorMsg = "data error"; errorType = &FormatError; break; - } case Z_MEM_ERROR: - { errorMsg = "insufficient memory"; errorType = &MemoryError; break; - } // This error indicates an error in the code -- there should always be space in the buffer case Z_BUF_ERROR: - { errorMsg = "no space in buffer"; break; - } case Z_VERSION_ERROR: - { errorMsg = "incompatible version"; errorType = &FormatError; break; - } default: - { errorMsg = "unknown error"; break; - } } THROWP_FMT(errorType, "zlib threw error: [%d] %s", error, errorMsg); diff --git a/src/common/exit.c b/src/common/exit.c index e6bca8a54..1613de23e 100644 --- a/src/common/exit.c +++ b/src/common/exit.c @@ -31,22 +31,16 @@ exitSignalName(SignalType signalType) switch (signalType) { case signalTypeHup: - { name = "HUP"; break; - } case signalTypeInt: - { name = "INT"; break; - } case signalTypeTerm: - { name = "TERM"; break; - } case signalTypeNone: THROW(AssertError, "no name for signal none"); diff --git a/src/common/io/tls/session.c b/src/common/io/tls/session.c index 31b24003e..f2bc9cf44 100644 --- a/src/common/io/tls/session.c +++ b/src/common/io/tls/session.c @@ -134,19 +134,15 @@ tlsSessionResultProcess(TlsSession *this, int errorTls, long unsigned int errorT // Try again after waiting for read ready case SSL_ERROR_WANT_READ: - { ioReadReadyP(ioSessionIoRead(this->ioSession), .error = true); result = 0; break; - } // Try again after waiting for write ready case SSL_ERROR_WANT_WRITE: - { ioWriteReadyP(ioSessionIoWrite(this->ioSession), .error = true); result = 0; break; - } // A syscall failed (this usually indicates unexpected eof) case SSL_ERROR_SYSCALL: diff --git a/src/common/type/json.c b/src/common/type/json.c index 311599088..cfecf3dc3 100644 --- a/src/common/type/json.c +++ b/src/common/type/json.c @@ -259,35 +259,35 @@ jsonToStrInternal(const char *json, unsigned int *jsonPos) switch (json[*jsonPos]) { case '"': - strCatChr(result, '"'); + strCatChr(result, '"'); break; case '\\': - strCatChr(result, '\\'); + strCatChr(result, '\\'); break; case '/': - strCatChr(result, '/'); + strCatChr(result, '/'); break; case 'n': - strCatChr(result, '\n'); + strCatChr(result, '\n'); break; case 'r': - strCatChr(result, '\r'); + strCatChr(result, '\r'); break; case 't': - strCatChr(result, '\t'); + strCatChr(result, '\t'); break; case 'b': - strCatChr(result, '\b'); + strCatChr(result, '\b'); break; case 'f': - strCatChr(result, '\f'); + strCatChr(result, '\f'); break; default: @@ -515,26 +515,20 @@ jsonToVarInternal(const char *json, unsigned int *jsonPos) { // String case '"': - { result = varNewStr(jsonToStrInternal(json, jsonPos)); break; - } // Integer case '-': case '0' ... '9': - { result = jsonToNumberInternal(json, jsonPos); break; - } // Boolean case 't': case 'f': - { result = varNewBool(jsonToBoolInternal(json, jsonPos)); break; - } // Null case 'n': @@ -549,24 +543,18 @@ jsonToVarInternal(const char *json, unsigned int *jsonPos) // Array case '[': - { result = varNewVarLst(jsonToVarLstInternal(json, jsonPos)); break; - } // Object case '{': - { result = varNewKv(jsonToKvInternal(json, jsonPos)); break; - } // Object default: - { THROW_FMT(JsonFormatError, "invalid type at '%s'", json + *jsonPos); break; - } } jsonConsumeWhiteSpace(json, jsonPos); @@ -705,46 +693,32 @@ jsonFromStrInternal(String *json, const String *string) switch (stringChr) { case '"': - { strCatZ(json, "\\\""); break; - } case '\\': - { strCatZ(json, "\\\\"); break; - } case '\n': - { strCatZ(json, "\\n"); break; - } case '\r': - { strCatZ(json, "\\r"); break; - } case '\t': - { strCatZ(json, "\\t"); break; - } case '\b': - { strCatZ(json, "\\b"); break; - } case '\f': - { strCatZ(json, "\\f"); break; - } } break; @@ -823,10 +797,8 @@ jsonFromKvInternal(const KeyValue *kv) switch (varType(value)) { case varTypeKeyValue: - { strCat(result, jsonFromKvInternal(kvDup(varKv(value)))); break; - } case varTypeVariantList: { @@ -878,16 +850,12 @@ jsonFromKvInternal(const KeyValue *kv) // String case varTypeString: - { jsonFromStrInternal(result, varStr(value)); break; - } default: - { strCat(result, varStrForce(value)); break; - } } } } diff --git a/src/common/type/list.c b/src/common/type/list.c index b419c206e..12eba9bb8 100644 --- a/src/common/type/list.c +++ b/src/common/type/list.c @@ -433,10 +433,8 @@ lstSort(List *this, SortOrder sortOrder) switch (sortOrder) { case sortOrderAsc: - { qsort(this->list, this->listSize, this->itemSize, this->comparator); break; - } case sortOrderDesc: { diff --git a/src/common/type/variant.c b/src/common/type/variant.c index 6088fde6c..69a3ab46a 100644 --- a/src/common/type/variant.c +++ b/src/common/type/variant.c @@ -120,22 +120,16 @@ varDup(const Variant *this) switch (this->type) { case varTypeBool: - { result = varNewBool(varBool(this)); break; - } case varTypeInt: - { result = varNewInt(varInt(this)); break; - } case varTypeInt64: - { result = varNewInt64(varInt64(this)); break; - } case varTypeKeyValue: { @@ -153,28 +147,20 @@ varDup(const Variant *this) } case varTypeString: - { result = varNewStr(varStr(this)); break; - } case varTypeUInt: - { result = varNewUInt(varUInt(this)); break; - } case varTypeUInt64: - { result = varNewUInt64(varUInt64(this)); break; - } case varTypeVariantList: - { result = varNewVarLst(varVarLst(this)); break; - } } } @@ -201,40 +187,28 @@ varEq(const Variant *this1, const Variant *this2) switch (varType(this1)) { case varTypeBool: - { result = varBool(this1) == varBool(this2); break; - } case varTypeInt: - { result = varInt(this1) == varInt(this2); break; - } case varTypeInt64: - { result = varInt64(this1) == varInt64(this2); break; - } case varTypeString: - { result = strEq(varStr(this1), varStr(this2)); break; - } case varTypeUInt: - { result = varUInt(this1) == varUInt(this2); break; - } case varTypeUInt64: - { result = varUInt64(this1) == varUInt64(this2); break; - } default: THROW_FMT(AssertError, "unable to test equality for %s", variantTypeName[this1->type]); @@ -412,16 +386,12 @@ varIntForce(const Variant *this) switch (this->type) { case varTypeBool: - { result = varBool(this); break; - } case varTypeInt: - { result = varInt(this); break; - } case varTypeInt64: { @@ -438,10 +408,8 @@ varIntForce(const Variant *this) } case varTypeString: - { result = cvtZToInt(strZ(varStr(this))); break; - } case varTypeUInt: { @@ -527,35 +495,25 @@ varInt64Force(const Variant *this) switch (this->type) { case varTypeBool: - { result = varBool(this); break; - } case varTypeInt: - { result = (int64_t)varInt(this); break; - } case varTypeInt64: - { result = varInt64(this); break; - } case varTypeString: - { result = cvtZToInt64(strZ(varStr(this))); break; - } case varTypeUInt: - { result = varUInt(this); break; - } case varTypeUInt64: { @@ -630,10 +588,8 @@ varUIntForce(const Variant *this) switch (this->type) { case varTypeBool: - { result = varBool(this); break; - } case varTypeInt: { @@ -670,10 +626,8 @@ varUIntForce(const Variant *this) } case varTypeUInt: - { result = varUInt(this); break; - } case varTypeUInt64: { @@ -693,10 +647,8 @@ varUIntForce(const Variant *this) } case varTypeString: - { result = cvtZToUInt(strZ(varStr(this))); break; - } default: THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeUInt]); @@ -754,10 +706,8 @@ varUInt64Force(const Variant *this) switch (this->type) { case varTypeBool: - { result = varBool(this); break; - } case varTypeInt: { @@ -794,22 +744,16 @@ varUInt64Force(const Variant *this) } case varTypeString: - { result = cvtZToUInt64(strZ(varStr(this))); break; - } case varTypeUInt: - { result = varUInt(this); break; - } case varTypeUInt64: - { result = varUInt64(this); break; - } default: THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeUInt64]); @@ -924,10 +868,8 @@ varStrForce(const Variant *this) switch (varType(this)) { case varTypeBool: - { result = strNew(cvtBoolToConstZ(varBool(this))); break; - } case varTypeInt: { @@ -948,10 +890,8 @@ varStrForce(const Variant *this) } case varTypeString: - { result = strDup(varStr(this)); break; - } case varTypeUInt: { @@ -1033,22 +973,16 @@ varToLog(const Variant *this) switch (varType(this)) { case varTypeString: - { result = strToLog(varStr(this)); break; - } case varTypeKeyValue: - { result = strNew("{KeyValue}"); break; - } case varTypeVariantList: - { result = strNew("{VariantList}"); break; - } case varTypeBool: case varTypeInt: @@ -1080,55 +1014,39 @@ varFree(Variant *this) switch (this->type) { case varTypeBool: - { memContext = ((VariantBool *)this)->memContext; break; - } case varTypeInt: - { memContext = ((VariantInt *)this)->memContext; break; - } case varTypeInt64: - { memContext = ((VariantInt64 *)this)->memContext; break; - } case varTypeKeyValue: - { memContext = ((VariantKeyValue *)this)->memContext; kvFree(((VariantKeyValue *)this)->data); break; - } case varTypeString: - { memContext = ((VariantString *)this)->memContext; strFree(((VariantString *)this)->data); break; - } case varTypeUInt: - { memContext = ((VariantUInt *)this)->memContext; break; - } case varTypeUInt64: - { memContext = ((VariantUInt64 *)this)->memContext; break; - } case varTypeVariantList: - { memContext = ((VariantVariantList *)this)->memContext; varLstFree(((VariantVariantList *)this)->data); break; - } } MEM_CONTEXT_BEGIN(memContext) diff --git a/src/config/config.c b/src/config/config.c index 4d21d5c63..a660ae27b 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -257,22 +257,16 @@ cfgCommandRoleStr(ConfigCommandRole commandRole) break; case cfgCmdRoleAsync: - { result = CONFIG_COMMAND_ROLE_ASYNC_STR; break; - } case cfgCmdRoleLocal: - { result = CONFIG_COMMAND_ROLE_LOCAL_STR; break; - } case cfgCmdRoleRemote: - { result = CONFIG_COMMAND_ROLE_REMOTE_STR; break; - } } FUNCTION_TEST_RETURN(result); @@ -523,18 +517,14 @@ cfgOptionDefaultValue(ConfigOption optionId) switch (cfgParseOptionType(optionId)) { case cfgOptTypeBoolean: - { result = varNewBool(varBoolForce(defaultValue)); break; - } case cfgOptTypeInteger: case cfgOptTypeSize: case cfgOptTypeTime: - { result = varNewInt64(varInt64Force(defaultValue)); break; - } case cfgOptTypePath: case cfgOptTypeString: diff --git a/src/config/parse.c b/src/config/parse.c index 6962a55c9..44578406d 100644 --- a/src/config/parse.c +++ b/src/config/parse.c @@ -597,40 +597,28 @@ sizeQualifierToMultiplier(char qualifier) switch (qualifier) { case 'b': - { result = 1; break; - } case 'k': - { result = 1024; break; - } case 'm': - { result = 1024 * 1024; break; - } case 'g': - { result = 1024 * 1024 * 1024; break; - } case 't': - { result = 1024LL * 1024LL * 1024LL * 1024LL; break; - } case 'p': - { result = 1024LL * 1024LL * 1024LL * 1024LL * 1024LL; break; - } default: THROW_FMT(AssertError, "'%c' is not a valid size qualifier", qualifier); diff --git a/src/info/manifest.c b/src/info/manifest.c index 1a0b87cd0..1fefc5501 100644 --- a/src/info/manifest.c +++ b/src/info/manifest.c @@ -839,10 +839,8 @@ manifestBuildCallback(void *data, const StorageInfo *info) // Skip special files // ------------------------------------------------------------------------------------------------------------------------- case storageTypeSpecial: - { LOG_WARN_FMT("exclude special file '%s/%s' from backup", strZ(buildData.pgPath), strZ(info->name)); break; - } } FUNCTION_TEST_RETURN_VOID(); diff --git a/src/main.c b/src/main.c index 11121b1dc..edfa83388 100644 --- a/src/main.c +++ b/src/main.c @@ -141,139 +141,105 @@ main(int argListSize, const char *argList[]) // Check command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdCheck: - { cmdCheck(); break; - } // Expire command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdExpire: - { cmdExpire(); break; - } // Help command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdHelp: case cfgCmdNone: - { THROW(AssertError, "'help' and 'none' commands should have been handled already"); - } // Info command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdInfo: - { cmdInfo(); break; - } // Repository create command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdRepoCreate: - { cmdRepoCreate(); break; - } // Repository get file command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdRepoGet: - { result = cmdStorageGet(); break; - } // Repository list paths/files command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdRepoLs: - { cmdStorageList(); break; - } // Repository put file command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdRepoPut: - { cmdStoragePut(); break; - } // Repository remove paths/files command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdRepoRm: - { cmdStorageRemove(); break; - } // Restore command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdRestore: - { cmdRestore(); break; - } // Stanza create command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdStanzaCreate: - { cmdStanzaCreate(); break; - } // Stanza delete command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdStanzaDelete: - { cmdStanzaDelete(); break; - } // Stanza upgrade command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdStanzaUpgrade: - { cmdStanzaUpgrade(); break; - } // Start command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdStart: - { cmdStart(); break; - } // Stop command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdStop: - { cmdStop(); break; - } // Verify command // ----------------------------------------------------------------------------------------------------------------- case cfgCmdVerify: - { cmdVerify(); break; - } // Display version // ----------------------------------------------------------------------------------------------------------------- case cfgCmdVersion: - { printf(PROJECT_NAME " " PROJECT_VERSION "\n"); fflush(stdout); break; - } } } } diff --git a/src/postgres/client.c b/src/postgres/client.c index 59ce62f68..e3e4d537b 100644 --- a/src/postgres/client.c +++ b/src/postgres/client.c @@ -280,36 +280,28 @@ pgClientQuery(PgClient *this, const String *query) { // Boolean type case 16: // bool - { varLstAdd(resultRow, varNewBool(varBoolForce(varNewStrZ(value)))); break; - } // Text/char types case 18: // char case 19: // name case 25: // text - { varLstAdd(resultRow, varNewStrZ(value)); break; - } // Integer types case 20: // int8 case 21: // int2 case 23: // int4 case 26: // oid - { varLstAdd(resultRow, varNewInt64(cvtZToInt64(value))); break; - } default: - { THROW_FMT( FormatError, "unable to parse type %u in column %d for query '%s'", columnType[columnIdx], columnIdx, strZ(query)); - } } } } diff --git a/src/protocol/parallelJob.c b/src/protocol/parallelJob.c index 6d9f4cb16..953afeb84 100644 --- a/src/protocol/parallelJob.c +++ b/src/protocol/parallelJob.c @@ -241,22 +241,16 @@ protocolParallelJobToConstZ(ProtocolParallelJobState state) switch (state) { case protocolParallelJobStatePending: - { result = "pending"; break; - } case protocolParallelJobStateRunning: - { result = "running"; break; - } case protocolParallelJobStateDone: - { result = "done"; break; - } } return result; diff --git a/test/src/common/harnessPack.c b/test/src/common/harnessPack.c index f4bf6c332..071244922 100644 --- a/test/src/common/harnessPack.c +++ b/test/src/common/harnessPack.c @@ -45,74 +45,52 @@ String *hrnPackToStr(PackRead *read) THROW_FMT(AssertError, "invalid type %s", strZ(pckTypeToStr(type))); case pckTypeArray: - { pckReadArrayBeginP(read, .id = id); strCatFmt(result, "[%s]", strZ(hrnPackToStr(read))); pckReadArrayEndP(read); break; - } case pckTypeBool: - { strCatZ(result, cvtBoolToConstZ(pckReadBoolP(read, .id = id))); break; - } case pckTypeBin: - { strCatFmt(result, "%s", strZ(bufHex(pckReadBinP(read, .id = id)))); break; - } case pckTypeI32: - { strCatFmt(result, "%d", pckReadI32P(read, .id = id)); break; - } case pckTypeI64: - { strCatFmt(result, "%" PRId64, pckReadI64P(read, .id = id)); break; - } case pckTypeObj: - { pckReadObjBeginP(read, .id = id); strCatFmt(result, "{%s}", strZ(hrnPackToStr(read))); pckReadObjEndP(read); break; - } case pckTypePtr: - { strCatFmt(result, "%p", pckReadPtrP(read, .id = id)); break; - } case pckTypeStr: - { strCatFmt(result, "%s", strZ(pckReadStrP(read, .id = id))); break; - } case pckTypeTime: - { strCatFmt(result, "%" PRId64, (int64_t)pckReadTimeP(read, .id = id)); break; - } case pckTypeU32: - { strCatFmt(result, "%u", pckReadU32P(read, .id = id)); break; - } case pckTypeU64: - { strCatFmt(result, "%" PRIu64, pckReadU64P(read, .id = id)); break; - } } first = false; diff --git a/test/src/common/harnessServer.c b/test/src/common/harnessServer.c index 64b9c5092..7660c884f 100644 --- a/test/src/common/harnessServer.c +++ b/test/src/common/harnessServer.c @@ -368,10 +368,8 @@ void hrnServerRun(IoRead *read, HrnServerProtocol protocol, HrnServerRunParam pa } case hrnServerCmdDone: - { done = true; break; - } case hrnServerCmdExpect: { @@ -409,19 +407,13 @@ void hrnServerRun(IoRead *read, HrnServerProtocol protocol, HrnServerRunParam pa } case hrnServerCmdReply: - { ioWrite(ioSessionIoWrite(serverSession), BUFSTR(varStr(data))); ioWriteFlush(ioSessionIoWrite(serverSession)); - break; - } case hrnServerCmdSleep: - { sleepMSec(varUInt64Force(data)); - break; - } } } while (!done); diff --git a/test/src/common/harnessStorage.c b/test/src/common/harnessStorage.c index 89fe16e84..e76cef6cc 100644 --- a/test/src/common/harnessStorage.c +++ b/test/src/common/harnessStorage.c @@ -110,22 +110,16 @@ hrnStorageInfoListCallback(void *callbackData, const StorageInfo *info) } case storageTypeLink: - { strCatFmt(data->content, "link, d=%s", strZ(info->linkDestination)); break; - } case storageTypePath: - { strCatZ(data->content, "path"); break; - } case storageTypeSpecial: - { strCatZ(data->content, "special"); break; - } } if (info->type != storageTypeSpecial) diff --git a/test/src/common/harnessTest.c b/test/src/common/harnessTest.c index 789e13025..375e2757a 100644 --- a/test/src/common/harnessTest.c +++ b/test/src/common/harnessTest.c @@ -593,16 +593,12 @@ void hrnTestResultInt64(int64_t actual, int64_t expected, HarnessTestResultOpera switch (operation) { case harnessTestResultOperationEq: - { result = actual == expected; break; - } case harnessTestResultOperationNe: - { result = actual != expected; break; - } } if (!result) @@ -628,16 +624,12 @@ void hrnTestResultPtr(const void *actual, const void *expected, HarnessTestResul switch (operation) { case harnessTestResultOperationEq: - { result = actual == expected; break; - } case harnessTestResultOperationNe: - { result = actual != expected; break; - } } if (!result) @@ -676,16 +668,12 @@ void hrnTestResultUInt64(uint64_t actual, uint64_t expected, HarnessTestResultOp switch (operation) { case harnessTestResultOperationEq: - { result = actual == expected; break; - } case harnessTestResultOperationNe: - { result = actual != expected; break; - } } if (!result) @@ -729,18 +717,14 @@ void hrnTestResultZ(const char *actual, const char *expected, HarnessTestResultO switch (operation) { case harnessTestResultOperationEq: - { result = (actual == NULL && expected == NULL) || (actual != NULL && expected != NULL && strcmp(actual, expected) == 0); break; - } case harnessTestResultOperationNe: - { result = (actual == NULL && expected != NULL) || (actual != NULL && expected == NULL) || (actual != NULL && expected != NULL && strcmp(actual, expected) == 0); break; - } } if (!result) diff --git a/test/src/module/command/backupTest.c b/test/src/module/command/backupTest.c index 0a9b08420..b996a87ff 100644 --- a/test/src/module/command/backupTest.c +++ b/test/src/module/command/backupTest.c @@ -117,10 +117,8 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info) } case storageTypeLink: - { strCatFmt(data->content, "link, d=%s", strZ(info->linkDestination)); break; - } case storageTypePath: { @@ -145,10 +143,7 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info) } case storageTypeSpecial: - { THROW_FMT(AssertError, "unexpected special file '%s'", strZ(info->name)); - break; - } } strCatZ(data->content, "}\n"); diff --git a/test/src/module/storage/azureTest.c b/test/src/module/storage/azureTest.c index 308f6ff71..97994ad2d 100644 --- a/test/src/module/storage/azureTest.c +++ b/test/src/module/storage/azureTest.c @@ -130,16 +130,12 @@ testResponse(IoWrite *write, TestResponseParam param) switch (param.code) { case 200: - { strCatZ(response, "OK"); break; - } case 403: - { strCatZ(response, "Forbidden"); break; - } } // End header diff --git a/test/src/module/storage/s3Test.c b/test/src/module/storage/s3Test.c index c77924000..c50c5eac5 100644 --- a/test/src/module/storage/s3Test.c +++ b/test/src/module/storage/s3Test.c @@ -148,16 +148,12 @@ testResponse(IoWrite *write, TestResponseParam param) switch (param.code) { case 200: - { strCatZ(response, "OK"); break; - } case 403: - { strCatZ(response, "Forbidden"); break; - } } // End header