From b9f636cab470165ff0d69baa54efa5f8b2a79d43 Mon Sep 17 00:00:00 2001 From: David Steele Date: Thu, 5 Apr 2018 22:38:11 -0400 Subject: [PATCH] Cleanup C types. * Remove pgBackRest defined types included with the C types. * Remove redefinition of standard C types. --- doc/xml/release.xml | 4 ++ src/cipher/cipher.h | 2 +- src/command/archive/push/push.c | 2 +- src/command/help/help.c | 2 +- src/common/encode.h | 2 +- src/common/encode/base64.h | 2 +- src/common/error.h | 2 +- src/common/ini.h | 2 + src/common/io/handle.h | 2 +- src/common/log.h | 2 +- src/common/memContext.h | 2 +- src/common/regExp.c | 2 +- src/common/regExp.h | 2 + src/common/time.c | 2 +- src/common/time.h | 4 +- src/common/type/buffer.h | 2 +- src/common/type/keyValue.c | 2 +- src/common/type/keyValue.h | 4 +- src/common/type/variant.c | 14 +++--- src/common/type/variant.h | 8 ++-- src/common/type/variantList.h | 5 ++- src/common/{type.h => typec.h} | 26 ++--------- src/config/config.c | 2 +- src/config/config.h | 4 +- src/config/define.c | 16 +++---- src/config/define.h | 2 +- src/perl/config.h | 2 - src/perl/exec.c | 2 +- src/postgres/pageChecksum.c | 45 ++++++++++--------- src/postgres/pageChecksum.h | 8 ++-- src/storage/storage.h | 2 +- test/lib/pgBackRestTest/Common/DefineTest.pm | 4 +- test/src/common/harnessTest.h | 5 +-- test/src/common/logTest.c | 1 - .../module/common/{typeTest.c => typecTest.c} | 2 +- 35 files changed, 88 insertions(+), 102 deletions(-) rename src/common/{type.h => typec.h} (71%) rename test/src/module/common/{typeTest.c => typecTest.c} (98%) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 18b01d5ef..83de6600c 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -59,6 +59,10 @@

Add ASSERT() that is preserved in production builds.

+ +

Cleanup C types. Remove defined types included with the C types. Remove redefinition of standard C types.

+
+

Fix header exclusion defines that do not match the general pattern.

