From 3848db2389318c41b7c29a74cf9e5f2ba7e331dc Mon Sep 17 00:00:00 2001 From: Sergey Yershov Date: Tue, 17 Mar 2015 16:04:42 +0300 Subject: [PATCH] fixed warning in [indexer] --- coding/dd_vector.hpp | 4 ++-- coding/file_sort.hpp | 2 +- geometry/simplification.hpp | 2 +- indexer/classificator.cpp | 2 +- indexer/data_header.cpp | 2 +- indexer/drawing_rules.cpp | 8 ++++---- indexer/feature_loader.cpp | 9 +++++---- indexer/old/feature_loader_101.cpp | 12 ++++++------ indexer/scale_index.hpp | 2 +- 9 files changed, 22 insertions(+), 21 deletions(-) diff --git a/coding/dd_vector.hpp b/coding/dd_vector.hpp index 255822a984..7b0e2df879 100644 --- a/coding/dd_vector.hpp +++ b/coding/dd_vector.hpp @@ -15,7 +15,7 @@ template < typename T, class TReader, typename TSize = uint32_t, - typename TDifference = typename make_signed::type + typename TDifference = ptrdiff_t > class DDVector { public: @@ -170,7 +170,7 @@ private: if ((sz % sizeof(T)) != 0) MYTHROW(OpenException, (sz, sizeof(T))); - m_Size = sz / sizeof(T); + m_Size = static_cast(sz / sizeof(T)); } // TODO: Refactor me to use Reader by pointer. diff --git a/coding/file_sort.hpp b/coding/file_sort.hpp index a2ed575759..98de10136c 100644 --- a/coding/file_sort.hpp +++ b/coding/file_sort.hpp @@ -132,7 +132,7 @@ private: } string const m_TmpFileName; - uint32_t const m_BufferCapacity; + size_t const m_BufferCapacity; OutputSinkT & m_OutputSink; unique_ptr m_pTmpWriter; vector m_Buffer; diff --git a/geometry/simplification.hpp b/geometry/simplification.hpp index 85b227151f..beda67df76 100644 --- a/geometry/simplification.hpp +++ b/geometry/simplification.hpp @@ -90,7 +90,7 @@ template void SimplifyNearOptimal(int kMaxFalseLookAhead, IterT beg, IterT end, double epsilon, DistanceF dist, OutT out) { - int32_t const n = end - beg; + int32_t const n = static_cast(end - beg); if (n <= 2) { for (IterT it = beg; it != end; ++it) diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index f89b2aeb89..9220c5d201 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -328,7 +328,7 @@ pair ClassifObject::GetDrawScaleRange() const if (!IsDrawableAny()) return make_pair(-1, -1); - size_t const count = m_visibility.size(); + int const count = static_cast(m_visibility.size()); int left = -1; for (int i = 0; i < count; ++i) diff --git a/indexer/data_header.cpp b/indexer/data_header.cpp index a6f2c413bf..c07ed87de7 100644 --- a/indexer/data_header.cpp +++ b/indexer/data_header.cpp @@ -59,7 +59,7 @@ namespace feature { STATIC_ASSERT(sizeof(typename TCont::value_type) == 1); - uint32_t const count = cont.size(); + uint32_t const count = static_cast(cont.size()); WriteVarUint(sink, count); if (count > 0) sink.Write(&cont[0], count); diff --git a/indexer/drawing_rules.cpp b/indexer/drawing_rules.cpp index c901cbeecd..6329b857bd 100644 --- a/indexer/drawing_rules.cpp +++ b/indexer/drawing_rules.cpp @@ -100,9 +100,9 @@ size_t RulesHolder::AddRule(int scale, rule_type_t type, BaseRule * p) m_container[type].push_back(p); vector & v = m_rules[scale][type]; - v.push_back(m_container[type].size()-1); + v.push_back(static_cast(m_container[type].size()-1)); - size_t const ret = v.size() - 1; + int const ret = static_cast(v.size() - 1); ASSERT ( Find(Key(scale, type, ret)) == p, (ret) ); return ret; } @@ -288,7 +288,7 @@ namespace void AddRule(ClassifObject * p, int scale, rule_type_t type, TProtoRule const & rule) { size_t const i = m_holder.AddRule(scale, type, new TRule(rule)); - Key k(scale, type, i); + Key k(scale, type, static_cast(i)); p->SetVisibilityOnScale(true, scale); k.SetPriority(rule.priority()); @@ -313,7 +313,7 @@ namespace using namespace proto_rules; - for (size_t k = 0; k < de.lines_size(); ++k) + for (int k = 0; k < de.lines_size(); ++k) AddRule(p, de.scale(), line, de.lines(k)); if (de.has_area()) diff --git a/indexer/feature_loader.cpp b/indexer/feature_loader.cpp index 55664f903a..2af1614771 100644 --- a/indexer/feature_loader.cpp +++ b/indexer/feature_loader.cpp @@ -140,7 +140,7 @@ void LoaderCurrent::ParseHeader2() src = ArrayByteSource(serial::LoadInnerPath(start, ptsCount, cp, m_pF->m_points)); - m_pF->m_innerStats.m_points = src.PtrC() - start; + m_pF->m_innerStats.m_points = static_cast(src.PtrC() - start); } else { @@ -160,7 +160,7 @@ void LoaderCurrent::ParseHeader2() FeatureType::points_t points; src = ArrayByteSource(serial::LoadInnerTriangles(start, trgCount, cp, points)); - m_pF->m_innerStats.m_strips = src.PtrC() - start; + m_pF->m_innerStats.m_strips = static_cast(src.PtrC() - start); for (uint8_t i = 2; i < trgCount; ++i) { @@ -173,7 +173,7 @@ void LoaderCurrent::ParseHeader2() ReadOffsets(src, trgMask, m_trgOffsets); } - m_pF->m_innerStats.m_size = src.PtrC() - DataPtr(); + m_pF->m_innerStats.m_size = static_cast(src.PtrC() - DataPtr()); } uint32_t LoaderCurrent::ParseGeometry(int scale) @@ -259,7 +259,8 @@ void LoaderCurrent::ParseMetadata() typedef pair IdxElementT; DDVector idx(m_Info.GetMetadataIndexReader()); - auto it = lower_bound(idx.begin(), idx.end() + auto it = lower_bound(idx.begin(), + idx.end() , make_pair(uint32_t(m_pF->m_id.m_offset), uint32_t(0)) , [](IdxElementT const & v1, IdxElementT const & v2) { return v1.first < v2.first; } ); diff --git a/indexer/old/feature_loader_101.cpp b/indexer/old/feature_loader_101.cpp index 4c42cf6ba0..2c365cd593 100644 --- a/indexer/old/feature_loader_101.cpp +++ b/indexer/old/feature_loader_101.cpp @@ -198,7 +198,7 @@ int LoaderImpl::GetScaleIndex(int scale, offsets_t const & offsets) const if (scale == -1) { // Choose the best geometry for the last visible scale. - int i = offsets.size()-1; + int i = static_cast(offsets.size()-1); while (i >= 0 && offsets[i] == s_InvalidOffset) --i; if (i >= 0) return i; @@ -207,7 +207,7 @@ int LoaderImpl::GetScaleIndex(int scale, offsets_t const & offsets) const } else { - for (size_t i = 0; i < m_Info.GetScalesCount(); ++i) + for (int i = 0; i < m_Info.GetScalesCount(); ++i) if (scale <= m_Info.GetScale(i)) { if (offsets[i] != s_InvalidOffset) @@ -268,7 +268,7 @@ namespace void LoaderImpl::ParseHeader2() { - uint8_t ptsCount, ptsMask, trgCount, trgMask; + uint8_t ptsCount = 0, ptsMask = 0, trgCount = 0, trgMask = 0; uint8_t const commonH = Header(); BitSource bitSource(DataPtr() + m_Header2Offset); @@ -311,7 +311,7 @@ void LoaderImpl::ParseHeader2() src = ArrayByteSource(serial::LoadInnerPath( start, ptsCount, GetDefCodingParams(), m_pF->m_points)); - m_pF->m_innerStats.m_points = src.PtrC() - start; + m_pF->m_innerStats.m_points = static_cast(src.PtrC() - start); } else ReadOffsets(src, ptsMask, m_ptsOffsets); @@ -329,7 +329,7 @@ void LoaderImpl::ParseHeader2() src = ArrayByteSource(serial::LoadInnerTriangles( start, trgCount, GetDefCodingParams(), points)); - m_pF->m_innerStats.m_strips = src.PtrC() - start; + m_pF->m_innerStats.m_strips = static_cast(src.PtrC() - start); for (uint8_t i = 2; i < trgCount; ++i) { @@ -342,7 +342,7 @@ void LoaderImpl::ParseHeader2() ReadOffsets(src, trgMask, m_trgOffsets); } - m_pF->m_innerStats.m_size = src.PtrC() - DataPtr(); + m_pF->m_innerStats.m_size = static_cast(src.PtrC() - DataPtr()); } uint32_t LoaderImpl::ParseGeometry(int scale) diff --git a/indexer/scale_index.hpp b/indexer/scale_index.hpp index 1c671010eb..eadb0c9261 100644 --- a/indexer/scale_index.hpp +++ b/indexer/scale_index.hpp @@ -49,7 +49,7 @@ public: ReaderSource source(reader); VarSerialVectorReader treesReader(source); - for (size_t i = 0; i < treesReader.Size(); ++i) + for (int i = 0; i < treesReader.Size(); ++i) m_IndexForScale.push_back(factory.CreateIndex(treesReader.SubReader(i))); }