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