#At file:///G:/bzr/mysql-6.0-falcon-team/
2895 Vladislav Vaintroub 2008-10-31
Eliminate compile warnings on Windows 64 bit.
(~2800 non-unique from falcon)
-Most of the warnings is about size_t to int truncation in memory manager.
Changed MemMgr function prototypes to accept size_t lengths.
alloc() will now assert if the size is more then 2GB.
(falcon cannot allocate more at once because it tracks size of each allocation
with an "int")
- the rest of the warnings seems harmless and solved mostly with casts.
modified:
storage/falcon/BlobReference.cpp
storage/falcon/Cache.cpp
storage/falcon/CollationCaseless.cpp
storage/falcon/DateTime.cpp
storage/falcon/EditString.cpp
storage/falcon/EncodedDataStream.cpp
storage/falcon/Filter.cpp
storage/falcon/FilterSet.cpp
storage/falcon/FsbSort.cpp
storage/falcon/IndexRootPage.cpp
storage/falcon/MemMgr.cpp
storage/falcon/MemMgr.h
storage/falcon/MemoryManager.h
storage/falcon/SerialLogFile.cpp
storage/falcon/Serialize.cpp
storage/falcon/ha_falcon.cpp
=== modified file 'storage/falcon/BlobReference.cpp'
--- a/storage/falcon/BlobReference.cpp 2008-06-19 15:09:45 +0000
+++ b/storage/falcon/BlobReference.cpp 2008-10-31 13:57:54 +0000
@@ -157,5 +157,5 @@ int BlobReference::getReference(int size
for (n = 0; n < 64; n += 8)
*q++ = (UCHAR) (blobId >> n);
- return q - buffer;
+ return (int)(q - buffer);
}
=== modified file 'storage/falcon/Cache.cpp'
--- a/storage/falcon/Cache.cpp 2008-10-30 00:22:54 +0000
+++ b/storage/falcon/Cache.cpp 2008-10-31 13:57:54 +0000
@@ -852,7 +852,7 @@ void Cache::ioThread(void)
flushLock.unlock();
//Log::debug(" %d Writing %s %d pages: %d - %d\n", thread->threadId, (const
char*) dbb->fileName, count, pageNumber, pageNumber + count - 1);
- int length = p - buffer;
+ int length = (int)(p - buffer);
priority.schedule(PRIORITY_LOW);
try
=== modified file 'storage/falcon/CollationCaseless.cpp'
--- a/storage/falcon/CollationCaseless.cpp 2008-05-14 18:39:57 +0000
+++ b/storage/falcon/CollationCaseless.cpp 2008-10-31 13:57:54 +0000
@@ -98,7 +98,7 @@ int CollationCaseless::makeKey(Value *va
while (q > p && q [-1] == ' ')
--q;
- l = q - p;
+ l = (int)(q - p);
for (int n = 0; n < l; ++n)
p [n] = caseTable [p [n]];
=== modified file 'storage/falcon/DateTime.cpp'
--- a/storage/falcon/DateTime.cpp 2008-06-19 15:09:45 +0000
+++ b/storage/falcon/DateTime.cpp 2008-10-31 13:57:54 +0000
@@ -626,7 +626,7 @@ int DateTime::lookup(const char *string,
for (const char **tbl = table; *tbl; ++tbl)
if (match (temp, *tbl))
- return tbl - table;
+ return (int)(tbl - table);
return -1;
}
@@ -660,7 +660,7 @@ int DateTime::getString(int length, char
time.tm_mon + 1,
time.tm_mday);
- return strlen (buffer);
+ return (int)strlen (buffer);
}
@@ -1056,7 +1056,7 @@ int DateTime::compare(DateTime when)
DateTime DateTime::convert(const char *string)
{
- return convert (string, strlen (string));
+ return convert (string, (int)strlen (string));
}
const char* DateTime::getTimeZone()
@@ -1143,7 +1143,7 @@ int Time::getString(int length, char *bu
time.tm_min,
time.tm_sec);
- return strlen (buffer);
+ return (int)strlen (buffer);
}
const TimeZone* DateTime::findTimeZone(const char *string)
=== modified file 'storage/falcon/EditString.cpp'
--- a/storage/falcon/EditString.cpp 2008-05-14 18:39:57 +0000
+++ b/storage/falcon/EditString.cpp 2008-10-31 13:57:54 +0000
@@ -367,8 +367,8 @@ char* EditString::formatString(Value * v
{
char *temp;
const char *from = value->getString (&temp);
- int fromLength = strlen (from);
- int fpos = 0, tpos = 0;
+ size_t fromLength = strlen (from);
+ size_t fpos = 0, tpos = 0;
char c;
reset();
=== modified file 'storage/falcon/EncodedDataStream.cpp'
--- a/storage/falcon/EncodedDataStream.cpp 2008-05-30 15:40:29 +0000
+++ b/storage/falcon/EncodedDataStream.cpp 2008-10-31 13:57:54 +0000
@@ -1358,7 +1358,7 @@ void EncodedDataStream::encodeOpaque(int
void EncodedDataStream::encodeEncoding(const UCHAR *encodedValue)
{
const UCHAR *p = skip(encodedValue);
- stream->putSegment(p - encodedValue, (const char*) encodedValue, true);
+ stream->putSegment((int)(p - encodedValue), (const char*) encodedValue, true);
}
INT64 EncodedDataStream::getInt64(int requiredScale)
=== modified file 'storage/falcon/Filter.cpp'
--- a/storage/falcon/Filter.cpp 2008-05-14 18:39:57 +0000
+++ b/storage/falcon/Filter.cpp 2008-10-31 13:57:54 +0000
@@ -133,7 +133,7 @@ int Filter::getWord(int bufferLength, ch
*q = 0;
- return q - buffer;
+ return (int)(q - buffer);
}
void Filter::start()
=== modified file 'storage/falcon/FilterSet.cpp'
--- a/storage/falcon/FilterSet.cpp 2008-05-14 18:39:57 +0000
+++ b/storage/falcon/FilterSet.cpp 2008-10-31 13:57:54 +0000
@@ -152,5 +152,5 @@ JString FilterSet::stripSQL(const char *
while (end > sql && end [-1] != ')')
--end;
- return JString (sql, end - sql);
+ return JString (sql, (int)(end - sql));
}
=== modified file 'storage/falcon/FsbSort.cpp'
--- a/storage/falcon/FsbSort.cpp 2008-05-14 18:39:57 +0000
+++ b/storage/falcon/FsbSort.cpp 2008-10-31 13:57:54 +0000
@@ -69,7 +69,7 @@ FsbSort::FsbSort(CompiledStatement *stat
int *ptr = contextIds;
getStreams(&ptr);
- numberContexts = ptr - contextIds;
+ numberContexts = (int)(ptr - contextIds);
}
FsbSort::~FsbSort()
=== modified file 'storage/falcon/IndexRootPage.cpp'
--- a/storage/falcon/IndexRootPage.cpp 2008-08-25 22:09:13 +0000
+++ b/storage/falcon/IndexRootPage.cpp 2008-10-31 13:57:54 +0000
@@ -1198,7 +1198,7 @@ void IndexRootPage::positionIndex(Dbb* d
offset = page->computePrefix (key, highKey);
}
- walkIndex->setNodes(page->nextPage, page->length - ((UCHAR*) node.node -
(UCHAR*) page->nodes), node.node);
+ walkIndex->setNodes(page->nextPage, page->length - (int)((UCHAR*) node.node -
(UCHAR*) page->nodes), node.node);
bdb->release(REL_HISTORY);
}
=== modified file 'storage/falcon/MemMgr.cpp'
--- a/storage/falcon/MemMgr.cpp 2008-08-20 16:28:44 +0000
+++ b/storage/falcon/MemMgr.cpp 2008-10-31 13:57:54 +0000
@@ -55,7 +55,7 @@
#include "LogStream.h"
#endif
-static const int guardBytes = sizeof(long); // * 2048;
+static const size_t guardBytes = sizeof(long); // * 2048;
#ifndef ASSERT
#define ASSERT
@@ -112,7 +112,7 @@ struct Client {
};
#ifdef _DEBUG
- void* MemMgrPoolAllocateDebug (MemMgr *pool, unsigned int s, const char *file, int line)
+ void* MemMgrPoolAllocateDebug (MemMgr *pool, size_t s, const char *file, int line)
{
void *object = pool->allocateDebug(s, file, line);
@@ -120,12 +120,12 @@ struct Client {
printf("MemMgrAllocateDebug at %p\n", stopAddress);
if (traceFile)
- fprintf(traceFile, "a %d %p\n", s, object);
+ fprintf(traceFile, "a " I64FORMAT " %p\n", (int64)s, object);
return object;
}
- void* MemMgrAllocateDebug (unsigned int s, const char *file, int line)
+ void* MemMgrAllocateDebug (size_t s, const char *file, int line)
{
if(!memoryManagerAlive)
return malloc(s);
@@ -136,7 +136,7 @@ struct Client {
printf("MemMgrAllocateDebug at %p\n", stopAddress);
if (traceFile)
- fprintf(traceFile, "a %d %p\n", s, object);
+ fprintf(traceFile, "a " I64FORMAT " %p\n", (int64)s, object);
return object;
}
@@ -159,7 +159,7 @@ struct Client {
memoryManager.releaseDebug (object);
}
- void* MemMgrRecordAllocate (int size, const char *file, int line)
+ void* MemMgrRecordAllocate (size_t size, const char *file, int line)
{
return recordManager.allocateDebug (size, file, line);
}
@@ -169,12 +169,12 @@ struct Client {
recordManager.releaseDebug (record);
}
#else
- void* MemMgrPoolAllocate (MemMgr *pool, unsigned int s)
+ void* MemMgrPoolAllocate (MemMgr *pool, size_t s)
{
return pool->allocate (s);
}
- void* MemMgrAllocate (unsigned int s)
+ void* MemMgrAllocate (size_t s)
{
if(!memoryManagerAlive)
return malloc(s);
@@ -190,7 +190,7 @@ struct Client {
memoryManager.release (object);
}
- void* MemMgrRecordAllocate (int size, const char *file, int line)
+ void* MemMgrRecordAllocate (size_t size, const char *file, int line)
{
return recordManager.allocate (size);
}
@@ -346,10 +346,13 @@ MemMgr::~MemMgr(void)
*isAlive = false;
}
-MemBlock* MemMgr::alloc(int length)
+MemBlock* MemMgr::alloc(size_t s)
{
- if (length <= 0)
- throw SQLError (RUNTIME_ERROR, "illegal memory allocate for %d bytes", length);
+ if(s > INT_MAX)
+ throw SQLError (RUNTIME_ERROR, "illegal memory allocate for " I64FORMAT " bytes",
+ (int64)s);
+
+ int length = (int) s;
Sync sync (&mutex, "MemMgr::alloc");
sync.lock(Exclusive);
@@ -522,9 +525,9 @@ MemBlock* MemMgr::alloc(int length)
return block;
}
-void* MemMgr::allocate(int size)
+void* MemMgr::allocate(size_t size)
{
- int length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
+ size_t length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
MemBlock *memory;
ASSERT(signature == defaultSignature);
@@ -547,9 +550,9 @@ void* MemMgr::allocate(int size)
return &memory->body;
}
-void* MemMgr::allocateDebug(int size, const char* fileName, int line)
+void* MemMgr::allocateDebug(size_t size, const char* fileName, int line)
{
- int length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
+ size_t length = ROUNDUP(size, roundingSize) + OFFSET(MemBlock*, body) + guardBytes;
MemBlock *memory;
ASSERT(signature == defaultSignature);
@@ -563,7 +566,7 @@ void* MemMgr::allocateDebug(int size, co
#endif
memset (&memory->body, INIT_BYTE, size);
- int l = ABS(memory->length) - size - OFFSET(MemBlock*,body);
+ size_t l = ABS(memory->length) - size - OFFSET(MemBlock*,body);
ASSERT(l >= guardBytes && l < length - size + guardBytes + (int) sizeof
(MemFreeBlock));
memset (&memory->body + size, GUARD_BYTE, l);
++blocksAllocated;
=== modified file 'storage/falcon/MemMgr.h'
--- a/storage/falcon/MemMgr.h 2008-08-06 11:53:21 +0000
+++ b/storage/falcon/MemMgr.h 2008-10-31 13:57:54 +0000
@@ -19,6 +19,7 @@
#include "Mutex.h"
#include "SyncObject.h"
+#include <limits.h>
#ifndef MEM_DEBUG
@@ -135,12 +136,12 @@ public:
friend void MemMgrLogDump();
protected:
- MemBlock* alloc(int size);
+ MemBlock* alloc(size_t size);
static void corrupt(const char* text);
public:
- void* allocate(int size);
- void* allocateDebug(int size, const char* fileName, int line);
+ void* allocate(size_t size);
+ void* allocateDebug(size_t size, const char* fileName, int line);
void releaseBlock(MemBlock *block);
void validateBlock(MemBlock *block);
void analyze (int mask, Stream *stream, InfoTable *summaryTable, InfoTable
*detailTable);
=== modified file 'storage/falcon/MemoryManager.h'
--- a/storage/falcon/MemoryManager.h 2008-09-14 20:12:37 +0000
+++ b/storage/falcon/MemoryManager.h 2008-10-31 13:57:54 +0000
@@ -43,35 +43,35 @@ class MemMgr;
struct MemObject;
#ifdef _DEBUG
- extern void* MemMgrAllocateDebug (unsigned int s, const char *file, int line);
- extern void* MemMgrPoolAllocateDebug (MemMgr *pool, unsigned int s, const char *file,
int line);
+ extern void* MemMgrAllocateDebug (size_t s, const char *file, int line);
+ extern void* MemMgrPoolAllocateDebug (MemMgr *pool, size_t s, const char *file, int
line);
WINSTATIC ALWAYS_INLINE void* operator new(size_t s) THROWS_BAD_ALLOC
- { return MemMgrAllocateDebug ((unsigned int) s, __FILE__, __LINE__); }
+ { return MemMgrAllocateDebug (s, __FILE__, __LINE__); }
WINSTATIC ALWAYS_INLINE void* operator new(size_t s, const int &n)
- { return MemMgrAllocateDebug ((unsigned int) s, __FILE__, __LINE__); }
+ { return MemMgrAllocateDebug (s, __FILE__, __LINE__); }
WINSTATIC ALWAYS_INLINE void* operator new(size_t s, const char *file, int line)
- { return MemMgrAllocateDebug ((unsigned int) s, file, line); }
+ { return MemMgrAllocateDebug (s, file, line); }
WINSTATIC ALWAYS_INLINE void* operator new[](size_t s) THROWS_BAD_ALLOC
- { return MemMgrAllocateDebug ((unsigned int) s, __FILE__, __LINE__); }
+ { return MemMgrAllocateDebug (s, __FILE__, __LINE__); }
WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, const char *file, int line)
THROWS_BAD_ALLOC
- { return MemMgrAllocateDebug ((unsigned int) s, file, line); }
+ { return MemMgrAllocateDebug (s, file, line); }
WINSTATIC ALWAYS_INLINE void* operator new(size_t s, MemMgr *pool) THROWS_BAD_ALLOC
- { return MemMgrPoolAllocateDebug (pool, (unsigned int) s, __FILE__, __LINE__); }
+ { return MemMgrPoolAllocateDebug (pool, s, __FILE__, __LINE__); }
WINSTATIC ALWAYS_INLINE void* operator new(size_t s, MemMgr *pool, const char *file, int
line)
- { return MemMgrPoolAllocateDebug (pool, (unsigned int) s, file, line); }
+ { return MemMgrPoolAllocateDebug (pool, s, file, line); }
WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, MemMgr *pool) THROWS_BAD_ALLOC
{ return MemMgrPoolAllocateDebug (pool, (unsigned int) s, __FILE__, __LINE__); }
WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, MemMgr *pool, const char *file,
int line)
- { return MemMgrPoolAllocateDebug (pool, (unsigned int) s, file, line); }
+ { return MemMgrPoolAllocateDebug (pool, s, file, line); }
#define POOL_NEW(arg) new(arg, THIS_FILE, __LINE__)
#define NEW new (THIS_FILE, __LINE__)
@@ -81,8 +81,8 @@ struct MemObject;
#endif
#else
- extern void* MemMgrAllocate (unsigned int s);
- extern void* MemMgrPoolAllocate (MemMgr *pool, unsigned int s);
+ extern void* MemMgrAllocate (size_t s);
+ extern void* MemMgrPoolAllocate (MemMgr *pool, size_t s);
WINSTATIC ALWAYS_INLINE void* operator new(size_t s) THROWS_BAD_ALLOC
{ return MemMgrAllocate (s); }
@@ -91,7 +91,7 @@ struct MemObject;
{ return ::MemMgrPoolAllocate (pool, s); }
WINSTATIC ALWAYS_INLINE void* operator new[](size_t s, MemMgr *pool) THROWS_BAD_ALLOC
- { return ::MemMgrPoolAllocate (pool, s); }
+ { return ::MemMgrPoolAllocate (pool,s); }
WINSTATIC ALWAYS_INLINE void* operator new(size_t s, const int &n) THROWS_BAD_ALLOC
{ return ::MemMgrAllocate (s); }
@@ -118,7 +118,7 @@ extern void MemMgrAnalyze(MemMgrWhat wh
extern void MemMgrRelease (void *object);
extern void MemMgrValidate (void *object);
extern void MemMgrAnalyze(int mask, Stream *stream);
-extern void* MemMgrRecordAllocate (int size, const char *file, int line);
+extern void* MemMgrRecordAllocate (size_t size, const char *file, int line);
extern void MemMgrRecordDelete (char *record);
extern void MemMgrSetMaxRecordMember (long long size);
extern MemMgr* MemMgrGetFixedPool (int id);
=== modified file 'storage/falcon/SerialLogFile.cpp'
--- a/storage/falcon/SerialLogFile.cpp 2008-10-31 10:26:35 +0000
+++ b/storage/falcon/SerialLogFile.cpp 2008-10-31 13:57:54 +0000
@@ -370,7 +370,7 @@ void SerialLogFile::zap()
UCHAR *junk = new UCHAR[initialSize +sectorSize];
UCHAR *buffer = ALIGN(junk, sectorSize);
memset(buffer, 0, initialSize);
- write(0, initialSize, (SerialLogBlock*) buffer);
+ write(0, (uint32) initialSize, (SerialLogBlock*) buffer);
delete junk;
}
=== modified file 'storage/falcon/Serialize.cpp'
--- a/storage/falcon/Serialize.cpp 2008-02-25 22:27:17 +0000
+++ b/storage/falcon/Serialize.cpp 2008-10-31 13:57:54 +0000
@@ -82,7 +82,7 @@ void Serialize::putInt(int value)
*p++ = (value >> (lengthShifts [count])) & 0x7f;
*p++ = value | LOW_BYTE_FLAG;
- release(p - data);
+ release((uint)(p - data));
}
void Serialize::putInt64(int64 value)
@@ -95,7 +95,7 @@ void Serialize::putInt64(int64 value)
*p++ = (UCHAR) (value >> (lengthShifts [count])) & 0x7f;
*p++ = ((UCHAR) value) | LOW_BYTE_FLAG;
- release(p - data);
+ release((uint)(p - data));
}
void Serialize::putData(uint length, const UCHAR* data)
=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp 2008-10-29 23:25:13 +0000
+++ b/storage/falcon/ha_falcon.cpp 2008-10-31 13:57:54 +0000
@@ -344,7 +344,7 @@ uint falcon_strnxfrmlen(void *cs, const
uint chrLen = falcon_strnchrlen(cs, s, srcLen);
int maxChrLen = partialKey ? min(chrLen, partialKey / charset->mbmaxlen) : chrLen;
- return min(charset->coll->strnxfrmlen(charset, maxChrLen * charset->mbmaxlen),
(uint) bufSize);
+ return (uint)min(charset->coll->strnxfrmlen(charset, maxChrLen *
charset->mbmaxlen), (uint) bufSize);
}
// Return the number of bytes used in s to hold a certain number of characters.
@@ -372,7 +372,7 @@ uint falcon_strntrunc(void *cs, int part
charLimit--;
}
- return ch - (uchar *) s;
+ return (uint)(ch - (uchar *) s);
}
int falcon_strnncoll(void *cs, const char *s1, uint l1, const char *s2, uint l2, char
flag)
@@ -3006,10 +3006,10 @@ bool StorageInterface::get_error_message
if (storageConnection)
{
const char *text = storageConnection->getLastErrorString();
- buf->set(text, strlen(text), system_charset_info);
+ buf->set(text, (uint32)strlen(text), system_charset_info);
}
else if (errorText)
- buf->set(errorText, strlen(errorText), system_charset_info);
+ buf->set(errorText, (uint32)strlen(errorText), system_charset_info);
return false;
}