Skip to content

Commit

Permalink
Convert the not very portable uint type to unsigned int.
Browse files Browse the repository at this point in the history
Suggested by Devrim Gündüz.
  • Loading branch information
dwsteele committed Jun 14, 2018
1 parent 4e7692b commit 3793ae1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
8 changes: 8 additions & 0 deletions doc/xml/release.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
<release-item>
<p>Update Debian package to add debug symbols to <backrest/> executable.</p>
</release-item>

<release-item>
<release-item-contributor-list>
<release-item-ideator id="gunduz.devrim"/>
</release-item-contributor-list>

<p>Convert the not very portable <code>uint</code> type to <code>unsigned int</code>.</p>
</release-item>
</release-development-list>
</release-core-list>

Expand Down
6 changes: 3 additions & 3 deletions src/command/archive/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool confe
Get the next WAL segment given a WAL segment and WAL segment size
***********************************************************************************************************************************/
String *
walSegmentNext(const String *walSegment, size_t walSegmentSize, uint pgVersion)
walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgVersion)
{
FUNCTION_DEBUG_BEGIN(logLevelTrace);
FUNCTION_DEBUG_PARAM(STRING, walSegment);
Expand Down Expand Up @@ -161,7 +161,7 @@ walSegmentNext(const String *walSegment, size_t walSegmentSize, uint pgVersion)
Build a list of WAL segments based on a beginning WAL and number of WAL in the range (inclusive)
***********************************************************************************************************************************/
StringList *
walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, uint pgVersion, uint range)
walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned int pgVersion, unsigned int range)
{
FUNCTION_DEBUG_BEGIN(logLevelDebug);
FUNCTION_DEBUG_PARAM(STRING, walSegmentBegin);
Expand All @@ -181,7 +181,7 @@ walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, uint pgVer
{
String *current = strDup(walSegmentBegin);

for (uint rangeIdx = 0; rangeIdx < range - 1; rangeIdx++)
for (unsigned int rangeIdx = 0; rangeIdx < range - 1; rangeIdx++)
{
String *next = walSegmentNext(current, walSegmentSize, pgVersion);

Expand Down
6 changes: 3 additions & 3 deletions src/command/archive/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ WAL segment constants
#define WAL_SEGMENT_REGEXP "^[0-F]{24}$"

// Defines the size of standard WAL segment name -- this should never changed
#define WAL_SEGMENT_NAME_SIZE ((uint)24)
#define WAL_SEGMENT_NAME_SIZE ((unsigned int)24)

// Default size of a WAL segment
#define WAL_SEGMENT_DEFAULT_SIZE ((size_t)(16 * 1024 * 1024))
Expand All @@ -36,7 +36,7 @@ Functions
***********************************************************************************************************************************/
bool archiveAsyncStatus(ArchiveMode archiveMode, const String *walSegment, bool confessOnError);

String *walSegmentNext(const String *walSegment, size_t walSegmentSize, uint pgVersion);
StringList *walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, uint pgVersion, uint range);
String *walSegmentNext(const String *walSegment, size_t walSegmentSize, unsigned int pgVersion);
StringList *walSegmentRange(const String *walSegmentBegin, size_t walSegmentSize, unsigned int pgVersion, unsigned int range);

#endif
12 changes: 6 additions & 6 deletions src/command/archive/get/get.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Archive Get Command
Clean the queue and prepare a list of WAL segments that the async process should get
***********************************************************************************************************************************/
static StringList *
queueNeed(const String *walSegment, bool found, size_t queueSize, size_t walSegmentSize, uint pgVersion)
queueNeed(const String *walSegment, bool found, size_t queueSize, size_t walSegmentSize, unsigned int pgVersion)
{
FUNCTION_DEBUG_BEGIN(logLevelDebug);
FUNCTION_DEBUG_PARAM(STRING, walSegment);
Expand All @@ -47,7 +47,7 @@ queueNeed(const String *walSegment, bool found, size_t queueSize, size_t walSegm

// Determine how many WAL segments should be in the queue. The queue total must be at least 2 or it doesn't make sense to
// have async turned on at all.
uint walSegmentQueueTotal = (uint)(queueSize / walSegmentSize);
unsigned int walSegmentQueueTotal = (unsigned int)(queueSize / walSegmentSize);

if (walSegmentQueueTotal < 2)
walSegmentQueueTotal = 2;
Expand All @@ -65,7 +65,7 @@ queueNeed(const String *walSegment, bool found, size_t queueSize, size_t walSegm
// Build a list of WAL segments that are being kept so we can later make a list of what is needed
StringList *keepQueue = strLstNew();

for (uint actualQueueIdx = 0; actualQueueIdx < strLstSize(actualQueue); actualQueueIdx++)
for (unsigned int actualQueueIdx = 0; actualQueueIdx < strLstSize(actualQueue); actualQueueIdx++)
{
// Get file from actual queue
const String *file = strLstGet(actualQueue, actualQueueIdx);
Expand All @@ -80,7 +80,7 @@ queueNeed(const String *walSegment, bool found, size_t queueSize, size_t walSegm
}

// Generate a list of the WAL that are needed by removing kept WAL from the ideal queue
for (uint idealQueueIdx = 0; idealQueueIdx < strLstSize(idealQueue); idealQueueIdx++)
for (unsigned int idealQueueIdx = 0; idealQueueIdx < strLstSize(idealQueue); idealQueueIdx++)
{
if (!strLstExists(keepQueue, strLstGet(idealQueue, idealQueueIdx)))
strLstAdd(result, strLstGet(idealQueue, idealQueueIdx));
Expand Down Expand Up @@ -210,10 +210,10 @@ cmdArchiveGet()
TRY_BEGIN()
{
// Get the version of PostgreSQL
uint pgVersion = pgControlInfo(cfgOptionStr(cfgOptPgPath)).version;
unsigned int pgVersion = pgControlInfo(cfgOptionStr(cfgOptPgPath)).version;

// Determine WAL segment size -- for now this is the default but for PG11 it will be configurable
uint walSegmentSize = WAL_SEGMENT_DEFAULT_SIZE;
unsigned int walSegmentSize = WAL_SEGMENT_DEFAULT_SIZE;

// Create the queue
storagePathCreateNP(storageSpool(), strNew(STORAGE_SPOOL_ARCHIVE_IN));
Expand Down
6 changes: 3 additions & 3 deletions src/command/help/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ helpRenderValue(const Variant *value)
const KeyValue *optionKv = varKv(value);
const VariantList *keyList = kvKeyList(optionKv);

for (uint keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
{
if (keyIdx != 0)
strCat(result, ", ");
Expand All @@ -113,7 +113,7 @@ helpRenderValue(const Variant *value)

const VariantList *list = varVarLst(value);

for (uint listIdx = 0; listIdx < varLstSize(list); listIdx++)
for (unsigned int listIdx = 0; listIdx < varLstSize(list); listIdx++)
{
if (listIdx != 0)
strCat(result, ", ");
Expand Down Expand Up @@ -357,7 +357,7 @@ helpRender()

strCat(result, ": ");

for (uint nameAltIdx = 0; nameAltIdx < cfgDefOptionHelpNameAltValueTotal(optionDefId); nameAltIdx++)
for (unsigned int nameAltIdx = 0; nameAltIdx < cfgDefOptionHelpNameAltValueTotal(optionDefId); nameAltIdx++)
{
if (nameAltIdx != 0) // {uncovered - no option has more than one alt name}
strCat(result, ", "); // {+uncovered}
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ PostgreSQL Info
/***********************************************************************************************************************************
Map control/catalog version to PostgreSQL version
***********************************************************************************************************************************/
static uint
static unsigned int
pgVersionMap(uint32_t controlVersion, uint32_t catalogVersion)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(UINT32, controlVersion);
FUNCTION_TEST_PARAM(UINT32, catalogVersion);
FUNCTION_TEST_END();

uint result = 0;
unsigned int result = 0;

if (controlVersion == 1100 && catalogVersion == 201804191)
result = PG_VERSION_11;
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ typedef struct PgControlInfo
uint64_t systemId;
uint32_t controlVersion;
uint32_t catalogVersion;
uint version;
unsigned int version;
} PgControlInfo;

#include "common/type/string.h"
Expand Down
2 changes: 1 addition & 1 deletion test/src/module/common/typeConvertTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ testRun()

TEST_ERROR(cvtUIntToZ(9999, buffer, 4), AssertError, "buffer overflow");

TEST_RESULT_INT(cvtUIntToZ(4294967295, buffer, STACK_TRACE_PARAM_MAX), 10, "convert uint to string");
TEST_RESULT_INT(cvtUIntToZ(4294967295, buffer, STACK_TRACE_PARAM_MAX), 10, "convert unsigned int to string");
TEST_RESULT_STR(buffer, "4294967295", " check buffer");
}

Expand Down

0 comments on commit 3793ae1

Please sign in to comment.