diff --git a/src/cipher/cipher.h b/src/cipher/cipher.h index b90a0ad84..756876336 100644 --- a/src/cipher/cipher.h +++ b/src/cipher/cipher.h @@ -4,7 +4,7 @@ Cipher Header #ifndef CIPHER_CIPHER_H #define CIPHER_CIPHER_H -#include "common/type.h" +#include "common/typec.h" // Define cipher modes typedef enum diff --git a/src/command/archive/push/push.c b/src/command/archive/push/push.c index 3c8542811..d5f8e41b4 100644 --- a/src/command/archive/push/push.c +++ b/src/command/archive/push/push.c @@ -12,7 +12,7 @@ Archive Push Command #include "common/log.h" #include "common/memContext.h" #include "common/regExp.h" -#include "common/type.h" +#include "common/typec.h" #include "common/wait.h" #include "config/config.h" #include "perl/exec.h" diff --git a/src/command/help/help.c b/src/command/help/help.c index 18f647fc2..633ace6a2 100644 --- a/src/command/help/help.c +++ b/src/command/help/help.c @@ -6,7 +6,7 @@ Help Command #include "common/io/handle.h" #include "common/memContext.h" -#include "common/type.h" +#include "common/typec.h" #include "config/config.h" #include "config/define.h" #include "version.h" diff --git a/src/common/encode.h b/src/common/encode.h index a435740fb..b43421e8d 100644 --- a/src/common/encode.h +++ b/src/common/encode.h @@ -6,7 +6,7 @@ These high-level functions are preferred to the low-level functions for each enc #ifndef COMMON_ENCODE_H #define COMMON_ENCODE_H -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Encoding types diff --git a/src/common/encode/base64.h b/src/common/encode/base64.h index 3aad7fe20..8a7703332 100644 --- a/src/common/encode/base64.h +++ b/src/common/encode/base64.h @@ -6,7 +6,7 @@ The high-level functions in encode.c should be used in preference to these low-l #ifndef COMMON_ENCODE_BASE64_H #define COMMON_ENCODE_BASE64_H -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Functions diff --git a/src/common/error.h b/src/common/error.h index e91d40bd9..720c1533a 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -40,7 +40,7 @@ IMPORTANT: Never call return from within any of the error-handling blocks. #include #include -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Error type object diff --git a/src/common/ini.h b/src/common/ini.h index 1640bfa2e..4c22bbbae 100644 --- a/src/common/ini.h +++ b/src/common/ini.h @@ -9,6 +9,8 @@ Ini object ***********************************************************************************************************************************/ typedef struct Ini Ini; +#include "common/type/variant.h" + /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ diff --git a/src/common/io/handle.h b/src/common/io/handle.h index 9bd140a5b..c01b9d467 100644 --- a/src/common/io/handle.h +++ b/src/common/io/handle.h @@ -4,7 +4,7 @@ Handle IO #ifndef COMMON_IO_HANDLE_H #define COMMON_IO_HANDLE_H -#include "common/type.h" +#include "common/type/string.h" /*********************************************************************************************************************************** Functions diff --git a/src/common/log.h b/src/common/log.h index c5b6e8824..f30b70e75 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -4,7 +4,7 @@ Log Handler #ifndef COMMON_LOG_H #define COMMON_LOG_H -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Log types diff --git a/src/common/memContext.h b/src/common/memContext.h index ccd62260f..1ba404afd 100644 --- a/src/common/memContext.h +++ b/src/common/memContext.h @@ -5,7 +5,7 @@ Memory Context Manager #define COMMON_MEMCONTEXT_H #include "common/error.h" -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Memory context names cannot be larger than this size (excluding terminator) or an error will be thrown diff --git a/src/common/regExp.c b/src/common/regExp.c index 9018c4fec..a526f78ed 100644 --- a/src/common/regExp.c +++ b/src/common/regExp.c @@ -6,7 +6,7 @@ Regular Expression Handler #include "common/memContext.h" #include "common/regExp.h" -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Contains information about the regular expression handler diff --git a/src/common/regExp.h b/src/common/regExp.h index 79d7e8531..e75deba43 100644 --- a/src/common/regExp.h +++ b/src/common/regExp.h @@ -9,6 +9,8 @@ Ini object ***********************************************************************************************************************************/ typedef struct RegExp RegExp; +#include "common/type/string.h" + /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ diff --git a/src/common/time.c b/src/common/time.c index 2e8fd3784..21299930a 100644 --- a/src/common/time.c +++ b/src/common/time.c @@ -4,7 +4,7 @@ Time Management #include "sys/time.h" #include "common/time.h" -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Constants describing number of sub-units in an interval diff --git a/src/common/time.h b/src/common/time.h index bd3f94d66..4c698b66b 100644 --- a/src/common/time.h +++ b/src/common/time.h @@ -4,12 +4,12 @@ Time Management #ifndef COMMON_TIME_H #define COMMON_TIME_H -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Time types ***********************************************************************************************************************************/ -typedef uint64 TimeMSec; +typedef uint64_t TimeMSec; /*********************************************************************************************************************************** Constants describing number of sub-units in an interval diff --git a/src/common/type/buffer.h b/src/common/type/buffer.h index 136a04e3e..b40d42713 100644 --- a/src/common/type/buffer.h +++ b/src/common/type/buffer.h @@ -4,7 +4,7 @@ Buffer Handler #ifndef COMMON_TYPE_BUFFER_H #define COMMON_TYPE_BUFFER_H -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Buffer object diff --git a/src/common/type/keyValue.c b/src/common/type/keyValue.c index ee3cdd650..04fdb7315 100644 --- a/src/common/type/keyValue.c +++ b/src/common/type/keyValue.c @@ -2,8 +2,8 @@ Key Value Handler ***********************************************************************************************************************************/ #include "common/memContext.h" -#include "common/type.h" #include "common/type/keyValue.h" +#include "common/type/list.h" #include "common/type/variantList.h" /*********************************************************************************************************************************** diff --git a/src/common/type/keyValue.h b/src/common/type/keyValue.h index 1c3b2c508..2e9bfa3a4 100644 --- a/src/common/type/keyValue.h +++ b/src/common/type/keyValue.h @@ -4,13 +4,13 @@ Key Value Handler #ifndef COMMON_TYPE_KEYVALUE_H #define COMMON_TYPE_KEYVALUE_H -#include "common/type/variant.h" - /*********************************************************************************************************************************** Key value object ***********************************************************************************************************************************/ typedef struct KeyValue KeyValue; +#include "common/type/variantList.h" + /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ diff --git a/src/common/type/variant.c b/src/common/type/variant.c index f5d2ec04a..a92502353 100644 --- a/src/common/type/variant.c +++ b/src/common/type/variant.c @@ -395,7 +395,7 @@ varIntForce(const Variant *this) case varTypeInt64: { - int64 resultTest = varInt64(this); + int64_t resultTest = varInt64(this); if (resultTest > 2147483647 || resultTest < -2147483648) THROW( @@ -427,7 +427,7 @@ varIntForce(const Variant *this) New int64 variant ***********************************************************************************************************************************/ Variant * -varNewInt64(int64 data) +varNewInt64(int64_t data) { return varNewInternal(varTypeInt64, (void *)&data, sizeof(data)); } @@ -435,7 +435,7 @@ varNewInt64(int64 data) /*********************************************************************************************************************************** Return int64 ***********************************************************************************************************************************/ -int64 +int64_t varInt64(const Variant *this) { // Only valid for int @@ -443,16 +443,16 @@ varInt64(const Variant *this) THROW(AssertError, "variant type is not %s", variantTypeName[varTypeInt64]); // Get the int - return *((int64 *)varData(this)); + return *((int64_t *)varData(this)); } /*********************************************************************************************************************************** Return int64 regardless of variant type ***********************************************************************************************************************************/ -int64 +int64_t varInt64Force(const Variant *this) { - int64 result = 0; + int64_t result = 0; switch (this->type) { @@ -464,7 +464,7 @@ varInt64Force(const Variant *this) case varTypeInt: { - result = (int64)varInt(this); + result = (int64_t)varInt(this); break; } diff --git a/src/common/type/variant.h b/src/common/type/variant.h index 2b34f1626..97b57ea40 100644 --- a/src/common/type/variant.h +++ b/src/common/type/variant.h @@ -4,7 +4,7 @@ Variant Data Type #ifndef COMMON_TYPE_VARIANT_H #define COMMON_TYPE_VARIANT_H -#include +#include "common/typec.h" /*********************************************************************************************************************************** Variant type @@ -44,9 +44,9 @@ Variant *varNewInt(int data); int varInt(const Variant *this); int varIntForce(const Variant *this); -Variant *varNewInt64(int64 data); -int64 varInt64(const Variant *this); -int64 varInt64Force(const Variant *this); +Variant *varNewInt64(int64_t data); +int64_t varInt64(const Variant *this); +int64_t varInt64Force(const Variant *this); Variant *varNewKv(); KeyValue *varKv(const Variant *this); diff --git a/src/common/type/variantList.h b/src/common/type/variantList.h index a6eda2190..a8934ff1a 100644 --- a/src/common/type/variantList.h +++ b/src/common/type/variantList.h @@ -9,11 +9,12 @@ Variant list type ***********************************************************************************************************************************/ typedef struct VariantList VariantList; +#include "common/type/stringList.h" +#include "common/type/variant.h" + /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ -#include "common/type/variant.h" - VariantList *varLstNew(); VariantList *varLstNewStrLst(const StringList *stringList); VariantList *varLstDup(const VariantList *source); diff --git a/src/common/type.h b/src/common/typec.h similarity index 71% rename from src/common/type.h rename to src/common/typec.h index df99d937b..6ae9f4fbd 100644 --- a/src/common/type.h +++ b/src/common/typec.h @@ -1,8 +1,8 @@ /*********************************************************************************************************************************** -Common Types +C Types ***********************************************************************************************************************************/ -#ifndef TYPE_H -#define TYPE_H +#ifndef COMMON_TYPEC_H +#define COMMON_TYPEC_H /*********************************************************************************************************************************** Include true/false @@ -24,16 +24,6 @@ Define standard integer types for portability ***********************************************************************************************************************************/ #include -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef uint64_t uint64; - -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; - /*********************************************************************************************************************************** Ensure that ints are at least 32 bits ***********************************************************************************************************************************/ @@ -41,14 +31,4 @@ Ensure that ints are at least 32 bits #error "int type must be at least 32 bits" #endif -/*********************************************************************************************************************************** -Include all header files in type directory for convenience -***********************************************************************************************************************************/ -#include "common/type/buffer.h" -#include "common/type/list.h" -#include "common/type/string.h" -#include "common/type/stringList.h" -#include "common/type/variant.h" -#include "common/type/variantList.h" - #endif diff --git a/src/config/config.c b/src/config/config.c index 361c56b76..86f012d5f 100644 --- a/src/config/config.c +++ b/src/config/config.c @@ -547,7 +547,7 @@ cfgOptionInt(ConfigOption optionId) return varIntForce(configOptionValue[optionId].value); } -int64 +int64_t cfgOptionInt64(ConfigOption optionId) { cfgOptionCheck(optionId); diff --git a/src/config/config.h b/src/config/config.h index 80880bff2..d94574f0d 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -8,7 +8,7 @@ config/parse.c sets the command and options and determines which options are val #define CONFIG_CONFIG_H #include "common/log.h" -#include "common/type.h" +#include "common/type/stringList.h" #include "config/define.h" #include "config/config.auto.h" @@ -45,7 +45,7 @@ const Variant *cfgOption(ConfigOption optionId); bool cfgOptionBool(ConfigOption optionId); double cfgOptionDbl(ConfigOption optionId); int cfgOptionInt(ConfigOption optionId); -int64 cfgOptionInt64(ConfigOption optionId); +int64_t cfgOptionInt64(ConfigOption optionId); const KeyValue *cfgOptionKv(ConfigOption optionId); const VariantList *cfgOptionLst(ConfigOption optionId); const String *cfgOptionStr(ConfigOption optionId); diff --git a/src/config/define.c b/src/config/define.c index 34daa2d97..c310be64e 100644 --- a/src/config/define.c +++ b/src/config/define.c @@ -106,10 +106,10 @@ typedef enum } ConfigDefineDataType; #define CFGDATA_OPTION_OPTIONAL_PUSH_LIST(type, size, data, ...) \ - (const void *)((uint32)type << 24 | (uint32)size << 16 | (uint32)data), __VA_ARGS__ + (const void *)((uint32_t)type << 24 | (uint32_t)size << 16 | (uint32_t)data), __VA_ARGS__ #define CFGDATA_OPTION_OPTIONAL_PUSH(type, size, data) \ - (const void *)((uint32)type << 24 | (uint32)size << 16 | (uint32)data) + (const void *)((uint32_t)type << 24 | (uint32_t)size << 16 | (uint32_t)data) #define CFGDEFDATA_OPTION_COMMAND_LIST(...) \ .commandValid = 0 __VA_ARGS__, @@ -130,10 +130,10 @@ typedef enum #define CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(rangeMinParam, rangeMaxParam) \ CFGDATA_OPTION_OPTIONAL_PUSH_LIST( \ configDefDataTypeAllowRange, 4, 0, \ - (const void *)(intptr_t)(int32)(((int64)((double)rangeMinParam * 100)) % 1000000000L), \ - (const void *)(intptr_t)(int32)(((int64)((double)rangeMinParam * 100)) / 1000000000L), \ - (const void *)(intptr_t)(int32)(((int64)((double)rangeMaxParam * 100)) % 1000000000L), \ - (const void *)(intptr_t)(int32)(((int64)((double)rangeMaxParam * 100)) / 1000000000L)), + (const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMinParam * 100)) % 1000000000L), \ + (const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMinParam * 100)) / 1000000000L), \ + (const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMaxParam * 100)) % 1000000000L), \ + (const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMaxParam * 100)) / 1000000000L)), #define CFGDEFDATA_OPTION_OPTIONAL_PREFIX(prefixParam) \ CFGDATA_OPTION_OPTIONAL_PUSH_LIST(configDefDataTypePrefix, 1, 0, prefixParam), @@ -365,7 +365,7 @@ cfgDefOptionAllowRangeMax(ConfigDefineCommand commandDefId, ConfigDefineOption o CONFIG_DEFINE_DATA_FIND(commandDefId, optionDefId, configDefDataTypeAllowRange); - return ((double)(((int64)(intptr_t)dataDefList[2]) + (((int64)(intptr_t)dataDefList[3]) * 1000000000L))) / 100; + return ((double)(((int64_t)(intptr_t)dataDefList[2]) + (((int64_t)(intptr_t)dataDefList[3]) * 1000000000L))) / 100; } double @@ -375,7 +375,7 @@ cfgDefOptionAllowRangeMin(ConfigDefineCommand commandDefId, ConfigDefineOption o CONFIG_DEFINE_DATA_FIND(commandDefId, optionDefId, configDefDataTypeAllowRange); - return ((double)(((int64)(intptr_t)dataDefList[0]) + (((int64)(intptr_t)dataDefList[1]) * 1000000000L))) / 100; + return ((double)(((int64_t)(intptr_t)dataDefList[0]) + (((int64_t)(intptr_t)dataDefList[1]) * 1000000000L))) / 100; } /*********************************************************************************************************************************** diff --git a/src/config/define.h b/src/config/define.h index 1ae1c333d..e71e304f6 100644 --- a/src/config/define.h +++ b/src/config/define.h @@ -4,7 +4,7 @@ Command and Option Configuration Definition #ifndef CONFIG_DEFINE_H #define CONFIG_DEFINE_H -#include "common/type.h" +#include "common/typec.h" #include "config/define.auto.h" /*********************************************************************************************************************************** diff --git a/src/perl/config.h b/src/perl/config.h index 71d1d7080..2e7c4b17b 100644 --- a/src/perl/config.h +++ b/src/perl/config.h @@ -4,8 +4,6 @@ Perl Configuration #ifndef PERL_CONFIG_H #define PERL_CONFIG_H -#include "common/type.h" - /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ diff --git a/src/perl/exec.c b/src/perl/exec.c index c444a0b23..34aa0368c 100644 --- a/src/perl/exec.c +++ b/src/perl/exec.c @@ -10,7 +10,7 @@ Execute Perl for Legacy Functionality #include "version.h" #include "common/error.h" #include "common/memContext.h" -#include "common/type.h" +#include "common/typec.h" #include "config/config.h" #include "perl/config.h" diff --git a/src/postgres/pageChecksum.c b/src/postgres/pageChecksum.c index 1a6c046f4..1e3522068 100644 --- a/src/postgres/pageChecksum.c +++ b/src/postgres/pageChecksum.c @@ -72,8 +72,8 @@ For historical reasons, the 64-bit LSN value is stored as two 32-bit values. ***********************************************************************************************************************************/ typedef struct { - uint32 walid; // high bits - uint32 xrecoff; // low bits + uint32_t walid; // high bits + uint32_t xrecoff; // low bits } PageWalRecPtr; /*********************************************************************************************************************************** @@ -95,11 +95,11 @@ relating to checksums. typedef struct PageHeaderData { // LSN is member of *any* block, not only page-organized ones - PageWalRecPtr pd_lsn; /* LSN: next byte after last byte of wal * record for last change to this page */ - uint16 pd_checksum; /* checksum */ - uint16 pd_flags; /* flag bits, see below */ - uint16 pd_lower; /* offset to start of free space */ - uint16 pd_upper; /* offset to end of free space */ + PageWalRecPtr pd_lsn; // Lsn for last change to this page + uint16_t pd_checksum; // checksum + uint16_t pd_flags; // flag bits, see below + uint16_t pd_lower; // offset to start of free space + uint16_t pd_upper; // offset to end of free space } PageHeaderData; typedef PageHeaderData *PageHeader; @@ -116,7 +116,7 @@ The data argument must be aligned on a 4-byte boundary. #define FNV_PRIME 16777619 // Base offsets to initialize each of the parallel FNV hashes into a different initial state. -static const uint32 checksumBaseOffsets[N_SUMS] = +static const uint32_t checksumBaseOffsets[N_SUMS] = { 0x5B1F36E9, 0xB8525960, 0x02AB50AA, 0x1DE66D2A, 0x79FF467A, 0x9BB9F8A3, 0x217E7CD2, 0x83E13D2C, 0xF8D4474F, 0xE39EB970, 0x42C6AE16, 0x993216FA, 0x7B093B5D, 0x98DAFF3C, 0xF718902A, 0x0B1C9CDB, @@ -127,23 +127,23 @@ static const uint32 checksumBaseOffsets[N_SUMS] = // Calculate one round of the checksum. #define CHECKSUM_COMP(checksum, value) \ do { \ - uint32 temp = (checksum) ^ (value); \ + uint32_t temp = (checksum) ^ (value); \ (checksum) = temp * FNV_PRIME ^ (temp >> 17); \ } while (0) -static uint32 -pageChecksumBlock(const unsigned char *data, uint32 size) +static uint32_t +pageChecksumBlock(const unsigned char *data, uint32_t size) { - uint32 sums[N_SUMS]; - uint32 (*dataArray)[N_SUMS] = (uint32 (*)[N_SUMS])data; - uint32 result = 0; - uint32 i, j; + uint32_t sums[N_SUMS]; + uint32_t (*dataArray)[N_SUMS] = (uint32_t (*)[N_SUMS])data; + uint32_t result = 0; + uint32_t i, j; /* initialize partial checksums to their corresponding offsets */ memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets)); /* main checksum calculation */ - for (i = 0; i < size / sizeof(uint32) / N_SUMS; i++) + for (i = 0; i < size / sizeof(uint32_t) / N_SUMS; i++) for (j = 0; j < N_SUMS; j++) CHECKSUM_COMP(sums[j], dataArray[i][j]); @@ -165,30 +165,31 @@ pageChecksum - compute the checksum for a PostgreSQL page The checksum includes the block number (to detect the case where a page is somehow moved to a different location), the page header (excluding the checksum itself), and the page data. ***********************************************************************************************************************************/ -uint16 +uint16_t pageChecksum(const unsigned char *page, unsigned int blockNo, unsigned int pageSize) { // Save pd_checksum and temporarily set it to zero, so that the checksum calculation isn't affected by the old checksum stored // on the page. Restore it after, because actually updating the checksum is NOT part of the API of this function. PageHeader pageHeader = (PageHeader)page; - uint16 originalChecksum = pageHeader->pd_checksum; + uint16_t originalChecksum = pageHeader->pd_checksum; pageHeader->pd_checksum = 0; - uint32 checksum = pageChecksumBlock(page, pageSize); + uint32_t checksum = pageChecksumBlock(page, pageSize); pageHeader->pd_checksum = originalChecksum; // Mix in the block number to detect transposed pages checksum ^= blockNo; // Reduce to a uint16 with an offset of one. That avoids checksums of zero, which seems like a good idea. - return (uint16)((checksum % 65535) + 1); + return (uint16_t)((checksum % 65535) + 1); } /*********************************************************************************************************************************** pageChecksumTest - test if checksum is valid for a single page ***********************************************************************************************************************************/ bool -pageChecksumTest(const unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32 ignoreWalId, uint32 ignoreWalOffset) +pageChecksumTest( + const unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32_t ignoreWalId, uint32_t ignoreWalOffset) { return // This is a new page so don't test checksum @@ -205,7 +206,7 @@ pageChecksumBufferTest - test if checksums are valid for all pages in a buffer bool pageChecksumBufferTest( const unsigned char *pageBuffer, unsigned int pageBufferSize, unsigned int blockNoBegin, unsigned int pageSize, - uint32 ignoreWalId, uint32 ignoreWalOffset) + uint32_t ignoreWalId, uint32_t ignoreWalOffset) { // If the buffer does not represent an even number of pages then error if (pageBufferSize % pageSize != 0 || pageBufferSize / pageSize == 0) diff --git a/src/postgres/pageChecksum.h b/src/postgres/pageChecksum.h index ff681731e..87efb5370 100644 --- a/src/postgres/pageChecksum.h +++ b/src/postgres/pageChecksum.h @@ -4,16 +4,16 @@ Checksum Implementation for Data Pages #ifndef POSTGRES_PAGECHECKSUM_H #define POSTGRES_PAGECHECKSUM_H -#include "common/type.h" +#include "common/typec.h" /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ -uint16 pageChecksum(const unsigned char *page, unsigned int blockNo, unsigned int pageSize); +uint16_t pageChecksum(const unsigned char *page, unsigned int blockNo, unsigned int pageSize); bool pageChecksumTest( - const unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32 ignoreWalId, uint32 ignoreWalOffset); + const unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32_t ignoreWalId, uint32_t ignoreWalOffset); bool pageChecksumBufferTest( const unsigned char *pageBuffer, unsigned int pageBufferSize, unsigned int blockNoBegin, unsigned int pageSize, - uint32 ignoreWalId, uint32 ignoreWalOffset); + uint32_t ignoreWalId, uint32_t ignoreWalOffset); #endif diff --git a/src/storage/storage.h b/src/storage/storage.h index f67148f21..acd01cfa6 100644 --- a/src/storage/storage.h +++ b/src/storage/storage.h @@ -7,7 +7,7 @@ Storage Manager #include #include "common/type/buffer.h" -#include "common/type/string.h" +#include "common/type/stringList.h" /*********************************************************************************************************************************** Default buffer size diff --git a/test/lib/pgBackRestTest/Common/DefineTest.pm b/test/lib/pgBackRestTest/Common/DefineTest.pm index 134087e71..b2e699884 100644 --- a/test/lib/pgBackRestTest/Common/DefineTest.pm +++ b/test/lib/pgBackRestTest/Common/DefineTest.pm @@ -101,14 +101,14 @@ my $oTestDef = &TESTDEF_TEST => [ { - &TESTDEF_NAME => 'type', + &TESTDEF_NAME => 'typec', &TESTDEF_TOTAL => 2, &TESTDEF_C => true, &TESTDEF_CDEF => '-DNO_ERROR -DNO_LOG', &TESTDEF_COVERAGE => { - 'common/type' => TESTDEF_COVERAGE_NOCODE, + 'common/typec' => TESTDEF_COVERAGE_NOCODE, }, }, { diff --git a/test/src/common/harnessTest.h b/test/src/common/harnessTest.h index 996b6f8c3..38c751b2b 100644 --- a/test/src/common/harnessTest.h +++ b/test/src/common/harnessTest.h @@ -7,7 +7,6 @@ C Test Harness #include #include "common/error.h" -#include "common/type.h" // Bogus values #define BOGUS_STR "BOGUS" @@ -218,7 +217,7 @@ Macros to ease the use of common data types TEST_RESULT_DOUBLE_PARAM(statement, resultExpected, ==, __VA_ARGS__); #define TEST_RESULT_INT_PARAM(statement, resultExpected, typeOp, ...) \ - TEST_RESULT(statement, resultExpected, int64, "%" PRId64, TEST_TYPE_FORMAT, typeOp, TEST_TYPE_COMPARE, __VA_ARGS__); + TEST_RESULT(statement, resultExpected, int64_t, "%" PRId64, TEST_TYPE_FORMAT, typeOp, TEST_TYPE_COMPARE, __VA_ARGS__); #define TEST_RESULT_INT(statement, resultExpected, ...) \ TEST_RESULT_INT_PARAM(statement, resultExpected, ==, __VA_ARGS__); #define TEST_RESULT_INT_NE(statement, resultExpected, ...) \ @@ -239,6 +238,6 @@ Macros to ease the use of common data types TEST_RESULT_STR_PARAM(statement, resultExpected, !=, __VA_ARGS__); #define TEST_RESULT_U16_HEX(statement, resultExpected, ...) \ - TEST_RESULT(statement, resultExpected, uint16, "0x%04X", TEST_TYPE_FORMAT, ==, TEST_TYPE_COMPARE, __VA_ARGS__); + TEST_RESULT(statement, resultExpected, uint16_t, "0x%04X", TEST_TYPE_FORMAT, ==, TEST_TYPE_COMPARE, __VA_ARGS__); #endif diff --git a/test/src/common/logTest.c b/test/src/common/logTest.c index 4655fddfc..3581be321 100644 --- a/test/src/common/logTest.c +++ b/test/src/common/logTest.c @@ -7,7 +7,6 @@ Log Test Harness #include "common/harnessTest.h" #include "common/log.h" -#include "common/type.h" #include "storage/helper.h" #ifndef NO_LOG diff --git a/test/src/module/common/typeTest.c b/test/src/module/common/typecTest.c similarity index 98% rename from test/src/module/common/typeTest.c rename to test/src/module/common/typecTest.c index 61cc1528b..0e3e4b9c9 100644 --- a/test/src/module/common/typeTest.c +++ b/test/src/module/common/typecTest.c @@ -1,5 +1,5 @@ /*********************************************************************************************************************************** -Test Types +Test C Types ***********************************************************************************************************************************/ #include