diff options
author | mpimenov <mpimenov@users.noreply.github.com> | 2017-05-11 12:46:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-11 12:46:10 +0300 |
commit | 007e590af70304c52e261a4e2214ac4df949558c (patch) | |
tree | fd11ef3c9d4888a11dad805a486d24512de7d8b8 | |
parent | c6482bf497483e857ef4da0596806a7c57fa2bd5 (diff) | |
parent | 3b3c72894b8097b1d4a282ae86e1cdc763ebcc8a (diff) |
Merge pull request #6021 from milchakov/warnings_fixesbeta-800
Warning fixes
-rw-r--r-- | android/jni/com/mapswithme/maps/Framework.cpp | 5 | ||||
-rw-r--r-- | android/jni/com/mapswithme/util/StringUtils.cpp | 5 | ||||
-rw-r--r-- | indexer/feature_utils.cpp | 9 | ||||
-rw-r--r-- | map/framework.cpp | 2 | ||||
-rw-r--r-- | map/map_tests/kmz_unarchive_test.cpp | 2 | ||||
-rw-r--r-- | map/map_tests/mwm_url_tests.cpp | 12 | ||||
-rw-r--r-- | qt/mainwindow.cpp | 7 | ||||
-rw-r--r-- | qt/osm_auth_dialog.cpp | 6 | ||||
-rw-r--r-- | routing/road_access.cpp | 2 | ||||
-rw-r--r-- | routing/road_access.hpp | 2 | ||||
-rw-r--r-- | routing/routing_integration_tests/cross_section_tests.cpp | 2 | ||||
-rw-r--r-- | search/keyword_lang_matcher.cpp | 2 | ||||
-rw-r--r-- | search/query_saver.cpp | 4 |
13 files changed, 31 insertions, 29 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 4e9b082684..e03c086d0b 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -436,8 +436,9 @@ location::EMyPositionMode Framework::GetMyPositionMode() { if (!m_isCurrentModeInitialized) { - m_currentMode = location::NotFollowNoPosition; - settings::Get(settings::kLocationStateMode, m_currentMode); + if (!settings::Get(settings::kLocationStateMode, m_currentMode)) + m_currentMode = location::NotFollowNoPosition; + m_isCurrentModeInitialized = true; } diff --git a/android/jni/com/mapswithme/util/StringUtils.cpp b/android/jni/com/mapswithme/util/StringUtils.cpp index 7e01c268cd..eb55440e13 100644 --- a/android/jni/com/mapswithme/util/StringUtils.cpp +++ b/android/jni/com/mapswithme/util/StringUtils.cpp @@ -42,8 +42,9 @@ Java_com_mapswithme_util_StringUtils_nativeFormatSpeedAndUnits(JNIEnv * env, jcl static jclass const pairClass = jni::GetGlobalClassRef(env, "android/util/Pair"); static jmethodID const pairCtor = jni::GetConstructorID(env, pairClass, "(Ljava/lang/Object;Ljava/lang/Object;)V"); - auto units = measurement_utils::Units::Metric; - settings::Get(settings::kMeasurementUnits, units); + measurement_utils::Units units; + if (!settings::Get(settings::kMeasurementUnits, units)) + units = measurement_utils::Units::Metric; return env->NewObject(pairClass, pairCtor, jni::ToJavaString(env, measurement_utils::FormatSpeed(metersPerSecond, units)), jni::ToJavaString(env, measurement_utils::FormatSpeedUnits(units))); diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 64b7d8779c..5947948079 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -49,10 +49,11 @@ bool GetTransliteratedName(feature::RegionData const & regionData, StringUtf8Mul bool GetBestName(StringUtf8Multilang const & src, vector<int8_t> const & priorityList, string & out) { - auto bestIndex = priorityList.size(); + auto const priorityListSize = static_cast<long>(priorityList.size()); + auto bestIndex = priorityListSize; auto const findAndSet = [](vector<int8_t> const & langs, int8_t const code, string const & name, - size_t & bestIndex, string & outName) + long & bestIndex, string & outName) { auto const it = find(langs.begin(), langs.end(), code); if (it != langs.end() && bestIndex > distance(langs.begin(), it)) @@ -72,13 +73,13 @@ bool GetBestName(StringUtf8Multilang const & src, vector<int8_t> const & priorit }); // There are many "junk" names in Arabian island. - if (bestIndex < priorityList.size() && + if (bestIndex < priorityListSize && priorityList[bestIndex] == StrUtf8::kInternationalCode) { out = out.substr(0, out.find_first_of(',')); } - return bestIndex < priorityList.size(); + return bestIndex < priorityListSize; } } // namespace diff --git a/map/framework.cpp b/map/framework.cpp index 12a658301a..98b2ee1fe1 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2511,7 +2511,7 @@ string Framework::CodeGe0url(double lat, double lon, double zoomLevel, string co int const len = MapsWithMe_GenShortShowMapUrl(lat, lon, zoomLevel, name.c_str(), &res[0], static_cast<int>(res.size())); - ASSERT_LESS_OR_EQUAL(len, res.size(), ()); + ASSERT_LESS_OR_EQUAL(len, static_cast<int>(res.size()), ()); res.resize(len); return res; diff --git a/map/map_tests/kmz_unarchive_test.cpp b/map/map_tests/kmz_unarchive_test.cpp index e9fae28ee0..5690e5e48e 100644 --- a/map/map_tests/kmz_unarchive_test.cpp +++ b/map/map_tests/kmz_unarchive_test.cpp @@ -21,7 +21,7 @@ UNIT_TEST(KMZ_UnzipTest) bool isKMLinZip = false; - for (int i = 0; i < files.size();++i) + for (size_t i = 0; i < files.size(); ++i) { if (files[i].first == "doc.kml") { diff --git a/map/map_tests/mwm_url_tests.cpp b/map/map_tests/mwm_url_tests.cpp index 26bab35891..2bbf03fec8 100644 --- a/map/map_tests/mwm_url_tests.cpp +++ b/map/map_tests/mwm_url_tests.cpp @@ -44,7 +44,7 @@ namespace string const & GetAppTitle() const { return m_api.GetAppTitle(); } bool GoBackOnBalloonClick() const { return m_api.GoBackOnBalloonClick(); } - int GetPointCount() const { return UserMarkControllerGuard(*m_m, type).m_controller.GetUserMarkCount(); } + size_t GetPointCount() const { return UserMarkControllerGuard(*m_m, type).m_controller.GetUserMarkCount(); } vector<RoutePoint> GetRoutePoints() const { return m_api.GetRoutePoints(); } url_scheme::SearchRequest const & GetSearchRequest() const { return m_api.GetSearchRequest(); } string const & GetGlobalBackUrl() const { return m_api.GetGlobalBackUrl(); } @@ -76,7 +76,7 @@ namespace ApiMarkPoint const * GetMark(int index) const { UserMarkControllerGuard guard(*m_m, type); - TEST_LESS(index, guard.m_controller.GetUserMarkCount(), ()); + TEST_LESS(index, static_cast<int>(guard.m_controller.GetUserMarkCount()), ()); return static_cast<ApiMarkPoint const *>(guard.m_controller.GetUserMark(index)); } @@ -344,7 +344,7 @@ string generatePartOfUrl(url_scheme::ApiPoint const & point) return stream.str(); } -string randomString(size_t size, size_t seed) +string randomString(size_t size, uint32_t seed) { string result(size, '0'); mt19937 rng(seed); @@ -353,10 +353,10 @@ string randomString(size_t size, size_t seed) return result; } -void generateRandomTest(size_t numberOfPoints, size_t stringLength) +void generateRandomTest(uint32_t numberOfPoints, size_t stringLength) { vector <url_scheme::ApiPoint> vect(numberOfPoints); - for (size_t i = 0; i < numberOfPoints; ++i) + for (uint32_t i = 0; i < numberOfPoints; ++i) { url_scheme::ApiPoint point; mt19937 rng(i); @@ -383,7 +383,7 @@ void generateRandomTest(size_t numberOfPoints, size_t stringLength) double lat = vect[i].m_lat; double lon = vect[i].m_lon; ToMercatoToLatLon(lat, lon); - size_t const ix = vect.size() - i - 1; + int const ix = vect.size() - i - 1; TEST(api.TestLatLon(ix, lat, lon), ()); TEST(api.TestName(ix, vect[i].m_name), ()); TEST(api.TestID(ix, vect[i].m_id), ()); diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 6ab5c3fc4d..1419d45c1e 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -540,10 +540,11 @@ void MainWindow::OnLoginMenuItem() void MainWindow::OnUploadEditsMenuItem() { string key, secret; - settings::Get(kTokenKeySetting, key); - settings::Get(kTokenSecretSetting, secret); - if (key.empty() || secret.empty()) + if (!settings::Get(kTokenKeySetting, key) || key.empty() || + !settings::Get(kTokenSecretSetting, secret) || secret.empty()) + { OnLoginMenuItem(); + } else { auto & editor = osm::Editor::Instance(); diff --git a/qt/osm_auth_dialog.cpp b/qt/osm_auth_dialog.cpp index 6525d5b035..69e0e14c7b 100644 --- a/qt/osm_auth_dialog.cpp +++ b/qt/osm_auth_dialog.cpp @@ -24,10 +24,8 @@ char const * kLogoutDialogTitle = "Logout Dialog"; OsmAuthDialog::OsmAuthDialog(QWidget * parent) { string key, secret; - settings::Get(kTokenKeySetting, key); - settings::Get(kTokenSecretSetting, secret); - - bool const isLoginDialog = key.empty() || secret.empty(); + bool const isLoginDialog = !settings::Get(kTokenKeySetting, key) || key.empty() || + !settings::Get(kTokenSecretSetting, secret) || secret.empty(); QVBoxLayout * vLayout = new QVBoxLayout(parent); diff --git a/routing/road_access.cpp b/routing/road_access.cpp index 3286438dcf..f2d4a8ea38 100644 --- a/routing/road_access.cpp +++ b/routing/road_access.cpp @@ -15,7 +15,7 @@ string const kNames[] = {"No", "Private", "Destination", "Yes", "Count"}; namespace routing { // RoadAccess -------------------------------------------------------------------------------------- -RoadAccess::Type const RoadAccess::GetSegmentType(Segment const & segment) const +RoadAccess::Type RoadAccess::GetSegmentType(Segment const & segment) const { // todo(@m) This may or may not be too slow. Consider profiling this and using // a Bloom filter or anything else that is faster than std::map. diff --git a/routing/road_access.hpp b/routing/road_access.hpp index f6c1d8dff8..3d1af10d8f 100644 --- a/routing/road_access.hpp +++ b/routing/road_access.hpp @@ -42,7 +42,7 @@ public: std::map<Segment, RoadAccess::Type> const & GetSegmentTypes() const { return m_segmentTypes; } - Type const GetSegmentType(Segment const & segment) const; + Type GetSegmentType(Segment const & segment) const; template <typename V> void SetSegmentTypes(V && v) diff --git a/routing/routing_integration_tests/cross_section_tests.cpp b/routing/routing_integration_tests/cross_section_tests.cpp index 28d8ebf1a0..03a4064311 100644 --- a/routing/routing_integration_tests/cross_section_tests.cpp +++ b/routing/routing_integration_tests/cross_section_tests.cpp @@ -116,7 +116,7 @@ UNIT_TEST(CheckOsrmToFeatureMapping) segMapping.Load(container, file); segMapping.Map(container); - for (size_t i = 0; i < dataFacade.GetNumberOfNodes(); ++i) + for (unsigned i = 0; i < dataFacade.GetNumberOfNodes(); ++i) { buffer_vector<OsrmMappingTypes::FtSeg, 8> buffer; segMapping.ForEachFtSeg(i, MakeBackInsertFunctor(buffer)); diff --git a/search/keyword_lang_matcher.cpp b/search/keyword_lang_matcher.cpp index dea70e4e6e..f4f61203b9 100644 --- a/search/keyword_lang_matcher.cpp +++ b/search/keyword_lang_matcher.cpp @@ -54,7 +54,7 @@ int KeywordLangMatcher::GetLangScore(int8_t lang) const { int const prioritiesTiersCount = static_cast<int>(m_languagePriorities.size()); for (int i = 0; i < prioritiesTiersCount; ++i) - for (int j = 0; j < m_languagePriorities[i].size(); ++j) + for (size_t j = 0; j < m_languagePriorities[i].size(); ++j) if (m_languagePriorities[i][j] == lang) return -i; // All languages in the same tier are equal. diff --git a/search/query_saver.cpp b/search/query_saver.cpp index 4457f49f79..4e15acc6cf 100644 --- a/search/query_saver.cpp +++ b/search/query_saver.cpp @@ -152,9 +152,9 @@ void QuerySaver::Save() void QuerySaver::Load() { string hexData; - settings::Get(kSettingsKey, hexData); - if (hexData.empty()) + if (!settings::Get(kSettingsKey, hexData) || hexData.empty()) return; + try { Deserialize(hexData); |