Skip to content

Commit

Permalink
HPCC-32395 Clean up compile warnings from jhtree and roxiemem
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Sep 19, 2024
1 parent 71c9ba5 commit 7992afd
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 163 deletions.
5 changes: 0 additions & 5 deletions plugins/debugservices/debugservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ static const char * EclDefinition =
" varstring GetBuildInfo() : c,pure,entrypoint='dsGetBuildInfo',initFunction='dsInitDebugServices';\n"
"END;";

static const char * compatibleVersions[] = {
"DEBUGSERVICES 1.0 [7294888b4271178e0cfda307826d4823]",
"DEBUGSERVICES 1.0.1",
NULL };

DEBUGSERVICES_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
{
if (pb->size != sizeof(ECLPluginDefinitionBlock))
Expand Down
1 change: 0 additions & 1 deletion plugins/stringlib/stringlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,6 @@ STRINGLIB_API void STRINGLIB_CALL slSplitWords(bool & __isAllResult, size32_t &
return;
}

unsigned sizeWords=0;
char * target = result;
const char * end = src + lenSrc;
const char * max = end - (lenSeparator - 1);
Expand Down
3 changes: 1 addition & 2 deletions plugins/timelib/timelib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ TIMELIB_API unsigned int TIMELIB_CALL tlAdjustCalendar(unsigned int date, short
unsigned int month = (date - (year * 10000)) / 100;
unsigned int day = date - (year * 10000) - (month * 100);
int expectedMonthVal = month - 1;
time_t seconds;
unsigned int result = 0;

// Normalize the expected month value
Expand All @@ -823,7 +822,7 @@ TIMELIB_API unsigned int TIMELIB_CALL tlAdjustCalendar(unsigned int date, short
timeInfo.tm_mon += month_delta;
timeInfo.tm_isdst = -1;

seconds = tlMKTime(&timeInfo);
tlMKTime(&timeInfo);

if (timeInfo.tm_mon != expectedMonthVal)
{
Expand Down
10 changes: 3 additions & 7 deletions roxie/roxiemem/roxiemem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,6 @@ static void *suballoc_aligned(size32_t pages, bool returnNullWhenExhausted)
if (matches==pages)
{
unsigned start = i;
heap_t startHbi = hbi;
char *ret = heapBase + (i*HEAP_BITS+b-1)*HEAP_ALIGNMENT_SIZE;
for (;;)
{
Expand Down Expand Up @@ -3841,7 +3840,6 @@ unsigned ChunkedHeaplet::allocateMultiChunk(unsigned max, char * * rows)
unsigned alreadyIncremented = 0;
do
{
bool needIncrement = false;
char * ret = allocateSingle(allocated, false, alreadyIncremented);
if (!ret)
{
Expand Down Expand Up @@ -8183,7 +8181,6 @@ class RoxieMemTests : public CppUnit::TestFixture
void testRoundup()
{
Owned<IRowManager> rowManager = createRowManager(1, NULL, logctx, NULL, false);
CChunkingRowManager * managerObject = static_cast<CChunkingRowManager *>(rowManager.get());
const unsigned maxFrac = firstFractionalHeap;

const void * tempRow[MAX_FRAC_ALLOCATOR];
Expand Down Expand Up @@ -8242,7 +8239,7 @@ class RoxieMemTests : public CppUnit::TestFixture
}
void * otherrow = rowManager->allocate(100, 0);
savedRowHeap.setown(rowManager->createFixedRowHeap(8, ACTIVITY_FLAG_ISREGISTERED|0, RHFhasdestructor|RHFunique));
void * leakedRow = savedRowHeap->allocate();
[[maybe_unused]] void * leakedRow = savedRowHeap->allocate();
ReleaseRoxieRow(otherrow);
rowManager.clear();
}
Expand Down Expand Up @@ -8428,7 +8425,8 @@ class RoxieMemTests : public CppUnit::TestFixture

for (unsigned pass=0; pass < 8; pass++)
{
unsigned numPagesFull = rowManager->numPagesAfterCleanup(true);
//numPagesAfterCleanup() also has the side-effect of freeing up any empty pages.
[[maybe_unused]] unsigned numPagesFull = rowManager->numPagesAfterCleanup(true);
unsigned numRowsLeft = 0;
unsigned target=0;
for (unsigned i2 = 0; i2 < numRows; i2++)
Expand Down Expand Up @@ -8758,8 +8756,6 @@ class RoxieMemTests : public CppUnit::TestFixture
void testResize()
{
Owned<IRowManager> rowManager = createRowManager(0, NULL, logctx, NULL, false);
memsize_t maxMemory = heapTotalPages * HEAP_ALIGNMENT_SIZE;
memsize_t wasted = 0;

std::unique_ptr<void *[]> pages(new void * [heapTotalPages]);
//Allocate a whole set of 1 page allocations
Expand Down
13 changes: 6 additions & 7 deletions rtl/nbcd/nbcd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ class nbcd_decl Decimal
Decimal & incLSD();

protected:
enum {
maxDigits=MAX_DECIMAL_DIGITS, // Total buffer size (integer+decimal)
maxPrecision=MAX_DECIMAL_PRECISION, // Size of decimal part
maxIntegerDigits=MAX_DECIMAL_LEADING, // Size of integer part
lastDigit = maxDigits-1, // Last decimal digit
zeroDigit = (maxDigits-maxIntegerDigits), // Unity digit (decimal point)
};
constexpr static int maxDigits=MAX_DECIMAL_DIGITS; // Total buffer size (integer+decimal)
constexpr static int maxPrecision=MAX_DECIMAL_PRECISION; // Size of decimal part
constexpr static int maxIntegerDigits=MAX_DECIMAL_LEADING; // Size of integer part
constexpr static int lastDigit = maxDigits-1; // Last decimal digit
constexpr static int zeroDigit = (maxDigits-maxIntegerDigits); // Unity digit (decimal point)

byte digits[maxDigits] = { 0 } ; // stored little endian.
byte msb = zeroDigit; // Most significant integer digit
byte lsb = zeroDigit; // Least significant decimal digit
Expand Down
14 changes: 6 additions & 8 deletions system/jhtree/ctfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ extern bool isCompressedIndex(const char *filename)
return false;
SwapBigEndian(hdr);
}
if (hdr.root && hdr.root % hdr.nodeSize == 0 && hdr.phyrec == size-1 && hdr.ktype & (HTREE_COMPRESSED_KEY|HTREE_QUICK_COMPRESSED_KEY))
if (hdr.root && hdr.root % hdr.nodeSize == 0 && (__uint64)hdr.phyrec == size-1 && hdr.ktype & (HTREE_COMPRESSED_KEY|HTREE_QUICK_COMPRESSED_KEY))
{
NodeHdr root;
if (io->read(hdr.root, sizeof(root), &root) == sizeof(root))
Expand Down Expand Up @@ -164,7 +164,7 @@ extern jhtree_decl bool isIndexFile(IFile *file)
SwapBigEndian(hdr);

}
if (!hdr.root || !hdr.nodeSize || !hdr.root || size % hdr.nodeSize || hdr.phyrec != size-1 || hdr.root % hdr.nodeSize || hdr.root >= size)
if (!hdr.root || !hdr.nodeSize || !hdr.root || size % hdr.nodeSize || (__uint64)hdr.phyrec != size-1 || hdr.root % hdr.nodeSize || (__uint64)hdr.root >= size)
return false;
return true; // Reasonable heuristic...
}
Expand Down Expand Up @@ -330,7 +330,7 @@ bool CPOCWriteNode::add(offset_t pos, const void *data, size32_t size, unsigned
zlib_deflate(thisRowBuffer, tmp.toByteArray(), tmp.length(), GZ_DEFAULT_COMPRESSION, ZlibCompressionType::ZLIB_DEFLATE);
size32_t deflateLen = thisRowBuffer.length();
// This row will require keyedLen bytes for the key, deflateLen for the payload, and a short for the offset
if (hdr.keyBytes + keyedLen + deflateLen + sizeof(unsigned short) > maxBytes)
if (hdr.keyBytes + keyedLen + deflateLen + sizeof(unsigned short) > (size32_t)maxBytes)
return false;
payloadBuffer.append(deflateLen, thisRowBuffer.toByteArray());
offsets.append(prevLength);
Expand All @@ -355,7 +355,7 @@ void CPOCWriteNode::write(IFileIOStream *out, CRC32 *crc)
}
memcpy(keyPtr, payloadBuffer.toByteArray(), payloadBuffer.length());
keyPtr += payloadBuffer.length();
assert(keyPtr - nodeBuf == hdr.keyBytes + sizeof(NodeHdr));
assert((size_t)(keyPtr - nodeBuf) == hdr.keyBytes + sizeof(NodeHdr));
SplitNodeHdr *splitHdr = (SplitNodeHdr *) (nodeBuf + sizeof(NodeHdr));
splitHdr->firstSequence = firstSequence;
CWriteNode::write(out, crc);
Expand Down Expand Up @@ -411,7 +411,6 @@ bool CLegacyWriteNode::add(offset_t pos, const void *indata, size32_t insize, un
{
if (0xffff == hdr.numKeys)
return false;
bool lastnode = false;
assertex (indata);
//assertex(insize==keyLen);
const void *data;
Expand Down Expand Up @@ -558,7 +557,7 @@ void CBloomFilterWriteNode::put4(unsigned val)
unsigned short written;
_WINCPYREV2(&written, keyPtr);

assertex(written + sizeof(val) + sizeof(unsigned short) <= maxBytes);
assertex(written + sizeof(val) + sizeof(unsigned short) <= (size32_t)maxBytes);
_WINCPYREV4(keyPtr+sizeof(unsigned short)+written, &val);
written += sizeof(val);
_WINCPYREV2(keyPtr, &written);
Expand All @@ -570,7 +569,7 @@ void CBloomFilterWriteNode::put8(__int64 val)
unsigned short written;
_WINCPYREV2(&written, keyPtr);

assertex(written + sizeof(val) + sizeof(unsigned short) <= maxBytes);
assertex(written + sizeof(val) + sizeof(unsigned short) <= (size32_t)maxBytes);
_WINCPYREV8(keyPtr+sizeof(unsigned short)+written, &val);
written += sizeof(val);
_WINCPYREV2(keyPtr, &written);
Expand Down Expand Up @@ -1260,7 +1259,6 @@ void CJHTreeBlobNode::load(CKeyHdr *_keyHdr, const void *rawData, offset_t _fpos
{
CJHTreeNode::load(_keyHdr, rawData, _fpos, needCopy);
const byte *data = ((const byte *) rawData) + sizeof(hdr);
char keyType = keyHdr->getKeyType();
expandedSize = keyHdr->getNodeSize();
keyBuf = expandData(data, expandedSize);
}
Expand Down
104 changes: 2 additions & 102 deletions system/jhtree/jhinplace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,81 +267,6 @@ inline void skipPacked(const byte * & cur)
} while (next >= 0x80);
}

//----- special packed format - code is untested

inline unsigned getLeadingMask(byte extraBytes) { return (0x100U - (1U << (8-extraBytes))); }
inline unsigned getLeadingValueMask(byte extraBytes) { return (~getLeadingMask(extraBytes)) >> 1; }

static void serializePacked2(MemoryBuffer & out, size32_t value)
{
//Efficiency of serialization is not the key consideration
byte mask = 0;
unsigned size = sizePacked(value);
constexpr unsigned maxBytes = 9;
byte result[maxBytes];

for (unsigned i=1; i < size; i++)
{
result[maxBytes - i] = value;
value >>= 8;
mask = 0x80 | (mask >> 1);
}
unsigned start = maxBytes - size;
result[start] |= mask;
out.append(size, result + start);
}

inline unsigned numExtraBytesFromFirst1(byte first)
{
if (first >= 0xF0)
if (first >= 0xFC)
if (first >= 0xFE)
if (first >= 0xFF)
return 8;
else
return 7;
else
return 6;
else
if (first >= 0xF8)
return 5;
else
return 4;
else
if (first >= 0xC0)
if (first >= 0xE0)
return 3;
else
return 2;
else
return (first >> 7); // (first >= 0x80) ? 1 : 0
}

inline unsigned numExtraBytesFromFirst2(byte first)
{
//Surely should be faster, but seems slower on AMD. Retest in its actual context
unsigned value = first;
return countLeadingUnsetBits(~(value << 24));
}

inline unsigned numExtraBytesFromFirst(byte first)
{
return numExtraBytesFromFirst1(first);
}

inline unsigned readPacked2(const byte * & cur)
{
byte first = *cur++;
unsigned extraBytes = numExtraBytesFromFirst(first);
unsigned value = first & getLeadingValueMask(extraBytes);
while (extraBytes--)
{
value <<= 8;
value |= *cur++;
}
return value;
}

//-------------------

static unsigned bytesRequired(unsigned __int64 value)
Expand Down Expand Up @@ -828,7 +753,6 @@ bool PartialMatch::squash()

//Always squash if you have some text - avoids length calculation elsewhere
size32_t startOffset = isRoot ? 0 : 1;
size32_t keyLen = builder->queryKeyLen();
if (data.length() > startOffset)
{
const byte * source = data.bytes();
Expand All @@ -837,7 +761,6 @@ bool PartialMatch::squash()
unsigned copyOffset = startOffset;
unsigned repeatCount = 0;
byte prevByte = 0;
const byte * nullRow = queryNullRow();
for (unsigned offset = startOffset; offset < maxOffset; offset++)
{
byte nextByte = source[offset];
Expand Down Expand Up @@ -1550,7 +1473,6 @@ size32_t InplaceNodeSearcher::getValueAt(unsigned int searchIndex, char *key) co
return 0;

unsigned resultPrev = 0;
unsigned resultNext = count;
const byte * finger = nodeData;
unsigned offset = 0;

Expand Down Expand Up @@ -1643,7 +1565,6 @@ size32_t InplaceNodeSearcher::getValueAt(unsigned int searchIndex, char *key) co
const byte nextFinger = getOptionValue(sizeInfo, finger, option);
key[offset++] = nextFinger;

resultNext = resultPrev + countNext;
resultPrev = resultPrev + countPrev;

const byte * offsets = counts + numOptions * bytesPerCount;
Expand Down Expand Up @@ -2100,7 +2021,7 @@ bool CInplaceBranchWriteNode::add(offset_t pos, const void * _data, size32_t siz
if (scaleFposByNodeSize && ((pos % nodeSize) != 0))
scaleFposByNodeSize = false;

if (getDataSize() > maxBytes)
if (getDataSize() > (size32_t)maxBytes)
{
builder.removeLast();
positions.pop();
Expand Down Expand Up @@ -2279,7 +2200,7 @@ bool CInplaceLeafWriteNode::add(offset_t pos, const void * _data, size32_t size,
payloadLengths.append(extraSize);

size32_t required = getDataSize(true);
bool hasSpace = (required <= maxBytes);
bool hasSpace = (required <= (size32_t)maxBytes);
if ((keyLen != keyCompareLen) && ctx.compressionHandler)
{
// The following approach is used for compressing payloads:
Expand Down Expand Up @@ -2696,30 +2617,9 @@ static int normalizeCompare(int x)
class InplaceIndexTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( InplaceIndexTest );
//CPPUNIT_TEST(testBytesFromFirstTiming);
CPPUNIT_TEST(testSearching);
CPPUNIT_TEST_SUITE_END();

void testBytesFromFirstTiming()
{
for (unsigned i=0; i <= 0xff; i++)
assertex(numExtraBytesFromFirst1(i) == numExtraBytesFromFirst2(i));
unsigned total = 0;
{
CCycleTimer timer;
for (unsigned i=0; i < 0xffffff; i++)
total += numExtraBytesFromFirst1(i);
printf("%llu\n", timer.elapsedNs());
}
{
CCycleTimer timer;
for (unsigned i2=0; i2 < 0xffffff; i2++)
total += numExtraBytesFromFirst2(i2);
printf("%llu\n", timer.elapsedNs());
}
printf("%u\n", total);
}

void testSearching()
{
const size32_t keyLen = 8;
Expand Down
8 changes: 2 additions & 6 deletions system/jhtree/jhtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static std::atomic<CKeyStore *> keyStore(nullptr);
static unsigned defaultKeyIndexLimit = 200;
static CNodeCache *nodeCache = NULL;
static CriticalSection *initCrit = NULL;
static __uint64 fetchThresholdCycles = 0;
static cycle_t fetchThresholdCycles = 0;

bool useMemoryMappedIndexes = false;
bool linuxYield = false;
Expand Down Expand Up @@ -329,8 +329,6 @@ void SegMonitorList::append(IKeySegmentMonitor *segment)
{
modified = true;
unsigned fieldIdx = segment->queryFieldIndex();
unsigned offset = segment->getOffset();
unsigned size = segment->getSize();
while (segMonitors.length() < fieldIdx)
{
unsigned idx = segMonitors.length();
Expand Down Expand Up @@ -2871,7 +2869,7 @@ class CKeyMerger : public CKeyLevelManager
break;
}
}
if (sortFromSeg == -1)
if (sortFromSeg == (unsigned)-1)
assertex(!"Attempting to sort from offset that is not on a segment boundary");
assertex(resetPending == true);
}
Expand Down Expand Up @@ -3475,7 +3473,6 @@ class IKeyManagerSlowTest : public CppUnit::TestFixture

tlk1->reset();

offset_t fpos;
ASSERT(tlk1->lookup(true)); ASSERT(memcmp(tlk1->queryKeyBuffer(), "0000003010", 10)==0);
ASSERT(tlk1->lookup(true)); ASSERT(memcmp(tlk1->queryKeyBuffer(), "0000005010", 10)==0);
ASSERT(tlk1->lookup(true)); ASSERT(memcmp(tlk1->queryKeyBuffer(), "0000006010", 10)==0);
Expand Down Expand Up @@ -3764,7 +3761,6 @@ class IKeyManagerSlowTest : public CppUnit::TestFixture
unsigned i;
for (pass = 0; pass < 2; pass++)
{
offset_t fpos;
tlk1->reset();
ASSERT(tlk1->lookup(true)); ASSERT(memcmp(tlk1->queryKeyBuffer(), "0000000001", 10)==0);
ASSERT(tlk1->lookup(true)); ASSERT(memcmp(tlk1->queryKeyBuffer(), "0000000002", 10)==0);
Expand Down
Loading

0 comments on commit 7992afd

Please sign in to comment.