Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorygorshenin <mipt.vi002@gmail.com>2017-01-13 19:34:23 +0300
committerGitHub <noreply@github.com>2017-01-13 19:34:23 +0300
commit5e2b87b707838c6ae8e27846c7953ddf1bf882eb (patch)
tree62e045227e3a7e30f192022a6a744810048fc9be
parent4dc806fbb7b3a1c34d7e792e978a202a592c38de (diff)
parent598088504e5d89852c45f0678acde17a3725caff (diff)
Merge pull request #5180 from syershov/fix-warningsbeta-572beta-571beta-570
Fix warnings
-rw-r--r--base/CMakeLists.txt1
-rw-r--r--base/base.pro1
-rw-r--r--base/checked_cast.hpp20
-rw-r--r--base/condition.cpp3
-rw-r--r--base/stl_iterator.hpp11
-rw-r--r--editor/changeset_wrapper.cpp4
-rw-r--r--indexer/centers_table.cpp17
-rw-r--r--indexer/drules_selector.cpp8
-rw-r--r--indexer/feature.cpp2
-rw-r--r--indexer/feature.hpp2
-rw-r--r--indexer/feature_impl.hpp2
-rw-r--r--indexer/ftypes_matcher.cpp4
-rw-r--r--indexer/ftypes_matcher.hpp2
-rw-r--r--indexer/scale_index.hpp2
-rw-r--r--platform/apple_location_service.mm2
-rw-r--r--platform/platform.pro3
-rw-r--r--search/ranking_utils.hpp4
-rw-r--r--traffic/traffic_info.cpp4
-rw-r--r--xcode/base/base.xcodeproj/project.pbxproj2
-rw-r--r--xcode/indexer/indexer.xcodeproj/project.pbxproj2
20 files changed, 65 insertions, 31 deletions
diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt
index 70b0832656..78b4bc815d 100644
--- a/base/CMakeLists.txt
+++ b/base/CMakeLists.txt
@@ -10,6 +10,7 @@ set(
buffer_vector.hpp
cache.hpp
cancellable.hpp
+ checked_cast.hpp
collection_cast.hpp
condition.cpp
condition.hpp
diff --git a/base/base.pro b/base/base.pro
index aa42754cc5..d8f90faf79 100644
--- a/base/base.pro
+++ b/base/base.pro
@@ -41,6 +41,7 @@ HEADERS += \
buffer_vector.hpp \
cache.hpp \
cancellable.hpp \
+ checked_cast.hpp \
collection_cast.hpp \
condition.hpp \
deferred_task.hpp \
diff --git a/base/checked_cast.hpp b/base/checked_cast.hpp
new file mode 100644
index 0000000000..363840c785
--- /dev/null
+++ b/base/checked_cast.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "base/assert.hpp"
+
+namespace base
+{
+template <typename ReturnType, typename ParameterType>
+ReturnType checked_cast(ParameterType v)
+{
+ CHECK_EQUAL(static_cast<ParameterType>(static_cast<ReturnType>(v)), v, ());
+ return static_cast<ReturnType>(v);
+}
+
+template <typename ReturnType, typename ParameterType>
+ReturnType asserted_cast(ParameterType v)
+{
+ ASSERT_EQUAL(static_cast<ParameterType>(static_cast<ReturnType>(v)), v, ());
+ return static_cast<ReturnType>(v);
+}
+} // namespace base
diff --git a/base/condition.cpp b/base/condition.cpp
index 1082a04346..2be49f0e27 100644
--- a/base/condition.cpp
+++ b/base/condition.cpp
@@ -8,6 +8,7 @@
#include <cerrno>
#include <cstdint>
+#include <limits>
namespace threads
{
@@ -47,7 +48,7 @@ namespace threads
bool Condition::Wait(unsigned ms)
{
- if (ms == -1)
+ if (ms == std::numeric_limits<unsigned>::max())
{
Wait();
return false;
diff --git a/base/stl_iterator.hpp b/base/stl_iterator.hpp
index a409f08b5f..4637dc9704 100644
--- a/base/stl_iterator.hpp
+++ b/base/stl_iterator.hpp
@@ -1,6 +1,15 @@
#pragma once
-#include <boost/iterator/iterator_facade.hpp>
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wshorten-64-to-32"
+#endif
+
+#include "3party/boost/boost/iterator/iterator_facade.hpp"
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
namespace detail
{
diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp
index d161b4332b..73b6c39a03 100644
--- a/editor/changeset_wrapper.cpp
+++ b/editor/changeset_wrapper.cpp
@@ -281,8 +281,8 @@ string ChangesetWrapper::TypeCountToString(TTypeCount const & typeCount)
});
ostringstream ss;
- auto const limit = min(size_t(3), items.size());
- for (auto i = 0; i < limit; ++i)
+ size_t const limit = min(size_t(3), items.size());
+ for (size_t i = 0; i < limit; ++i)
{
if (i > 0)
{
diff --git a/indexer/centers_table.cpp b/indexer/centers_table.cpp
index f0a1fa7d6a..1659c6a83a 100644
--- a/indexer/centers_table.cpp
+++ b/indexer/centers_table.cpp
@@ -14,6 +14,7 @@
#include "coding/writer.hpp"
#include "base/assert.hpp"
+#include "base/checked_cast.hpp"
#include "base/logging.hpp"
#include "std/unordered_map.hpp"
@@ -151,10 +152,10 @@ public:
{
entry.resize(kBlockSize);
- uint32_t const start = m_offsets.select(base);
- uint32_t const end = base + 1 < m_offsets.num_ones()
- ? m_offsets.select(base + 1)
- : m_header.m_endOffset - m_header.m_deltasOffset;
+ auto const start = m_offsets.select(base);
+ auto const end = base + 1 < m_offsets.num_ones()
+ ? m_offsets.select(base + 1)
+ : m_header.m_endOffset - m_header.m_deltasOffset;
vector<uint8_t> data(end - start);
@@ -297,7 +298,7 @@ void CentersTableBuilder::Freeze(Writer & writer) const
MemWriter<vector<uint8_t>> writer(deltas);
for (size_t i = 0; i < m_centers.size(); i += CentersTableV0::kBlockSize)
{
- offsets.push_back(deltas.size());
+ offsets.push_back(static_cast<uint32_t>(deltas.size()));
uint64_t delta = EncodeDelta(m_centers[i], m_codingParams.GetBasePoint());
WriteVarUint(writer, delta);
@@ -315,15 +316,15 @@ void CentersTableBuilder::Freeze(Writer & writer) const
for (auto const & offset : offsets)
builder.push_back(offset);
- header.m_positionsOffset = writer.Pos() - startOffset;
+ header.m_positionsOffset = base::checked_cast<uint32_t>(writer.Pos() - startOffset);
coding::FreezeVisitor<Writer> visitor(writer);
succinct::elias_fano(&builder).map(visitor);
}
{
- header.m_deltasOffset = writer.Pos() - startOffset;
+ header.m_deltasOffset = base::checked_cast<uint32_t>(writer.Pos() - startOffset);
writer.Write(deltas.data(), deltas.size());
- header.m_endOffset = writer.Pos() - startOffset;
+ header.m_endOffset = base::checked_cast<uint32_t>(writer.Pos() - startOffset);
}
int64_t const endOffset = writer.Pos();
diff --git a/indexer/drules_selector.cpp b/indexer/drules_selector.cpp
index bacc660246..99c0e1f3c9 100644
--- a/indexer/drules_selector.cpp
+++ b/indexer/drules_selector.cpp
@@ -97,7 +97,7 @@ private:
};
// Feature tag value evaluator for tag 'population'
-bool GetPopulation(FeatureType const & ft, uint32_t & population)
+bool GetPopulation(FeatureType const & ft, uint64_t & population)
{
population = ftypes::GetPopulation(ft);
return true;
@@ -139,14 +139,14 @@ unique_ptr<ISelector> ParseSelector(string const & str)
if (e.m_tag == "population")
{
- int value = 0;
- if (!e.m_value.empty() && (!strings::to_int(e.m_value, value) || value < 0))
+ uint64_t value = 0;
+ if (!e.m_value.empty() && !strings::to_uint64(e.m_value, value))
{
// bad string format
LOG(LDEBUG, ("Invalid selector:", str));
return unique_ptr<ISelector>();
}
- return make_unique<Selector<uint32_t>>(&GetPopulation, e.m_operator, static_cast<uint32_t>(value));
+ return make_unique<Selector<uint64_t>>(&GetPopulation, e.m_operator, value);
}
else if (e.m_tag == "name")
{
diff --git a/indexer/feature.cpp b/indexer/feature.cpp
index 84ecab623f..d5d35dec64 100644
--- a/indexer/feature.cpp
+++ b/indexer/feature.cpp
@@ -550,7 +550,7 @@ uint8_t FeatureType::GetRank() const
return m_params.rank;
}
-uint32_t FeatureType::GetPopulation() const
+uint64_t FeatureType::GetPopulation() const
{
return feature::RankToPopulation(GetRank());
}
diff --git a/indexer/feature.hpp b/indexer/feature.hpp
index 874d8bd57a..d580d5eedb 100644
--- a/indexer/feature.hpp
+++ b/indexer/feature.hpp
@@ -294,7 +294,7 @@ public:
//@}
uint8_t GetRank() const;
- uint32_t GetPopulation() const;
+ uint64_t GetPopulation() const;
string GetRoadNumber() const;
inline feature::Metadata const & GetMetadata() const
diff --git a/indexer/feature_impl.hpp b/indexer/feature_impl.hpp
index ea1ba79950..e5b195620f 100644
--- a/indexer/feature_impl.hpp
+++ b/indexer/feature_impl.hpp
@@ -14,7 +14,7 @@ namespace feature
static int const g_arrWorldScales[] = { 3, 5, 7, 9 }; // 9 = scales::GetUpperWorldScale()
static int const g_arrCountryScales[] = { 10, 12, 14, 17 }; // 17 = scales::GetUpperScale()
- inline string GetTagForIndex(char const * prefix, int ind)
+ inline string GetTagForIndex(char const * prefix, size_t ind)
{
string str;
str.reserve(strlen(prefix) + 1);
diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp
index d8bd57b50b..ec939f1880 100644
--- a/indexer/ftypes_matcher.cpp
+++ b/indexer/ftypes_matcher.cpp
@@ -488,9 +488,9 @@ IsLocalityChecker const & IsLocalityChecker::Instance()
return inst;
}
-uint32_t GetPopulation(FeatureType const & ft)
+uint64_t GetPopulation(FeatureType const & ft)
{
- uint32_t population = ft.GetPopulation();
+ uint64_t population = ft.GetPopulation();
if (population < 10)
{
diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp
index 48d1dcfd97..c3d6e02d5d 100644
--- a/indexer/ftypes_matcher.hpp
+++ b/indexer/ftypes_matcher.hpp
@@ -210,7 +210,7 @@ public:
/// @name Get city radius and population.
/// @param r Radius in meters.
//@{
-uint32_t GetPopulation(FeatureType const & ft);
+uint64_t GetPopulation(FeatureType const & ft);
double GetRadiusByPopulation(uint32_t p);
uint32_t GetPopulationByRadius(double r);
//@}
diff --git a/indexer/scale_index.hpp b/indexer/scale_index.hpp
index d290b1a1a3..5a9a397544 100644
--- a/indexer/scale_index.hpp
+++ b/indexer/scale_index.hpp
@@ -53,7 +53,7 @@ public:
ReaderSource<ReaderT> source(reader);
VarSerialVectorReader<ReaderT> treesReader(source);
- for (int i = 0; i < treesReader.Size(); ++i)
+ for (uint32_t i = 0; i < treesReader.Size(); ++i)
m_IndexForScale.push_back(factory.CreateIndex(treesReader.SubReader(i)));
}
diff --git a/platform/apple_location_service.mm b/platform/apple_location_service.mm
index cb7da3a328..a26c85eaf5 100644
--- a/platform/apple_location_service.mm
+++ b/platform/apple_location_service.mm
@@ -88,6 +88,7 @@ public:
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations
{
+ UNUSED_VALUE(manager);
GpsInfo newInfo;
[LocationManagerWrapper location:locations.firstObject toGpsInfo:newInfo];
m_service->OnLocationUpdate(newInfo);
@@ -96,6 +97,7 @@ public:
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
+ UNUSED_VALUE(manager);
LOG(LWARNING, ("locationManager failed with error", error.code, [error.description UTF8String]));
if (error.code == kCLErrorDenied)
diff --git a/platform/platform.pro b/platform/platform.pro
index 01d2aa56d3..aecbb744f5 100644
--- a/platform/platform.pro
+++ b/platform/platform.pro
@@ -29,8 +29,7 @@ INCLUDEPATH += $$ROOT_DIR/3party/jansson/src
SOURCES += platform_win.cpp \
wifi_info_windows.cpp
} else:macx-* {
- OBJECTIVE_SOURCES += marketing_service_dummy.cpp \
- platform_mac.mm \
+ OBJECTIVE_SOURCES += platform_mac.mm \
apple_location_service.mm
} else:linux* {
SOURCES += platform_linux.cpp
diff --git a/search/ranking_utils.hpp b/search/ranking_utils.hpp
index 1af9bbe6ce..d247bc4ef9 100644
--- a/search/ranking_utils.hpp
+++ b/search/ranking_utils.hpp
@@ -61,10 +61,10 @@ NameScore GetNameScore(vector<strings::UniString> const & tokens, TSlice const &
bool const lastTokenIsPrefix = slice.IsPrefix(m - 1);
NameScore score = NAME_SCORE_ZERO;
- for (int offset = 0; offset + m <= n; ++offset)
+ for (size_t offset = 0; offset + m <= n; ++offset)
{
bool match = true;
- for (int i = 0; i < m - 1 && match; ++i)
+ for (size_t i = 0; i < m - 1 && match; ++i)
match = match && impl::Match(slice.Get(i), tokens[offset + i]);
if (!match)
continue;
diff --git a/traffic/traffic_info.cpp b/traffic/traffic_info.cpp
index ffa122fae7..48c2600af0 100644
--- a/traffic/traffic_info.cpp
+++ b/traffic/traffic_info.cpp
@@ -511,8 +511,8 @@ TrafficInfo::ServerDataStatus TrafficInfo::ProcessFailure(platform::HttpClient c
{
case 404: /* Not Found */
{
- int64_t version = 0;
- strings::to_int64(request.ServerResponse().c_str(), version);
+ uint64_t version = 0;
+ strings::to_uint64(request.ServerResponse().c_str(), version);
if (version > mwmVersion && version <= m_currentDataVersion)
m_availability = Availability::ExpiredData;
diff --git a/xcode/base/base.xcodeproj/project.pbxproj b/xcode/base/base.xcodeproj/project.pbxproj
index f044b90146..87a23fc54f 100644
--- a/xcode/base/base.xcodeproj/project.pbxproj
+++ b/xcode/base/base.xcodeproj/project.pbxproj
@@ -223,6 +223,7 @@
67A609AD1C88642E001E641A /* deferred_task.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = deferred_task.hpp; sourceTree = "<group>"; };
67B52B5E1AD3C84E00664C17 /* thread_checker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = thread_checker.cpp; sourceTree = "<group>"; };
67B52B5F1AD3C84E00664C17 /* thread_checker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = thread_checker.hpp; sourceTree = "<group>"; };
+ 67C79B9E1E2929DB00C40034 /* checked_cast.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = checked_cast.hpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -377,6 +378,7 @@
675341CA1A3F57E400A0A8C3 /* timer.hpp */,
3446C66F1DDCA96300146687 /* uni_string_dfa.cpp */,
3446C6701DDCA96300146687 /* uni_string_dfa.hpp */,
+ 67C79B9E1E2929DB00C40034 /* checked_cast.hpp */,
);
name = base;
path = ../../base;
diff --git a/xcode/indexer/indexer.xcodeproj/project.pbxproj b/xcode/indexer/indexer.xcodeproj/project.pbxproj
index 5a1f8fc16f..e690be6ba6 100644
--- a/xcode/indexer/indexer.xcodeproj/project.pbxproj
+++ b/xcode/indexer/indexer.xcodeproj/project.pbxproj
@@ -33,7 +33,6 @@
3496AB971DC1FA2000C5DDBA /* types.txt in Resources */ = {isa = PBXBuildFile; fileRef = 3496AB961DC1FA2000C5DDBA /* types.txt */; };
3496AB9D1DC1FA5200C5DDBA /* drules_proto_clear.bin in Resources */ = {isa = PBXBuildFile; fileRef = 3496AB981DC1FA5200C5DDBA /* drules_proto_clear.bin */; };
3496AB9E1DC1FA5200C5DDBA /* drules_proto_dark.bin in Resources */ = {isa = PBXBuildFile; fileRef = 3496AB991DC1FA5200C5DDBA /* drules_proto_dark.bin */; };
- 3496AB9F1DC1FA5200C5DDBA /* drules_proto_legacy.bin in Resources */ = {isa = PBXBuildFile; fileRef = 3496AB9A1DC1FA5200C5DDBA /* drules_proto_legacy.bin */; };
3496ABA01DC1FA5200C5DDBA /* drules_proto-bw.bin in Resources */ = {isa = PBXBuildFile; fileRef = 3496AB9B1DC1FA5200C5DDBA /* drules_proto-bw.bin */; };
3496ABA11DC1FA5200C5DDBA /* drules_proto.bin in Resources */ = {isa = PBXBuildFile; fileRef = 3496AB9C1DC1FA5200C5DDBA /* drules_proto.bin */; };
3496ABA31DC1FA7200C5DDBA /* editor.config in Resources */ = {isa = PBXBuildFile; fileRef = 3496ABA21DC1FA7200C5DDBA /* editor.config */; };
@@ -972,7 +971,6 @@
3496ABA31DC1FA7200C5DDBA /* editor.config in Resources */,
3496AB9D1DC1FA5200C5DDBA /* drules_proto_clear.bin in Resources */,
3496AB9E1DC1FA5200C5DDBA /* drules_proto_dark.bin in Resources */,
- 3496AB9F1DC1FA5200C5DDBA /* drules_proto_legacy.bin in Resources */,
3496ABA01DC1FA5200C5DDBA /* drules_proto-bw.bin in Resources */,
3496ABA11DC1FA5200C5DDBA /* drules_proto.bin in Resources */,
3496AB971DC1FA2000C5DDBA /* types.txt in Resources */,