mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-30 05:39:12 +02:00
Enable -Wconversion and silence new warnings.
This commit is contained in:
parent
6ca6424fb1
commit
406acf9cba
@ -34,7 +34,7 @@
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Enable <id>-Wswitch-enum</id> and silence new warnings.</p>
|
||||
<p>Enable <id>-Wswitch-enum</id> and <id>-Wconversion</id> and silence new warnings.</p>
|
||||
</release-item>
|
||||
</release-development-list>
|
||||
</release-core-list>
|
||||
|
@ -17,7 +17,7 @@ COPT = -O2
|
||||
CINCLUDE = -I.
|
||||
|
||||
# Compile warnings
|
||||
CWARN = -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wswitch-enum
|
||||
CWARN = -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wswitch-enum -Wconversion
|
||||
|
||||
# Automatically generate Perl compile options for the local system
|
||||
CPERL = `perl -MExtUtils::Embed -e ccopts`
|
||||
|
@ -30,9 +30,9 @@ struct CipherBlock
|
||||
CipherMode mode; // Mode encrypt/decrypt
|
||||
bool saltDone; // Has the salt been read/generated?
|
||||
bool processDone; // Has any data been processed?
|
||||
int passSize; // Size of passphrase in bytes
|
||||
size_t passSize; // Size of passphrase in bytes
|
||||
unsigned char *pass; // Passphrase used to generate encryption key
|
||||
int headerSize; // Size of header read during decrypt
|
||||
size_t headerSize; // Size of header read during decrypt
|
||||
unsigned char header[CIPHER_BLOCK_HEADER_SIZE]; // Buffer to hold partial header during decrypt
|
||||
const EVP_CIPHER *cipher; // Cipher object
|
||||
const EVP_MD *digest; // Message digest object
|
||||
@ -43,7 +43,7 @@ struct CipherBlock
|
||||
New block encrypt/decrypt object
|
||||
***********************************************************************************************************************************/
|
||||
CipherBlock *
|
||||
cipherBlockNew(CipherMode mode, const char *cipherName, const unsigned char *pass, int passSize, const char *digestName)
|
||||
cipherBlockNew(CipherMode mode, const char *cipherName, const unsigned char *pass, size_t passSize, const char *digestName)
|
||||
{
|
||||
// Only need to init once.
|
||||
if (!cipherIsInit())
|
||||
@ -96,11 +96,11 @@ cipherBlockNew(CipherMode mode, const char *cipherName, const unsigned char *pas
|
||||
/***********************************************************************************************************************************
|
||||
Determine how large the destination buffer should be
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
cipherBlockProcessSize(CipherBlock *this, int sourceSize)
|
||||
size_t
|
||||
cipherBlockProcessSize(CipherBlock *this, size_t sourceSize)
|
||||
{
|
||||
// Destination size is source size plus one extra block
|
||||
int destinationSize = sourceSize + EVP_MAX_BLOCK_LENGTH;
|
||||
size_t destinationSize = sourceSize + EVP_MAX_BLOCK_LENGTH;
|
||||
|
||||
// On encrypt the header size must be included before the first block
|
||||
if (this->mode == cipherModeEncrypt && !this->saltDone)
|
||||
@ -112,11 +112,11 @@ cipherBlockProcessSize(CipherBlock *this, int sourceSize)
|
||||
/***********************************************************************************************************************************
|
||||
Encrypt/decrypt data
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
cipherBlockProcess(CipherBlock *this, const unsigned char *source, int sourceSize, unsigned char *destination)
|
||||
size_t
|
||||
cipherBlockProcess(CipherBlock *this, const unsigned char *source, size_t sourceSize, unsigned char *destination)
|
||||
{
|
||||
// Actual destination size
|
||||
uint32 destinationSize = 0;
|
||||
size_t destinationSize = 0;
|
||||
|
||||
// If the salt has not been generated/read yet
|
||||
if (!this->saltDone)
|
||||
@ -175,7 +175,7 @@ cipherBlockProcess(CipherBlock *this, const unsigned char *source, int sourceSiz
|
||||
unsigned char initVector[EVP_MAX_IV_LENGTH];
|
||||
|
||||
EVP_BytesToKey(
|
||||
this->cipher, this->digest, salt, (unsigned char *)this->pass, this->passSize, 1, key, initVector);
|
||||
this->cipher, this->digest, salt, (unsigned char *)this->pass, (int)this->passSize, 1, key, initVector);
|
||||
|
||||
// Create context to track cipher
|
||||
if (!(this->cipherContext = EVP_CIPHER_CTX_new()))
|
||||
@ -199,9 +199,9 @@ cipherBlockProcess(CipherBlock *this, const unsigned char *source, int sourceSiz
|
||||
if (sourceSize > 0)
|
||||
{
|
||||
// Process the data
|
||||
int destinationUpdateSize = 0;
|
||||
size_t destinationUpdateSize = 0;
|
||||
|
||||
if (!EVP_CipherUpdate(this->cipherContext, destination, &destinationUpdateSize, source, sourceSize))
|
||||
if (!EVP_CipherUpdate(this->cipherContext, destination, (int *)&destinationUpdateSize, source, (int)sourceSize))
|
||||
THROW(CipherError, "unable to process"); // {uncoverable - no failure path known}
|
||||
|
||||
destinationSize += destinationUpdateSize;
|
||||
@ -217,22 +217,22 @@ cipherBlockProcess(CipherBlock *this, const unsigned char *source, int sourceSiz
|
||||
/***********************************************************************************************************************************
|
||||
Flush the remaining data
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
size_t
|
||||
cipherBlockFlush(CipherBlock *this, unsigned char *destination)
|
||||
{
|
||||
// Actual destination size
|
||||
int iDestinationSize = 0;
|
||||
size_t destinationSize = 0;
|
||||
|
||||
// If no header was processed then error
|
||||
if (!this->saltDone)
|
||||
THROW(CipherError, "cipher header missing");
|
||||
|
||||
// Only flush remaining data if some data was processed
|
||||
if (!EVP_CipherFinal(this->cipherContext, destination, &iDestinationSize))
|
||||
if (!EVP_CipherFinal(this->cipherContext, destination, (int *)&destinationSize))
|
||||
THROW(CipherError, "unable to flush");
|
||||
|
||||
// Return actual destination size
|
||||
return iDestinationSize;
|
||||
return destinationSize;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -11,10 +11,10 @@ typedef struct CipherBlock CipherBlock;
|
||||
|
||||
// Functions
|
||||
CipherBlock *cipherBlockNew(
|
||||
CipherMode mode, const char *cipherName, const unsigned char *pass, int passSize, const char *digestName);
|
||||
int cipherBlockProcessSize(CipherBlock *this, int sourceSize);
|
||||
int cipherBlockProcess(CipherBlock *this, const unsigned char *source, int sourceSize, unsigned char *destination);
|
||||
int cipherBlockFlush(CipherBlock *this, unsigned char *destination);
|
||||
CipherMode mode, const char *cipherName, const unsigned char *pass, size_t passSize, const char *digestName);
|
||||
size_t cipherBlockProcessSize(CipherBlock *this, size_t sourceSize);
|
||||
size_t cipherBlockProcess(CipherBlock *this, const unsigned char *source, size_t sourceSize, unsigned char *destination);
|
||||
size_t cipherBlockFlush(CipherBlock *this, unsigned char *destination);
|
||||
void cipherBlockFree(CipherBlock *this);
|
||||
|
||||
#endif
|
||||
|
@ -9,7 +9,7 @@ Cipher
|
||||
Generate random bytes
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
randomBytes(unsigned char *buffer, int size)
|
||||
randomBytes(unsigned char *buffer, size_t size)
|
||||
{
|
||||
RAND_bytes(buffer, size);
|
||||
RAND_bytes(buffer, (int)size);
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ Random Header
|
||||
#define RANDOM_H
|
||||
|
||||
// Functions
|
||||
void randomBytes(unsigned char *buffer, int size);
|
||||
void randomBytes(unsigned char *buffer, size_t size);
|
||||
|
||||
#endif
|
||||
|
@ -65,7 +65,7 @@ walStatus(const String *walSegment, bool confessOnError)
|
||||
THROW(FormatError, "%s message must be > 0", strPtr(statusFile));
|
||||
|
||||
// Get contents
|
||||
code = varIntForce(varNewStr(strNewN(strPtr(content), linefeedPtr - strPtr(content))));
|
||||
code = varIntForce(varNewStr(strNewN(strPtr(content), (size_t)(linefeedPtr - strPtr(content)))));
|
||||
message = strTrim(strNew(linefeedPtr + 1));
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ Define the console width - use a fixed with of 80 since this should be safe on v
|
||||
Helper function for helpRender() to make output look good on a console
|
||||
***********************************************************************************************************************************/
|
||||
static String *
|
||||
helpRenderText(const String *text, int indent, bool indentFirst, int length)
|
||||
helpRenderText(const String *text, size_t indent, bool indentFirst, size_t length)
|
||||
{
|
||||
String *result = strNew("");
|
||||
|
||||
@ -45,7 +45,7 @@ helpRenderText(const String *text, int indent, bool indentFirst, int length)
|
||||
strCat(result, "\n");
|
||||
|
||||
if (strSize(strLstGet(partList, partIdx)))
|
||||
strCatFmt(result, "%*s", indent, "");
|
||||
strCatFmt(result, "%*s", (int)indent, "");
|
||||
}
|
||||
|
||||
// Add the line
|
||||
|
@ -17,7 +17,7 @@ Macro to handle invalid encode type errors
|
||||
Encode binary data to a printable string
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
encodeToStr(EncodeType encodeType, const unsigned char *source, int sourceSize, char *destination)
|
||||
encodeToStr(EncodeType encodeType, const unsigned char *source, size_t sourceSize, char *destination)
|
||||
{
|
||||
if (encodeType == encodeBase64)
|
||||
encodeToStrBase64(source, sourceSize, destination);
|
||||
@ -28,10 +28,10 @@ encodeToStr(EncodeType encodeType, const unsigned char *source, int sourceSize,
|
||||
/***********************************************************************************************************************************
|
||||
Size of the string returned by encodeToStr()
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
encodeToStrSize(EncodeType encodeType, int sourceSize)
|
||||
size_t
|
||||
encodeToStrSize(EncodeType encodeType, size_t sourceSize)
|
||||
{
|
||||
int destinationSize = 0;
|
||||
size_t destinationSize = 0;
|
||||
|
||||
if (encodeType == encodeBase64)
|
||||
destinationSize = encodeToStrSizeBase64(sourceSize);
|
||||
@ -56,10 +56,10 @@ decodeToBin(EncodeType encodeType, const char *source, unsigned char *destinatio
|
||||
/***********************************************************************************************************************************
|
||||
Size of the binary data returned by decodeToBin()
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
size_t
|
||||
decodeToBinSize(EncodeType encodeType, const char *source)
|
||||
{
|
||||
int destinationSize = 0;
|
||||
size_t destinationSize = 0;
|
||||
|
||||
if (encodeType == encodeBase64)
|
||||
destinationSize = decodeToBinSizeBase64(source);
|
||||
|
@ -16,10 +16,10 @@ typedef enum {encodeBase64} EncodeType;
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
void encodeToStr(EncodeType encodeType, const unsigned char *source, int sourceSize, char *destination);
|
||||
int encodeToStrSize(EncodeType encodeType, int sourceSize);
|
||||
void encodeToStr(EncodeType encodeType, const unsigned char *source, size_t sourceSize, char *destination);
|
||||
size_t encodeToStrSize(EncodeType encodeType, size_t sourceSize);
|
||||
void decodeToBin(EncodeType encodeType, const char *source, unsigned char *destination);
|
||||
int decodeToBinSize(EncodeType encodeType, const char *source);
|
||||
size_t decodeToBinSize(EncodeType encodeType, const char *source);
|
||||
bool decodeToBinValid(EncodeType encodeType, const char *source);
|
||||
void decodeToBinValidate(EncodeType encodeType, const char *source);
|
||||
|
||||
|
@ -12,12 +12,12 @@ Encode binary data to a printable string
|
||||
static const char encodeBase64Lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
void
|
||||
encodeToStrBase64(const unsigned char *source, int sourceSize, char *destination)
|
||||
encodeToStrBase64(const unsigned char *source, size_t sourceSize, char *destination)
|
||||
{
|
||||
int destinationIdx = 0;
|
||||
unsigned int destinationIdx = 0;
|
||||
|
||||
// Encode the string from three bytes to four characters
|
||||
for (int sourceIdx = 0; sourceIdx < sourceSize; sourceIdx += 3)
|
||||
for (unsigned int sourceIdx = 0; sourceIdx < sourceSize; sourceIdx += 3)
|
||||
{
|
||||
// First encoded character is always used completely
|
||||
destination[destinationIdx++] = encodeBase64Lookup[source[sourceIdx] >> 2];
|
||||
@ -61,11 +61,11 @@ encodeToStrBase64(const unsigned char *source, int sourceSize, char *destination
|
||||
/***********************************************************************************************************************************
|
||||
Size of the destination param required by encodeToStrBase64() minus space for the null terminator
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
encodeToStrSizeBase64(int sourceSize)
|
||||
size_t
|
||||
encodeToStrSizeBase64(size_t sourceSize)
|
||||
{
|
||||
// Calculate how many groups of three are in the source
|
||||
int encodeGroupTotal = sourceSize / 3;
|
||||
size_t encodeGroupTotal = sourceSize / 3;
|
||||
|
||||
// Increase by one if there is a partial group
|
||||
if (sourceSize % 3 != 0)
|
||||
@ -132,15 +132,15 @@ decodeToBinBase64(const char *source, unsigned char *destination)
|
||||
/***********************************************************************************************************************************
|
||||
Size of the destination param required by decodeToBinBase64()
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
size_t
|
||||
decodeToBinSizeBase64(const char *source)
|
||||
{
|
||||
// Validate encoded string
|
||||
decodeToBinValidateBase64(source);
|
||||
|
||||
// Start with size calculated directly from source length
|
||||
int sourceSize = strlen(source);
|
||||
int destinationSize = sourceSize / 4 * 3;
|
||||
size_t sourceSize = strlen(source);
|
||||
size_t destinationSize = sourceSize / 4 * 3;
|
||||
|
||||
// Subtract last character if it is not present
|
||||
if (source[sourceSize - 1] == 0x3d)
|
||||
@ -162,13 +162,13 @@ void
|
||||
decodeToBinValidateBase64(const char *source)
|
||||
{
|
||||
// Check for the correct length
|
||||
int sourceSize = strlen(source);
|
||||
size_t sourceSize = strlen(source);
|
||||
|
||||
if (sourceSize % 4 != 0)
|
||||
THROW(FormatError, "base64 size %d is not evenly divisible by 4", sourceSize);
|
||||
|
||||
// Check all characters
|
||||
for (int sourceIdx = 0; sourceIdx < sourceSize; sourceIdx++)
|
||||
for (unsigned int sourceIdx = 0; sourceIdx < sourceSize; sourceIdx++)
|
||||
{
|
||||
// Check terminators
|
||||
if (source[sourceIdx] == 0x3d)
|
||||
|
@ -11,10 +11,10 @@ The high-level functions in encode.c should be used in preference to these low-l
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
void encodeToStrBase64(const unsigned char *source, int sourceSize, char *destination);
|
||||
int encodeToStrSizeBase64(int sourceSize);
|
||||
void encodeToStrBase64(const unsigned char *source, size_t sourceSize, char *destination);
|
||||
size_t encodeToStrSizeBase64(size_t sourceSize);
|
||||
void decodeToBinBase64(const char *source, unsigned char *destination);
|
||||
int decodeToBinSizeBase64(const char *source);
|
||||
size_t decodeToBinSizeBase64(const char *source);
|
||||
void decodeToBinValidateBase64(const char *source);
|
||||
|
||||
#endif
|
||||
|
@ -380,7 +380,7 @@ errorInternalThrowSys(int result, const ErrorType *errorType, const char *fileNa
|
||||
// Create message
|
||||
va_list argument;
|
||||
va_start(argument, format);
|
||||
int messageSize = vsnprintf(messageBufferTemp, ERROR_MESSAGE_BUFFER_SIZE - 1, format, argument);
|
||||
size_t messageSize = (size_t)vsnprintf(messageBufferTemp, ERROR_MESSAGE_BUFFER_SIZE - 1, format, argument);
|
||||
va_end(argument);
|
||||
|
||||
// Append the system message
|
||||
|
@ -181,7 +181,7 @@ iniParse(Ini *this, const String *content)
|
||||
THROW(FormatError, "missing '=' in key/value at line %d: %s", lineIdx + 1, linePtr);
|
||||
|
||||
// Extract the key
|
||||
String *key = strTrim(strNewN(linePtr, lineEqual - linePtr));
|
||||
String *key = strTrim(strNewN(linePtr, (size_t)(lineEqual - linePtr)));
|
||||
|
||||
if (strSize(key) == 0)
|
||||
THROW(FormatError, "key is zero-length at line %d: %s", lineIdx++, linePtr);
|
||||
|
@ -97,7 +97,7 @@ logInternal(LogLevel logLevel, const char *fileName, const char *functionName, i
|
||||
// Should this entry be logged?
|
||||
if (logLevel <= logLevelStdOut || logLevel <= logLevelStdErr)
|
||||
{
|
||||
int bufferPos = 0;
|
||||
size_t bufferPos = 0;
|
||||
|
||||
// Add time
|
||||
if (logTimestamp && logLevel > logLevelStdErr)
|
||||
@ -106,24 +106,28 @@ logInternal(LogLevel logLevel, const char *fileName, const char *functionName, i
|
||||
time_t logTime = (time_t)(logTimeUSec / USEC_PER_SEC);
|
||||
|
||||
bufferPos += strftime(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "%Y-%m-%d %H:%M:%S", localtime(&logTime));
|
||||
bufferPos += snprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, ".%03d ", (int)(logTimeUSec / 1000 % 1000));
|
||||
bufferPos += (size_t)snprintf(
|
||||
logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, ".%03d ", (int)(logTimeUSec / 1000 % 1000));
|
||||
}
|
||||
|
||||
// Add process and aligned log level
|
||||
if (logLevel > logLevelStdErr)
|
||||
bufferPos += snprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "P00 %*s: ", 6, logLevelStr(logLevel));
|
||||
{
|
||||
bufferPos += (size_t)snprintf(
|
||||
logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "P00 %*s: ", 6, logLevelStr(logLevel));
|
||||
}
|
||||
// Else just the log level with no alignment
|
||||
else
|
||||
bufferPos += snprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "%s: ", logLevelStr(logLevel));
|
||||
bufferPos += (size_t)snprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "%s: ", logLevelStr(logLevel));
|
||||
|
||||
// Add error code
|
||||
if (code != 0)
|
||||
bufferPos += snprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "[%03d]: ", code);
|
||||
bufferPos += (size_t)snprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "[%03d]: ", code);
|
||||
|
||||
// Add debug info
|
||||
if (logLevelStdOut >= logLevelDebug)
|
||||
{
|
||||
bufferPos += snprintf(
|
||||
bufferPos += (size_t)snprintf(
|
||||
logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, "%s:%s():%d: ", fileName, functionName, fileLine);
|
||||
}
|
||||
|
||||
@ -132,7 +136,7 @@ logInternal(LogLevel logLevel, const char *fileName, const char *functionName, i
|
||||
va_start(argumentList, format);
|
||||
|
||||
if (logLevel <= logLevelStdErr || strchr(format, '\n') == NULL)
|
||||
bufferPos += vsnprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, format, argumentList);
|
||||
bufferPos += (size_t)vsnprintf(logBuffer + bufferPos, LOG_BUFFER_SIZE - bufferPos, format, argumentList);
|
||||
else
|
||||
{
|
||||
vsnprintf(logFormat, LOG_BUFFER_SIZE, format, argumentList);
|
||||
@ -144,8 +148,8 @@ logInternal(LogLevel logLevel, const char *fileName, const char *functionName, i
|
||||
|
||||
while (linefeedPtr != NULL)
|
||||
{
|
||||
strncpy(logBuffer + bufferPos, formatPtr, linefeedPtr - formatPtr + 1);
|
||||
bufferPos += linefeedPtr - formatPtr + 1;
|
||||
strncpy(logBuffer + bufferPos, formatPtr, (size_t)(linefeedPtr - formatPtr + 1));
|
||||
bufferPos += (size_t)(linefeedPtr - formatPtr + 1);
|
||||
|
||||
formatPtr = linefeedPtr + 1;
|
||||
linefeedPtr = strchr(formatPtr, '\n');
|
||||
@ -171,6 +175,6 @@ logInternal(LogLevel logLevel, const char *fileName, const char *functionName, i
|
||||
stream = logHandleStdErr;
|
||||
|
||||
THROW_ON_SYS_ERROR(
|
||||
write(stream, logBuffer, bufferPos) != bufferPos, FileWriteError, "unable to write log to console");
|
||||
write(stream, logBuffer, bufferPos) != (int)bufferPos, FileWriteError, "unable to write log to console");
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ struct MemContext
|
||||
MemContext *contextParent; // All contexts have a parent except top
|
||||
|
||||
MemContext **contextChildList; // List of contexts created in this context
|
||||
int contextChildListSize; // Size of child context list (not the actual count of contexts)
|
||||
unsigned int contextChildListSize; // Size of child context list (not the actual count of contexts)
|
||||
|
||||
MemContextAlloc *allocList; // List of memory allocations created in this context
|
||||
int allocListSize; // Size of alloc list (not the actual count of allocations)
|
||||
unsigned int allocListSize; // Size of alloc list (not the actual count of allocations)
|
||||
|
||||
MemContextCallback callbackFunction; // Function to call before the context is freed
|
||||
void *callbackArgument; // Argument to pass to callback function
|
||||
@ -124,7 +124,7 @@ memContextNew(const char *name)
|
||||
THROW(AssertError, "context name length must be > 0 and <= %d", MEM_CONTEXT_NAME_SIZE);
|
||||
|
||||
// Try to find space for the new context
|
||||
int contextIdx;
|
||||
unsigned int contextIdx;
|
||||
|
||||
for (contextIdx = 0; contextIdx < memContextCurrent()->contextChildListSize; contextIdx++)
|
||||
if (!memContextCurrent()->contextChildList[contextIdx] ||
|
||||
@ -149,7 +149,7 @@ memContextNew(const char *name)
|
||||
else
|
||||
{
|
||||
// Calculate new list size
|
||||
int contextChildListSizeNew = memContextCurrent()->contextChildListSize * 2;
|
||||
unsigned int contextChildListSizeNew = memContextCurrent()->contextChildListSize * 2;
|
||||
|
||||
// ReAllocate memory before modifying anything else in case there is an error
|
||||
memContextCurrent()->contextChildList = memReAllocInternal(
|
||||
@ -215,7 +215,7 @@ static void *
|
||||
memContextAlloc(size_t size, bool zero)
|
||||
{
|
||||
// Find space for the new allocation
|
||||
int allocIdx;
|
||||
unsigned int allocIdx;
|
||||
|
||||
for (allocIdx = 0; allocIdx < memContextCurrent()->allocListSize; allocIdx++)
|
||||
if (!memContextCurrent()->allocList[allocIdx].active)
|
||||
@ -237,7 +237,7 @@ memContextAlloc(size_t size, bool zero)
|
||||
else
|
||||
{
|
||||
// Calculate new list size
|
||||
int allocListSizeNew = memContextCurrent()->allocListSize * 2;
|
||||
unsigned int allocListSizeNew = memContextCurrent()->allocListSize * 2;
|
||||
|
||||
// ReAllocate memory before modifying anything else in case there is an error
|
||||
memContextCurrent()->allocList = memReAllocInternal(
|
||||
@ -251,7 +251,7 @@ memContextAlloc(size_t size, bool zero)
|
||||
|
||||
// Allocate the memory
|
||||
memContextCurrent()->allocList[allocIdx].active = true;
|
||||
memContextCurrent()->allocList[allocIdx].size = size;
|
||||
memContextCurrent()->allocList[allocIdx].size = (unsigned int)size;
|
||||
memContextCurrent()->allocList[allocIdx].buffer = memAllocInternal(size, zero);
|
||||
|
||||
// Return buffer
|
||||
@ -261,7 +261,7 @@ memContextAlloc(size_t size, bool zero)
|
||||
/***********************************************************************************************************************************
|
||||
Find a memory allocation
|
||||
***********************************************************************************************************************************/
|
||||
static int
|
||||
static unsigned int
|
||||
memFind(const void *buffer)
|
||||
{
|
||||
// Error if buffer is null
|
||||
@ -269,7 +269,7 @@ memFind(const void *buffer)
|
||||
THROW(AssertError, "unable to find null allocation");
|
||||
|
||||
// Find memory allocation
|
||||
int allocIdx;
|
||||
unsigned int allocIdx;
|
||||
|
||||
for (allocIdx = 0; allocIdx < memContextCurrent()->allocListSize; allocIdx++)
|
||||
if (memContextCurrent()->allocList[allocIdx].buffer == buffer && memContextCurrent()->allocList[allocIdx].active)
|
||||
@ -302,7 +302,7 @@ memGrowRaw(const void *buffer, size_t size)
|
||||
|
||||
// Grow the buffer
|
||||
alloc->buffer = memReAllocInternal(alloc->buffer, alloc->size, size, false);
|
||||
alloc->size = size;
|
||||
alloc->size = (unsigned int)size;
|
||||
|
||||
return alloc->buffer;
|
||||
}
|
||||
@ -402,7 +402,7 @@ memContextFree(MemContext *this)
|
||||
|
||||
// Free child contexts
|
||||
if (this->contextChildListSize > 0)
|
||||
for (int contextIdx = 0; contextIdx < this->contextChildListSize; contextIdx++)
|
||||
for (unsigned int contextIdx = 0; contextIdx < this->contextChildListSize; contextIdx++)
|
||||
if (this->contextChildList[contextIdx] && this->contextChildList[contextIdx]->state == memContextStateActive)
|
||||
memContextFree(this->contextChildList[contextIdx]);
|
||||
|
||||
@ -417,7 +417,7 @@ memContextFree(MemContext *this)
|
||||
// Free child context allocations
|
||||
if (this->contextChildListSize > 0)
|
||||
{
|
||||
for (int contextIdx = 0; contextIdx < this->contextChildListSize; contextIdx++)
|
||||
for (unsigned int contextIdx = 0; contextIdx < this->contextChildListSize; contextIdx++)
|
||||
if (this->contextChildList[contextIdx])
|
||||
memFreeInternal(this->contextChildList[contextIdx]);
|
||||
|
||||
@ -428,7 +428,7 @@ memContextFree(MemContext *this)
|
||||
// Free memory allocations
|
||||
if (this->allocListSize > 0)
|
||||
{
|
||||
for (int allocIdx = 0; allocIdx < this->allocListSize; allocIdx++)
|
||||
for (unsigned int allocIdx = 0; allocIdx < this->allocListSize; allocIdx++)
|
||||
{
|
||||
MemContextAlloc *alloc = &(this->allocList[allocIdx]);
|
||||
|
||||
|
@ -24,7 +24,7 @@ void
|
||||
sleepUSec(TimeUSec sleepUSec)
|
||||
{
|
||||
struct timeval delay;
|
||||
delay.tv_sec = sleepUSec / USEC_PER_SEC;
|
||||
delay.tv_usec = sleepUSec % USEC_PER_SEC;
|
||||
delay.tv_sec = (__time_t)(sleepUSec / USEC_PER_SEC);
|
||||
delay.tv_usec = (__time_t)(sleepUSec % USEC_PER_SEC);
|
||||
select(0, NULL, NULL, NULL, &delay);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ strNewFmt(const char *format, ...)
|
||||
// Determine how long the allocated string needs to be
|
||||
va_list argumentList;
|
||||
va_start(argumentList, format);
|
||||
this->size = vsnprintf(NULL, 0, format, argumentList);
|
||||
this->size = (size_t)vsnprintf(NULL, 0, format, argumentList);
|
||||
va_end(argumentList);
|
||||
|
||||
// Allocate and assign string
|
||||
@ -151,7 +151,7 @@ String *
|
||||
strCat(String *this, const char *cat)
|
||||
{
|
||||
// Determine length of string to append
|
||||
int sizeGrow = strlen(cat);
|
||||
size_t sizeGrow = strlen(cat);
|
||||
|
||||
// Allocate and append string
|
||||
MEM_CONTEXT_BEGIN(this->memContext)
|
||||
@ -175,7 +175,7 @@ strCatFmt(String *this, const char *format, ...)
|
||||
// Determine how long the allocated string needs to be
|
||||
va_list argumentList;
|
||||
va_start(argumentList, format);
|
||||
int sizeGrow = vsnprintf(NULL, 0, format, argumentList);
|
||||
size_t sizeGrow = (size_t)vsnprintf(NULL, 0, format, argumentList);
|
||||
va_end(argumentList);
|
||||
|
||||
// Allocate and append string
|
||||
@ -275,7 +275,7 @@ String *
|
||||
strFirstUpper(String *this)
|
||||
{
|
||||
if (this->size > 0)
|
||||
this->buffer[0] = toupper(this->buffer[0]);
|
||||
this->buffer[0] = (char)toupper(this->buffer[0]);
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -287,7 +287,7 @@ String *
|
||||
strFirstLower(String *this)
|
||||
{
|
||||
if (this->size > 0)
|
||||
this->buffer[0] = tolower(this->buffer[0]);
|
||||
this->buffer[0] = (char)tolower(this->buffer[0]);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ strLstNewSplitZ(const String *string, const char *delimiter)
|
||||
// If a match was found then add the string
|
||||
if (stringMatch != NULL)
|
||||
{
|
||||
strLstAdd(this, strNewN(stringBase, stringMatch - stringBase));
|
||||
strLstAdd(this, strNewN(stringBase, (size_t)(stringMatch - stringBase)));
|
||||
stringBase = stringMatch + strlen(delimiter);
|
||||
}
|
||||
// Else make whatever is left the last string
|
||||
@ -97,7 +97,7 @@ strLstNewSplitSizeZ(const String *string, const char *delimiter, size_t size)
|
||||
if (stringMatchLast != NULL)
|
||||
stringMatch = stringMatchLast - strlen(delimiter);
|
||||
|
||||
strLstAdd(this, strNewN(stringBase, stringMatch - stringBase));
|
||||
strLstAdd(this, strNewN(stringBase, (size_t)(stringMatch - stringBase)));
|
||||
stringBase = stringMatch + strlen(delimiter);
|
||||
stringMatchLast = NULL;
|
||||
}
|
||||
@ -109,7 +109,7 @@ strLstNewSplitSizeZ(const String *string, const char *delimiter, size_t size)
|
||||
{
|
||||
if (stringMatchLast != NULL && strlen(stringBase) - strlen(delimiter) >= size)
|
||||
{
|
||||
strLstAdd(this, strNewN(stringBase, (stringMatchLast - strlen(delimiter)) - stringBase));
|
||||
strLstAdd(this, strNewN(stringBase, (size_t)((stringMatchLast - strlen(delimiter)) - stringBase)));
|
||||
stringBase = stringMatchLast;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ Return bool regardless of variant type
|
||||
bool
|
||||
varBoolForce(const Variant *this)
|
||||
{
|
||||
int result = 0;
|
||||
bool result = false;
|
||||
|
||||
switch (this->type)
|
||||
{
|
||||
@ -611,7 +611,7 @@ varStrForce(const Variant *this)
|
||||
break;
|
||||
}
|
||||
|
||||
result = strNewN(begin, end - begin + 1);
|
||||
result = strNewN(begin, (size_t)(end - begin + 1));
|
||||
strFree(working);
|
||||
|
||||
break;
|
||||
|
@ -362,7 +362,7 @@ cfgOptionDefaultSet(ConfigOption optionId, const Variant *defaultValue)
|
||||
/***********************************************************************************************************************************
|
||||
Get index for option
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
unsigned int
|
||||
cfgOptionIndex(ConfigOption optionId)
|
||||
{
|
||||
cfgOptionCheck(optionId);
|
||||
@ -385,7 +385,7 @@ cfgOptionId(const char *optionName)
|
||||
/***********************************************************************************************************************************
|
||||
Get total indexed values for option
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
unsigned int
|
||||
cfgOptionIndexTotal(ConfigOption optionId)
|
||||
{
|
||||
cfgOptionCheck(optionId);
|
||||
@ -396,7 +396,7 @@ cfgOptionIndexTotal(ConfigOption optionId)
|
||||
Get the id for this option define
|
||||
***********************************************************************************************************************************/
|
||||
ConfigOption
|
||||
cfgOptionIdFromDefId(ConfigDefineOption optionDefId, int index)
|
||||
cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index)
|
||||
{
|
||||
// Search for the option
|
||||
ConfigOption optionId;
|
||||
|
@ -45,9 +45,9 @@ void cfgOptionDefaultSet(ConfigOption optionId, const Variant *defaultValue);
|
||||
ConfigDefineOption cfgOptionDefIdFromId(ConfigOption optionId);
|
||||
double cfgOptionDbl(ConfigOption optionId);
|
||||
int cfgOptionId(const char *optionName);
|
||||
ConfigOption cfgOptionIdFromDefId(ConfigDefineOption optionDefId, int index);
|
||||
int cfgOptionIndex(ConfigOption optionId);
|
||||
int cfgOptionIndexTotal(ConfigOption optionDefId);
|
||||
ConfigOption cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index);
|
||||
unsigned int cfgOptionIndex(ConfigOption optionId);
|
||||
unsigned int cfgOptionIndexTotal(ConfigOption optionDefId);
|
||||
int cfgOptionInt(ConfigOption optionId);
|
||||
int64 cfgOptionInt64(ConfigOption optionId);
|
||||
const KeyValue *cfgOptionKv(ConfigOption optionId);
|
||||
|
@ -205,7 +205,7 @@ cfgDefDataFind(
|
||||
break;
|
||||
|
||||
// Set the current command
|
||||
commandCurrent = data;
|
||||
commandCurrent = (unsigned int)data;
|
||||
}
|
||||
// Only find type if not in a command block yet or in the expected command
|
||||
else if (type == typeFind && (commandCurrent == UINT_MAX || commandCurrent == commandDefId))
|
||||
@ -548,7 +548,7 @@ cfgDefOptionId(const char *optionName)
|
||||
/***********************************************************************************************************************************
|
||||
Get total indexed values for option
|
||||
***********************************************************************************************************************************/
|
||||
int
|
||||
unsigned int
|
||||
cfgDefOptionIndexTotal(ConfigDefineOption optionDefId)
|
||||
{
|
||||
cfgDefOptionCheck(optionDefId);
|
||||
|
@ -51,7 +51,7 @@ int cfgDefOptionHelpNameAltValueTotal(ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionHelpSection(ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionHelpSummary(ConfigDefineCommand commandDefId, ConfigDefineOption optionDefId);
|
||||
int cfgDefOptionId(const char *optionName);
|
||||
int cfgDefOptionIndexTotal(ConfigDefineOption optionDefId);
|
||||
unsigned int cfgDefOptionIndexTotal(ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionInternal(ConfigDefineCommand commandDefId, ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionName(ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionPrefix(ConfigDefineOption optionDefId);
|
||||
|
@ -13,13 +13,13 @@ Configuration Load
|
||||
Load the configuration
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
cfgLoad(int argListSize, const char *argList[])
|
||||
cfgLoad(unsigned int argListSize, const char *argList[])
|
||||
{
|
||||
cfgLoadParam(argListSize, argList, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
cfgLoadParam(int argListSize, const char *argList[], String *exe)
|
||||
cfgLoadParam(unsigned int argListSize, const char *argList[], String *exe)
|
||||
{
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
@ -59,7 +59,7 @@ cfgLoadParam(int argListSize, const char *argList[], String *exe)
|
||||
// Set default for pg-host-cmd
|
||||
if (cfgOptionValid(cfgOptPgHostCmd))
|
||||
{
|
||||
for (int optionIdx = 0; optionIdx <= cfgOptionIndexTotal(cfgOptPgHost); optionIdx++)
|
||||
for (unsigned int optionIdx = 0; optionIdx <= cfgOptionIndexTotal(cfgOptPgHost); optionIdx++)
|
||||
{
|
||||
if (cfgOption(cfgOptPgHost + optionIdx) != NULL && cfgOptionSource(cfgOptPgHostCmd + optionIdx) == cfgSourceDefault)
|
||||
cfgOptionDefaultSet(cfgOptPgHostCmd + optionIdx, varNewStr(cfgExe()));
|
||||
|
@ -7,7 +7,7 @@ Configuration Load
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
void cfgLoad(int argListSize, const char *argList[]);
|
||||
void cfgLoadParam(int argListSize, const char *argList[], String *exe);
|
||||
void cfgLoad(unsigned int argListSize, const char *argList[]);
|
||||
void cfgLoadParam(unsigned int argListSize, const char *argList[], String *exe);
|
||||
|
||||
#endif
|
||||
|
@ -17,16 +17,16 @@ Command and Option Parse
|
||||
Parse option flags
|
||||
***********************************************************************************************************************************/
|
||||
// Offset the option values so they don't conflict with getopt_long return codes
|
||||
#define PARSE_OPTION_FLAG (1 << 31)
|
||||
#define PARSE_OPTION_FLAG (1 << 30)
|
||||
|
||||
// Add a flag for negation rather than checking "--no-"
|
||||
#define PARSE_NEGATE_FLAG (1 << 30)
|
||||
#define PARSE_NEGATE_FLAG (1 << 29)
|
||||
|
||||
// Add a flag for reset rather than checking "--reset-"
|
||||
#define PARSE_RESET_FLAG (1 << 29)
|
||||
#define PARSE_RESET_FLAG (1 << 28)
|
||||
|
||||
// Indicate that option name has been deprecated and will be removed in a future release
|
||||
#define PARSE_DEPRECATE_FLAG (1 << 28)
|
||||
#define PARSE_DEPRECATE_FLAG (1 << 27)
|
||||
|
||||
// Mask to exclude all flags and get at the actual option id (only 12 bits allowed for option id, the rest reserved for flags)
|
||||
#define PARSE_OPTION_MASK 0xFFF
|
||||
@ -74,7 +74,7 @@ Parse the command-line arguments and config file to produce final config data
|
||||
logic to this critical path code.
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
configParse(int argListSize, const char *argList[])
|
||||
configParse(unsigned int argListSize, const char *argList[])
|
||||
{
|
||||
// Initialize configuration
|
||||
cfgInit();
|
||||
@ -107,7 +107,7 @@ configParse(int argListSize, const char *argList[])
|
||||
// Only the first non-option parameter should be treated as a command so track if the command has been set
|
||||
bool commandSet = false;
|
||||
|
||||
while ((option = getopt_long(argListSize, (char **)argList, "-:", optionList, &optionListIdx)) != -1)
|
||||
while ((option = getopt_long((int)argListSize, (char **)argList, "-:", optionList, &optionListIdx)) != -1)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
@ -590,7 +590,7 @@ configParse(int argListSize, const char *argList[])
|
||||
strPtr(strLstGet(parseOption->valueList, listIdx)), cfgOptionName(optionId));
|
||||
}
|
||||
|
||||
kvPut(keyValue, varNewStr(strNewN(pair, equal - pair)), varNewStr(strNew(equal + 1)));
|
||||
kvPut(keyValue, varNewStr(strNewN(pair, (size_t)(equal - pair))), varNewStr(strNew(equal + 1)));
|
||||
}
|
||||
|
||||
cfgOptionSet(optionId, parseOption->source, value);
|
||||
@ -621,7 +621,7 @@ configParse(int argListSize, const char *argList[])
|
||||
TRY_BEGIN()
|
||||
{
|
||||
if (optionDefType == cfgDefOptTypeInteger)
|
||||
valueDbl = varInt64Force(varNewStr(value));
|
||||
valueDbl = (double)varInt64Force(varNewStr(value));
|
||||
else
|
||||
valueDbl = varDblForce(varNewStr(value));
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ Parse Configuration
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
void configParse(int argListSize, const char *argList[]);
|
||||
void configParse(unsigned int argListSize, const char *argList[]);
|
||||
|
||||
#endif
|
||||
|
@ -23,7 +23,7 @@ main(int argListSize, const char *argList[])
|
||||
{
|
||||
// Load the configuration
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
cfgLoad(argListSize, argList);
|
||||
cfgLoad((unsigned int)argListSize, argList);
|
||||
|
||||
// Display help
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -18,6 +18,8 @@ Execute Perl for Legacy Functionality
|
||||
#define WARNING_PEDANTIC 1
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
#if WARNING_PEDANTIC
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
@ -33,6 +35,8 @@ Execute Perl for Legacy Functionality
|
||||
#pragma GCC diagnostic warning "-Wpedantic"
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic warning "-Wsign-conversion"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constants used to build perl options
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -166,13 +166,13 @@ The checksum includes the block number (to detect the case where a page is someh
|
||||
(excluding the checksum itself), and the page data.
|
||||
***********************************************************************************************************************************/
|
||||
uint16
|
||||
pageChecksum(const unsigned char *page, int blockNo, int pageSize)
|
||||
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;
|
||||
|
||||
uint32 originalChecksum = pageHeader->pd_checksum;
|
||||
uint16 originalChecksum = pageHeader->pd_checksum;
|
||||
pageHeader->pd_checksum = 0;
|
||||
uint32 checksum = pageChecksumBlock(page, pageSize);
|
||||
pageHeader->pd_checksum = originalChecksum;
|
||||
@ -181,14 +181,14 @@ pageChecksum(const unsigned char *page, int blockNo, int pageSize)
|
||||
checksum ^= blockNo;
|
||||
|
||||
// Reduce to a uint16 with an offset of one. That avoids checksums of zero, which seems like a good idea.
|
||||
return (checksum % 65535) + 1;
|
||||
return (uint16)((checksum % 65535) + 1);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
pageChecksumTest - test if checksum is valid for a single page
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
pageChecksumTest(const unsigned char *page, int blockNo, int pageSize, uint32 ignoreWalId, uint32 ignoreWalOffset)
|
||||
pageChecksumTest(const unsigned char *page, unsigned int blockNo, unsigned int pageSize, uint32 ignoreWalId, uint32 ignoreWalOffset)
|
||||
{
|
||||
return
|
||||
// This is a new page so don't test checksum
|
||||
@ -204,15 +204,15 @@ pageChecksumBufferTest - test if checksums are valid for all pages in a buffer
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
pageChecksumBufferTest(
|
||||
const unsigned char *pageBuffer, int pageBufferSize, int blockNoBegin, int pageSize, uint32 ignoreWalId,
|
||||
uint32 ignoreWalOffset)
|
||||
const unsigned char *pageBuffer, unsigned int pageBufferSize, unsigned int blockNoBegin, unsigned int pageSize,
|
||||
uint32 ignoreWalId, uint32 ignoreWalOffset)
|
||||
{
|
||||
// If the buffer does not represent an even number of pages then error
|
||||
if (pageBufferSize % pageSize != 0 || pageBufferSize / pageSize == 0)
|
||||
THROW(AssertError, "buffer size %d, page size %d are not divisible", pageBufferSize, pageSize);
|
||||
|
||||
// Loop through all pages in the buffer
|
||||
for (int pageIdx = 0; pageIdx < pageBufferSize / pageSize; pageIdx++)
|
||||
for (unsigned int pageIdx = 0; pageIdx < pageBufferSize / pageSize; pageIdx++)
|
||||
{
|
||||
const unsigned char *page = pageBuffer + (pageIdx * pageSize);
|
||||
|
||||
|
@ -9,10 +9,11 @@ Checksum Implementation for Data Pages
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
uint16 pageChecksum(const unsigned char *page, int blockNo, int pageSize);
|
||||
bool pageChecksumTest(const unsigned char *page, int blockNo, int pageSize, uint32 ignoreWalId, uint32 ignoreWalOffset);
|
||||
uint16 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);
|
||||
bool pageChecksumBufferTest(
|
||||
const unsigned char *pageBuffer, int pageBufferSize, int blockNoBegin, int pageSize, uint32 ignoreWalId,
|
||||
uint32 ignoreWalOffset);
|
||||
const unsigned char *pageBuffer, unsigned int pageBufferSize, unsigned int blockNoBegin, unsigned int pageSize,
|
||||
uint32 ignoreWalId, uint32 ignoreWalOffset);
|
||||
|
||||
#endif
|
||||
|
@ -92,7 +92,7 @@ storageSpool()
|
||||
{
|
||||
storageSpoolStanza = strDup(cfgOptionStr(cfgOptStanza));
|
||||
storageSpoolData = storageNew(
|
||||
cfgOptionStr(cfgOptSpoolPath), STORAGE_PATH_MODE_DEFAULT, cfgOptionInt(cfgOptBufferSize),
|
||||
cfgOptionStr(cfgOptSpoolPath), STORAGE_PATH_MODE_DEFAULT, (size_t)cfgOptionInt(cfgOptBufferSize),
|
||||
(StoragePathExpressionCallback)storageSpoolPathExpression);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
|
@ -280,7 +280,7 @@ storagePath(const Storage *storage, const String *pathExp)
|
||||
THROW(AssertError, "end > not found in path expression '%s'", strPtr(pathExp));
|
||||
|
||||
// Create a string from the expression
|
||||
String *expression = strNewN(strPtr(pathExp), end - strPtr(pathExp) + 1);
|
||||
String *expression = strNewN(strPtr(pathExp), (size_t)(end - strPtr(pathExp) + 1));
|
||||
|
||||
// Create a string from the path if there is anything left after the expression
|
||||
String *path = NULL;
|
||||
|
@ -324,7 +324,7 @@ sub run
|
||||
my $strMakefile =
|
||||
"CC=gcc\n" .
|
||||
"CFLAGS=-I. -std=c99 -fPIC -g \\\n" .
|
||||
" -Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered" .
|
||||
" -Werror -Wfatal-errors -Wall -Wextra -Wwrite-strings -Wno-clobbered -Wswitch-enum -Wconversion" .
|
||||
($self->{oTest}->{&TEST_VM} ne VM_CO6 && $self->{oTest}->{&TEST_VM} ne VM_U12 ? ' -Wpedantic' : '') . "\\\n" .
|
||||
" `perl -MExtUtils::Embed -e ccopts`\n" .
|
||||
"LDFLAGS=-lcrypto" . (vmCoverage($self->{oTest}->{&TEST_VM}) ? " -lgcov" : '') .
|
||||
|
@ -58,9 +58,9 @@ testRun()
|
||||
if (testBegin("Encrypt and Decrypt"))
|
||||
{
|
||||
unsigned char encryptBuffer[TEST_BUFFER_SIZE];
|
||||
int encryptSize = 0;
|
||||
size_t encryptSize = 0;
|
||||
unsigned char decryptBuffer[TEST_BUFFER_SIZE];
|
||||
int decryptSize = 0;
|
||||
size_t decryptSize = 0;
|
||||
|
||||
// Encrypt
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -13,7 +13,7 @@ testRun()
|
||||
{
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
// Test if the buffer was overrun
|
||||
int bufferSize = 256;
|
||||
size_t bufferSize = 256;
|
||||
unsigned char *buffer = memNew(bufferSize + 1);
|
||||
|
||||
randomBytes(buffer, bufferSize);
|
||||
@ -23,7 +23,7 @@ testRun()
|
||||
// Count bytes that are not zero (there shouldn't be all zeroes)
|
||||
int nonZeroTotal = 0;
|
||||
|
||||
for (int charIdx = 0; charIdx < bufferSize; charIdx++)
|
||||
for (unsigned int charIdx = 0; charIdx < bufferSize; charIdx++)
|
||||
if (buffer[charIdx] != 0)
|
||||
nonZeroTotal++;
|
||||
|
||||
|
@ -38,7 +38,7 @@ testRun()
|
||||
TEST_ASSIGN(bufferPtr, bufPtr(buffer), "buffer pointer");
|
||||
|
||||
for (unsigned int bufferIdx = 0; bufferIdx < bufSize(buffer); bufferIdx++)
|
||||
bufferPtr[bufferIdx] = bufferIdx;
|
||||
bufferPtr[bufferIdx] = (unsigned char)bufferIdx;
|
||||
|
||||
// Increase buffer size
|
||||
TEST_ASSIGN(bufferPtr, bufPtr(bufResize(buffer, 512)), "increase buffer size");
|
||||
|
@ -17,7 +17,7 @@ testRun()
|
||||
TEST_ERROR(waitNew(9999999), AssertError, "waitTime must be >= 0.1 and <= 999999.0");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
unsigned long begin = timeUSec();
|
||||
TimeUSec begin = timeUSec();
|
||||
|
||||
TEST_ASSIGN(wait, waitNew(0.2), "new wait = 0.2 sec");
|
||||
TEST_RESULT_DOUBLE(wait->waitTime, 200000, " check wait time");
|
||||
@ -26,7 +26,7 @@ testRun()
|
||||
TEST_RESULT_BOOL(wait->beginTime > (unsigned long)1483228800000000, true, " check begin time");
|
||||
|
||||
while (waitMore(wait));
|
||||
unsigned long end = timeUSec();
|
||||
TimeUSec end = timeUSec();
|
||||
|
||||
// Check bounds for time slept (within a range of .1 seconds)
|
||||
TEST_RESULT_BOOL(end - begin >= wait->waitTime, true, " lower range check");
|
||||
|
@ -13,7 +13,7 @@ Test Configuration Parse
|
||||
Option find test -- this is done a lot in the deprecated tests
|
||||
***********************************************************************************************************************************/
|
||||
static void
|
||||
testOptionFind(const char *option, int value)
|
||||
testOptionFind(const char *option, unsigned int value)
|
||||
{
|
||||
// If not testing for a missing option, then add the option offset that is already added to each option in the list
|
||||
if (value != 0)
|
||||
@ -555,7 +555,7 @@ testRun()
|
||||
|
||||
testOptionFind("no-db-user", 0);
|
||||
|
||||
for (int optionIdx = 0; optionIdx < cfgDefOptionIndexTotal(cfgDefOptPgPath); optionIdx++)
|
||||
for (unsigned int optionIdx = 0; optionIdx < cfgDefOptionIndexTotal(cfgDefOptPgPath); optionIdx++)
|
||||
{
|
||||
testOptionFind(strPtr(strNewFmt("db%u-cmd", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + optionIdx));
|
||||
testOptionFind(
|
||||
|
@ -11,7 +11,7 @@ Page data for testing -- use 8192 for page size since this is the most common va
|
||||
// GCC doesn't like this elements of this array being used as both char * and struct * so wrap it in a function to disable the
|
||||
// optimizations that cause warnings
|
||||
unsigned char *
|
||||
testPage(int pageIdx)
|
||||
testPage(unsigned int pageIdx)
|
||||
{
|
||||
static unsigned char testPageBuffer[TEST_PAGE_TOTAL][TEST_PAGE_SIZE];
|
||||
return testPageBuffer[pageIdx];
|
||||
@ -74,7 +74,7 @@ testRun()
|
||||
AssertError, "buffer size 131071, page size 8192 are not divisible");
|
||||
|
||||
// Create pages that will pass the test (starting with block 0)
|
||||
for (int pageIdx = 0; pageIdx < TEST_PAGE_TOTAL; pageIdx++)
|
||||
for (unsigned int pageIdx = 0; pageIdx < TEST_PAGE_TOTAL; pageIdx++)
|
||||
{
|
||||
// Don't fill with zero because zeroes will succeed on the pd_upper check
|
||||
memset(testPage(pageIdx), 0x77, TEST_PAGE_SIZE);
|
||||
@ -87,9 +87,9 @@ testRun()
|
||||
true, "valid page buffer starting at block 0");
|
||||
|
||||
// Create pages that will pass the test (beginning with block <> 0)
|
||||
int blockBegin = 999;
|
||||
unsigned int blockBegin = 999;
|
||||
|
||||
for (int pageIdx = 0; pageIdx < TEST_PAGE_TOTAL; pageIdx++)
|
||||
for (unsigned int pageIdx = 0; pageIdx < TEST_PAGE_TOTAL; pageIdx++)
|
||||
{
|
||||
((PageHeader)testPage(pageIdx))->pd_checksum = pageChecksum(
|
||||
testPage(pageIdx), pageIdx + blockBegin, TEST_PAGE_SIZE);
|
||||
@ -101,8 +101,8 @@ testRun()
|
||||
true, "valid page buffer starting at block 999");
|
||||
|
||||
// Break the checksum for a page and make sure it is found
|
||||
int pageInvalid = 7;
|
||||
assert(pageInvalid >= 0 && pageInvalid < TEST_PAGE_TOTAL);
|
||||
unsigned int pageInvalid = 7;
|
||||
assert(pageInvalid < TEST_PAGE_TOTAL);
|
||||
((PageHeader)testPage(pageInvalid))->pd_checksum = 0xEEEE;
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
|
Loading…
x
Reference in New Issue
Block a user