1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Rename param structs to match function names.

The functions were named with short integer representations (e.g. I32) but the param structs were using longer ones, e.g. UInt32. Shorten the integer representations in the param structs to match.

Also rename pckReadUInt64Internal() to pckReadU64Internal() for the same reason.
This commit is contained in:
David Steele
2021-06-08 08:44:10 -04:00
parent df8276f59f
commit 4ccb42bb7a
3 changed files with 59 additions and 59 deletions

View File

@@ -329,7 +329,7 @@ pckReadBuffer(PackRead *this, size_t size)
Unpack an unsigned 64-bit integer from base-128 varint encoding
***********************************************************************************************************************************/
static uint64_t
pckReadUInt64Internal(PackRead *this)
pckReadU64Internal(PackRead *this)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_READ, this);
@@ -407,10 +407,10 @@ pckReadTagNext(PackRead *this)
// Read high order bits of the field ID delta when specified
if (tag & 0x4)
this->tagNextId |= (unsigned int)pckReadUInt64Internal(this) << 2;
this->tagNextId |= (unsigned int)pckReadU64Internal(this) << 2;
// Read value
this->tagNextValue = pckReadUInt64Internal(this);
this->tagNextValue = pckReadU64Internal(this);
}
// Else the value is stored in the tag (value == 1 bit)
else
@@ -420,7 +420,7 @@ pckReadTagNext(PackRead *this)
// Read high order bits of the field ID delta when specified
if (tag & 0x2)
this->tagNextId |= (unsigned int)pckReadUInt64Internal(this) << 1;
this->tagNextId |= (unsigned int)pckReadU64Internal(this) << 1;
// Read value
this->tagNextValue = (tag >> 2) & 0x3;
@@ -434,7 +434,7 @@ pckReadTagNext(PackRead *this)
// Read high order bits of the field ID delta when specified
if (tag & 0x4)
this->tagNextId |= (unsigned int)pckReadUInt64Internal(this) << 2;
this->tagNextId |= (unsigned int)pckReadU64Internal(this) << 2;
// Read value
this->tagNextValue = (tag >> 3) & 0x1;
@@ -447,7 +447,7 @@ pckReadTagNext(PackRead *this)
// Read high order bits of the field ID delta when specified
if (tag & 0x8)
this->tagNextId |= (unsigned int)pckReadUInt64Internal(this) << 3;
this->tagNextId |= (unsigned int)pckReadU64Internal(this) << 3;
// Value length is variable so is stored after the tag
this->tagNextValue = 0;
@@ -526,7 +526,7 @@ pckReadTag(PackRead *this, unsigned int *id, PackType type, bool peek)
// Read data for the field being skipped if this is not the field requested
if (packTypeData[this->tagNextType].size && this->tagNextValue != 0)
{
size_t sizeExpected = (size_t)pckReadUInt64Internal(this);
size_t sizeExpected = (size_t)pckReadU64Internal(this);
while (sizeExpected != 0)
{
@@ -693,7 +693,7 @@ pckReadBin(PackRead *this, PckReadBinParam param)
if (pckReadTag(this, &param.id, pckTypeBin, false))
{
// Get the buffer size
result = bufNew((size_t)pckReadUInt64Internal(this));
result = bufNew((size_t)pckReadU64Internal(this));
// Read the buffer out in chunks
while (bufUsed(result) < bufSize(result))
@@ -730,7 +730,7 @@ pckReadBool(PackRead *this, PckReadBoolParam param)
/**********************************************************************************************************************************/
int32_t
pckReadI32(PackRead *this, PckReadInt32Param param)
pckReadI32(PackRead *this, PckReadI32Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_READ, this);
@@ -748,7 +748,7 @@ pckReadI32(PackRead *this, PckReadInt32Param param)
/**********************************************************************************************************************************/
int64_t
pckReadI64(PackRead *this, PckReadInt64Param param)
pckReadI64(PackRead *this, PckReadI64Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_READ, this);
@@ -848,7 +848,7 @@ pckReadStr(PackRead *this, PckReadStrParam param)
if (pckReadTag(this, &param.id, pckTypeStr, false))
{
// Read the string size
size_t sizeExpected = (size_t)pckReadUInt64Internal(this);
size_t sizeExpected = (size_t)pckReadU64Internal(this);
// Read the string out in chunks
result = strNew();
@@ -887,7 +887,7 @@ pckReadTime(PackRead *this, PckReadTimeParam param)
/**********************************************************************************************************************************/
uint32_t
pckReadU32(PackRead *this, PckReadUInt32Param param)
pckReadU32(PackRead *this, PckReadU32Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_READ, this);
@@ -905,7 +905,7 @@ pckReadU32(PackRead *this, PckReadUInt32Param param)
/**********************************************************************************************************************************/
uint64_t
pckReadU64(PackRead *this, PckReadUInt64Param param)
pckReadU64(PackRead *this, PckReadU64Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_READ, this);
@@ -1074,7 +1074,7 @@ pckWriteBuffer(PackWrite *this, const Buffer *buffer)
Pack an unsigned 64-bit integer to base-128 varint encoding
***********************************************************************************************************************************/
static void
pckWriteUInt64Internal(PackWrite *this, uint64_t value)
pckWriteU64Internal(PackWrite *this, uint64_t value)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_WRITE, this);
@@ -1209,11 +1209,11 @@ pckWriteTag(PackWrite *this, PackType type, unsigned int id, uint64_t value)
// Write low order bits of the field ID delta
if (tagId > 0)
pckWriteUInt64Internal(this, tagId);
pckWriteU64Internal(this, tagId);
// Write low order bits of the value
if (value > 0)
pckWriteUInt64Internal(this, value);
pckWriteU64Internal(this, value);
// Set last field id
this->tagStackTop->idLast = id;
@@ -1291,7 +1291,7 @@ pckWriteArrayEnd(PackWrite *this)
ASSERT(((PackTagStack *)lstGetLast(this->tagStack))->type == pckTypeArray);
// Write end of array tag
pckWriteUInt64Internal(this, 0);
pckWriteU64Internal(this, 0);
// Pop array off the stack to revert to ID tracking for the prior container
lstRemoveLast(this->tagStack);
@@ -1322,7 +1322,7 @@ pckWriteBin(PackWrite *this, const Buffer *value, PckWriteBinParam param)
// Write buffer data if size > 0
if (!bufEmpty(value))
{
pckWriteUInt64Internal(this, bufUsed(value));
pckWriteU64Internal(this, bufUsed(value));
pckWriteBuffer(this, value);
}
}
@@ -1352,7 +1352,7 @@ pckWriteBool(PackWrite *this, bool value, PckWriteBoolParam param)
/**********************************************************************************************************************************/
PackWrite *
pckWriteI32(PackWrite *this, int32_t value, PckWriteInt32Param param)
pckWriteI32(PackWrite *this, int32_t value, PckWriteI32Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_WRITE, this);
@@ -1372,7 +1372,7 @@ pckWriteI32(PackWrite *this, int32_t value, PckWriteInt32Param param)
/**********************************************************************************************************************************/
PackWrite *
pckWriteI64(PackWrite *this, int64_t value, PckWriteInt64Param param)
pckWriteI64(PackWrite *this, int64_t value, PckWriteI64Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_WRITE, this);
@@ -1422,7 +1422,7 @@ pckWriteObjEnd(PackWrite *this)
ASSERT(((PackTagStack *)lstGetLast(this->tagStack))->type == pckTypeObj);
// Write end of object tag
pckWriteUInt64Internal(this, 0);
pckWriteU64Internal(this, 0);
// Pop object off the stack to revert to ID tracking for the prior container
lstRemoveLast(this->tagStack);
@@ -1472,7 +1472,7 @@ pckWriteStr(PackWrite *this, const String *value, PckWriteStrParam param)
// Write string data if size > 0
if (strSize(value) > 0)
{
pckWriteUInt64Internal(this, strSize(value));
pckWriteU64Internal(this, strSize(value));
pckWriteBuffer(this, BUF(strZ(value), strSize(value)));
}
}
@@ -1502,7 +1502,7 @@ pckWriteTime(PackWrite *this, time_t value, PckWriteTimeParam param)
/**********************************************************************************************************************************/
PackWrite *
pckWriteU32(PackWrite *this, uint32_t value, PckWriteUInt32Param param)
pckWriteU32(PackWrite *this, uint32_t value, PckWriteU32Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_WRITE, this);
@@ -1522,7 +1522,7 @@ pckWriteU32(PackWrite *this, uint32_t value, PckWriteUInt32Param param)
/**********************************************************************************************************************************/
PackWrite *
pckWriteU64(PackWrite *this, uint64_t value, PckWriteUInt64Param param)
pckWriteU64(PackWrite *this, uint64_t value, PckWriteU64Param param)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(PACK_WRITE, this);
@@ -1551,7 +1551,7 @@ pckWriteEnd(PackWrite *this)
ASSERT(this != NULL);
ASSERT(lstSize(this->tagStack) == 1);
pckWriteUInt64Internal(this, 0);
pckWriteU64Internal(this, 0);
this->tagStackTop = NULL;
// If writing to io flush the internal buffer

View File

@@ -188,30 +188,30 @@ typedef struct PckReadBoolParam
bool pckReadBool(PackRead *this, PckReadBoolParam param);
// Read 32-bit signed integer
typedef struct PckReadInt32Param
typedef struct PckReadI32Param
{
VAR_PARAM_HEADER;
unsigned int id;
int32_t defaultValue;
} PckReadInt32Param;
} PckReadI32Param;
#define pckReadI32P(this, ...) \
pckReadI32(this, (PckReadInt32Param){VAR_PARAM_INIT, __VA_ARGS__})
pckReadI32(this, (PckReadI32Param){VAR_PARAM_INIT, __VA_ARGS__})
int32_t pckReadI32(PackRead *this, PckReadInt32Param param);
int32_t pckReadI32(PackRead *this, PckReadI32Param param);
// Read 64-bit signed integer
typedef struct PckReadInt64Param
typedef struct PckReadI64Param
{
VAR_PARAM_HEADER;
unsigned int id;
int64_t defaultValue;
} PckReadInt64Param;
} PckReadI64Param;
#define pckReadI64P(this, ...) \
pckReadI64(this, (PckReadInt64Param){VAR_PARAM_INIT, __VA_ARGS__})
pckReadI64(this, (PckReadI64Param){VAR_PARAM_INIT, __VA_ARGS__})
int64_t pckReadI64(PackRead *this, PckReadInt64Param param);
int64_t pckReadI64(PackRead *this, PckReadI64Param param);
// Read object begin/end
#define pckReadObjBeginP(this, ...) \
@@ -263,30 +263,30 @@ typedef struct PckReadTimeParam
time_t pckReadTime(PackRead *this, PckReadTimeParam param);
// Read 32-bit unsigned integer
typedef struct PckReadUInt32Param
typedef struct PckReadU32Param
{
VAR_PARAM_HEADER;
unsigned int id;
uint32_t defaultValue;
} PckReadUInt32Param;
} PckReadU32Param;
#define pckReadU32P(this, ...) \
pckReadU32(this, (PckReadUInt32Param){VAR_PARAM_INIT, __VA_ARGS__})
pckReadU32(this, (PckReadU32Param){VAR_PARAM_INIT, __VA_ARGS__})
uint32_t pckReadU32(PackRead *this, PckReadUInt32Param param);
uint32_t pckReadU32(PackRead *this, PckReadU32Param param);
// Read 64-bit unsigned integer
typedef struct PckReadUInt64Param
typedef struct PckReadU64Param
{
VAR_PARAM_HEADER;
unsigned int id;
uint64_t defaultValue;
} PckReadUInt64Param;
} PckReadU64Param;
#define pckReadU64P(this, ...) \
pckReadU64(this, (PckReadUInt64Param){VAR_PARAM_INIT, __VA_ARGS__})
pckReadU64(this, (PckReadU64Param){VAR_PARAM_INIT, __VA_ARGS__})
uint64_t pckReadU64(PackRead *this, PckReadUInt64Param param);
uint64_t pckReadU64(PackRead *this, PckReadU64Param param);
// Read end
#define pckReadEndP(this) \
@@ -350,32 +350,32 @@ typedef struct PckWriteBoolParam
PackWrite *pckWriteBool(PackWrite *this, bool value, PckWriteBoolParam param);
// Write 32-bit signed integer
typedef struct PckWriteInt32Param
typedef struct PckWriteI32Param
{
VAR_PARAM_HEADER;
bool defaultWrite;
unsigned int id;
int32_t defaultValue;
} PckWriteInt32Param;
} PckWriteI32Param;
#define pckWriteI32P(this, value, ...) \
pckWriteI32(this, value, (PckWriteInt32Param){VAR_PARAM_INIT, __VA_ARGS__})
pckWriteI32(this, value, (PckWriteI32Param){VAR_PARAM_INIT, __VA_ARGS__})
PackWrite *pckWriteI32(PackWrite *this, int32_t value, PckWriteInt32Param param);
PackWrite *pckWriteI32(PackWrite *this, int32_t value, PckWriteI32Param param);
// Write 64-bit signed integer
typedef struct PckWriteInt64Param
typedef struct PckWriteI64Param
{
VAR_PARAM_HEADER;
bool defaultWrite;
unsigned int id;
int64_t defaultValue;
} PckWriteInt64Param;
} PckWriteI64Param;
#define pckWriteI64P(this, value, ...) \
pckWriteI64(this, value, (PckWriteInt64Param){VAR_PARAM_INIT, __VA_ARGS__})
pckWriteI64(this, value, (PckWriteI64Param){VAR_PARAM_INIT, __VA_ARGS__})
PackWrite *pckWriteI64(PackWrite *this, int64_t value, PckWriteInt64Param param);
PackWrite *pckWriteI64(PackWrite *this, int64_t value, PckWriteI64Param param);
// Write null
#define pckWriteNullP(this) \
@@ -436,32 +436,32 @@ typedef struct PckWriteTimeParam
PackWrite *pckWriteTime(PackWrite *this, time_t value, PckWriteTimeParam param);
// Write 32-bit unsigned integer
typedef struct PckWriteUInt32Param
typedef struct PckWriteU32Param
{
VAR_PARAM_HEADER;
bool defaultWrite;
unsigned int id;
uint32_t defaultValue;
} PckWriteUInt32Param;
} PckWriteU32Param;
#define pckWriteU32P(this, value, ...) \
pckWriteU32(this, value, (PckWriteUInt32Param){VAR_PARAM_INIT, __VA_ARGS__})
pckWriteU32(this, value, (PckWriteU32Param){VAR_PARAM_INIT, __VA_ARGS__})
PackWrite *pckWriteU32(PackWrite *this, uint32_t value, PckWriteUInt32Param param);
PackWrite *pckWriteU32(PackWrite *this, uint32_t value, PckWriteU32Param param);
// Write 64-bit unsigned integer
typedef struct PckWriteUInt64Param
typedef struct PckWriteU64Param
{
VAR_PARAM_HEADER;
bool defaultWrite;
unsigned int id;
uint64_t defaultValue;
} PckWriteUInt64Param;
} PckWriteU64Param;
#define pckWriteU64P(this, value, ...) \
pckWriteU64(this, value, (PckWriteUInt64Param){VAR_PARAM_INIT, __VA_ARGS__})
pckWriteU64(this, value, (PckWriteU64Param){VAR_PARAM_INIT, __VA_ARGS__})
PackWrite *pckWriteU64(PackWrite *this, uint64_t value, PckWriteUInt64Param param);
PackWrite *pckWriteU64(PackWrite *this, uint64_t value, PckWriteU64Param param);
// Write end
#define pckWriteEndP(this) \

View File

@@ -272,13 +272,13 @@ testRun(void)
TEST_TITLE("EOF on short buffer");
TEST_ASSIGN(packRead, pckReadNewBuf(BUFSTRDEF("\255")), "new read");
TEST_ERROR(pckReadUInt64Internal(packRead), FormatError, "unexpected EOF");
TEST_ERROR(pckReadU64Internal(packRead), FormatError, "unexpected EOF");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on invalid uint64");
TEST_ASSIGN(packRead, pckReadNewBuf(BUFSTRDEF("\255\255\255\255\255\255\255\255\255\255")), "new read");
TEST_ERROR(pckReadUInt64Internal(packRead), FormatError, "unterminated base-128 integer");
TEST_ERROR(pckReadU64Internal(packRead), FormatError, "unterminated base-128 integer");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("pack/unpack pointer");