Fix warnings.

This commit is contained in:
vng 2011-10-12 18:11:40 +03:00 committed by Alex Zolotarev
parent e9d70dae6e
commit fafe45cbbf
11 changed files with 28 additions and 27 deletions

View file

@ -28,7 +28,7 @@ TArchive & operator >> (TArchive & ar, pair<T1, T2> & t)
template <class TArchive, class TCont> void save_like_map(TArchive & ar, TCont const & rMap)
{
uint32_t const count = rMap.size();
uint32_t const count = static_cast<uint32_t>(rMap.size());
ar << count;
for (typename TCont::const_iterator i = rMap.begin(); i != rMap.end(); ++i)
@ -56,7 +56,7 @@ template <class TArchive, class TCont> void load_like_map(TArchive & ar, TCont &
template <class TArchive, class TCont> void save_like_vector(TArchive & ar, TCont const & rCont)
{
uint32_t const count = rCont.size();
uint32_t const count = static_cast<uint32_t>(rCont.size());
ar << count;
for (uint32_t i = 0; i < count; ++i)

View file

@ -21,14 +21,15 @@ public:
m_p += size;
}
const void * Ptr() const {
return m_p;
}
inline const void * Ptr() const { return m_p; }
inline const unsigned char * PtrUC() const { return m_p; }
inline const char * PtrC() const { return static_cast<char const *>(Ptr()); }
void Advance(size_t size)
{
m_p += size;
}
private:
const unsigned char * m_p;
};

View file

@ -14,7 +14,7 @@ namespace
WriteVarUint(dst, x);
ArrayByteSource src(&data[0]);
TEST_EQUAL(ReadVarUint<T>(src), x, ());
size_t const bytesRead = static_cast<const unsigned char*>(src.Ptr()) - &data[0];
size_t const bytesRead = src.PtrUC() - &data[0];
TEST_EQUAL(bytesRead, data.size(), (x));
}
@ -25,7 +25,7 @@ namespace
WriteVarInt(dst, x);
ArrayByteSource src(&data[0]);
TEST_EQUAL(ReadVarInt<T>(src), x, ());
size_t const bytesRead = static_cast<const unsigned char*>(src.Ptr()) - &data[0];
size_t const bytesRead = src.PtrUC() - &data[0];
TEST_EQUAL(bytesRead, data.size(), (x));
}
}

View file

