Skip to content
Permalink
Browse files

Add constant for maximum buffer sizes required by cvt*() functions.

Also update Variant to use cvt*() in all cases.  Variant was written before these functions were available and not all cases were updated.
  • Loading branch information...
dwsteele committed Apr 22, 2019
1 parent f573905 commit f100ea0ff44e173299e8f691115b9e7ce68d422b
Showing with 23 additions and 12 deletions.
  1. +4 −0 doc/xml/release.xml
  2. +1 −1 src/common/io/tls/client.c
  3. +6 −0 src/common/type/convert.h
  4. +12 −11 src/common/type/variant.c
@@ -37,6 +37,10 @@
<p><code>varNewKv()</code> accepts a <code>KeyValue</code> object rather than creating one.</p>
</release-item>

<release-item>
<p>Add constant for maximum buffer sizes required by <code>cvt*()</code> functions.</p>
</release-item>

<release-item>
<p>Add <id>true</id> and <id>false</id> <code>String</code> constants.</p>
</release-item>
@@ -298,7 +298,7 @@ tlsClientOpen(TlsClient *this)
hints.ai_protocol = IPPROTO_TCP;

// Convert the port to a zero-terminated string for use with getaddrinfo()
char port[32];
char port[CVT_BASE10_BUFFER_SIZE];
cvtUIntToZ(this->port, port, sizeof(port));

// Get an address for the host. We are only going to try the first address returned.
@@ -7,6 +7,12 @@ Convert Base Data Types
#include <inttypes.h>
#include <sys/types.h>

/***********************************************************************************************************************************
Required buffer sizes
***********************************************************************************************************************************/
#define CVT_BOOL_BUFFER_SIZE 6
#define CVT_BASE10_BUFFER_SIZE 64

/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
@@ -1080,27 +1080,22 @@ varStrForce(const Variant *this)
{
case varTypeBool:
{
char working[6];

cvtBoolToZ(varBool(this), working, sizeof(working));
result = strNew(working);

result = strNew(cvtBoolToConstZ(varBool(this)));
break;
}

case varTypeDouble:
{
char working[64];
char working[CVT_BASE10_BUFFER_SIZE];

cvtDoubleToZ(varDbl(this), working, sizeof(working));
result = strNew(working);

break;
}

case varTypeInt:
{
char working[64];
char working[CVT_BASE10_BUFFER_SIZE];

cvtIntToZ(varInt(this), working, sizeof(working));
result = strNew(working);
@@ -1109,7 +1104,7 @@ varStrForce(const Variant *this)

case varTypeInt64:
{
char working[64];
char working[CVT_BASE10_BUFFER_SIZE];

cvtInt64ToZ(varInt64(this), working, sizeof(working));
result = strNew(working);
@@ -1124,13 +1119,19 @@ varStrForce(const Variant *this)

case varTypeUInt:
{
result = strNewFmt("%u", varUInt(this));
char working[CVT_BASE10_BUFFER_SIZE];

cvtUIntToZ(varUInt(this), working, sizeof(working));
result = strNew(working);
break;
}

case varTypeUInt64:
{
result = strNewFmt("%" PRIu64, varUInt64(this));
char working[CVT_BASE10_BUFFER_SIZE];

cvtUInt64ToZ(varUInt64(this), working, sizeof(working));
result = strNew(working);
break;
}

0 comments on commit f100ea0

Please sign in to comment.
You can’t perform that action at this time.