@ -28,7 +28,7 @@ namespace stream
template <class TStream, class TWriter>
void WriteString(TStream & s, TWriter & w, string const & t)
{
uint32_t const count = t.size();
uint32_t const count = static_cast<uint32_t>(t.size());
s << count;
if (count > 0)
w.Write(t.c_str(), count);

View file

@ -40,7 +40,7 @@ public:
m_Reader.Read(pos, &buffer[0], initialSize);
ArrayByteSource source(&buffer[0]);
uint32_t const recordSize = VarRecordSizeReaderFn(source);
uint32_t const recordSizeSize = static_cast<char const *>(source.Ptr()) - &buffer[0];
uint32_t const recordSizeSize = static_cast<uint32_t>(source.PtrC() - &buffer[0]);
uint32_t const fullSize = recordSize + recordSizeSize;
ASSERT_LESS_OR_EQUAL(pos + fullSize, m_ReaderSize, ());
buffer.resize(fullSize);

View file

@ -13,7 +13,7 @@ inline void SplitRectCell(CellIdT id,
CoordT maxX, CoordT maxY,
vector<CellIdT> & result)
{
for (size_t i = 0; i < 4; ++i)
for (int8_t i = 0; i < 4; ++i)
{
CellIdT child = id.Child(i);
CoordT minCellX, minCellY, maxCellX, maxCellY;

View file

@ -142,11 +142,11 @@ void LoaderCurrent::ParseHeader2()
m_ptsSimpMask += (mask << (i << 3));
}
char const * start = static_cast<char const *>(src.Ptr());
char const * start = src.PtrC();
src = ArrayByteSource(serial::LoadInnerPath(src.Ptr(), ptsCount, cp, m_pF->m_Points));
src = ArrayByteSource(serial::LoadInnerPath(start, ptsCount, cp, m_pF->m_Points));
m_pF->m_InnerStats.m_Points = static_cast<char const *>(src.Ptr()) - start;
m_pF->m_InnerStats.m_Points = src.PtrC() - start;
}
else
{
@ -162,12 +162,12 @@ void LoaderCurrent::ParseHeader2()
{
trgCount += 2;
char const * start = static_cast<char const *>(src.Ptr());
char const * start = static_cast<char const *>(src.PtrC());
FeatureType::points_t points;
src = ArrayByteSource(serial::LoadInnerTriangles(src.Ptr(), trgCount, cp, points));
src = ArrayByteSource(serial::LoadInnerTriangles(start, trgCount, cp, points));
m_pF->m_InnerStats.m_Strips = static_cast<char const *>(src.Ptr()) - start;
m_pF->m_InnerStats.m_Strips = src.PtrC() - start;
for (uint8_t i = 2; i < trgCount; ++i)
{
@ -180,7 +180,7 @@ void LoaderCurrent::ParseHeader2()
ReadOffsets(src, trgMask, m_trgOffsets);
}
m_pF->m_InnerStats.m_Size = static_cast<char const *>(src.Ptr()) - DataPtr();
m_pF->m_InnerStats.m_Size = src.PtrC() - DataPtr();
}
uint32_t LoaderCurrent::ParseGeometry(int scale)

View file

@ -77,7 +77,7 @@ void LoaderBase::Deserialize(BufferT data)
uint32_t LoaderBase::CalcOffset(ArrayByteSource const & source) const
{
return static_cast<uint32_t>(static_cast<char const *>(source.Ptr()) - DataPtr());
return static_cast<uint32_t>(source.PtrC() - DataPtr());
}
}

View file

@ -77,7 +77,7 @@ namespace serial
template <class TSink>
void WriteBufferToSink(vector<char> const & buffer, TSink & sink)
{
uint32_t const count = buffer.size();
uint32_t const count = static_cast<uint32_t>(buffer.size());
WriteVarUint(sink, count);
sink.Write(&buffer[0], count);
}

View file

@ -247,12 +247,12 @@ void LoaderImpl::ParseHeader2()
m_ptsSimpMask += (mask << (i << 3));
}
char const * start = static_cast<char const *>(src.Ptr());
char const * start = src.PtrC();
src = ArrayByteSource(serial::LoadInnerPath(
src.Ptr(), ptsCount, GetDefCodingParams(), m_pF->m_Points));
start, ptsCount, GetDefCodingParams(), m_pF->m_Points));
m_pF->m_InnerStats.m_Points = static_cast<char const *>(src.Ptr()) - start;
m_pF->m_InnerStats.m_Points = src.PtrC() - start;
}
else
ReadOffsets(src, ptsMask, m_ptsOffsets);
@ -264,13 +264,13 @@ void LoaderImpl::ParseHeader2()
{
trgCount += 2;
char const * start = static_cast<char const *>(src.Ptr());
char const * start = src.PtrC();
FeatureType::points_t points;
src = ArrayByteSource(serial::LoadInnerTriangles(
src.Ptr(), trgCount, GetDefCodingParams(), points));
start, trgCount, GetDefCodingParams(), points));
m_pF->m_InnerStats.m_Strips = static_cast<char const *>(src.Ptr()) - start;
m_pF->m_InnerStats.m_Strips = src.PtrC() - start;
for (uint8_t i = 2; i < trgCount; ++i)
{
@ -283,7 +283,7 @@ void LoaderImpl::ParseHeader2()
ReadOffsets(src, trgMask, m_trgOffsets);
}
m_pF->m_InnerStats.m_Size = static_cast<char const *>(src.Ptr()) - DataPtr();
m_pF->m_InnerStats.m_Size = src.PtrC() - DataPtr();
}
uint32_t LoaderImpl::ParseGeometry(int scale)

View file

@ -86,7 +86,7 @@ void sl::SlofDictionary::ArticleById(sl::Dictionary::Id id, string & article) co
m_pReader->Read(m_Header.m_ArticleOffset + articleChunkPos + 4, &chunk[0], chunkSize);
ArrayByteSource chunkSource(&chunk[0]);
uint32_t chunkHeaderSize = ReadVarUint<uint32_t>(chunkSource);
chunkHeaderSize += static_cast<char const *>(chunkSource.Ptr()) - &chunk[0];
chunkHeaderSize += (chunkSource.PtrC() - &chunk[0]);
uint32_t const decompressedChunkSize = ReadVarUint<uint32_t>(chunkSource);
uint32_t articleBegInChunk = 0;
for (uint32_t i = 0; i < articleNumInChunk; ++i)