From 036be1ebad980f832fd01ba42b5a7c2ca16d8f1e Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Thu, 21 Jun 2018 15:49:50 +0300 Subject: [PATCH 01/12] Fixed warn: comparison between signed and unsigned integer expressions --- base/base_tests/stl_helpers_test.cpp | 4 +-- base/levenshtein_dfa.cpp | 5 +++- coding/diff.hpp | 8 +++-- coding/point_to_integer.cpp | 7 +++-- drape/drape_tests/buffer_tests.cpp | 4 +-- drape/overlay_tree.cpp | 2 +- drape_frontend/user_event_stream.cpp | 14 +++++---- .../feature_segments_checker.cpp | 4 +-- generator/generator_tests/tesselator_test.cpp | 2 +- generator/ugc_db.cpp | 2 +- geometry/cellid.hpp | 4 +-- indexer/cell_coverer.hpp | 5 ++-- indexer/interval_index_builder.hpp | 4 +-- map/gps_track_storage.cpp | 9 ++++-- .../openlr_assessment_tool/traffic_mode.cpp | 2 +- platform/http_request.cpp | 3 +- routing/bicycle_directions.cpp | 3 +- routing/index_router.cpp | 6 ++-- search/keyword_matcher.cpp | 6 ++-- search/result.cpp | 3 +- .../assessment_tool/main_model.cpp | 29 ++++++++++++------- search/search_tests/keyword_matcher_test.cpp | 3 +- .../storage_http_tests.cpp | 12 +++++--- storage/storage_tests/storage_tests.cpp | 13 +++++---- 24 files changed, 94 insertions(+), 60 deletions(-) diff --git a/base/base_tests/stl_helpers_test.cpp b/base/base_tests/stl_helpers_test.cpp index 424007c40f..59f8315455 100644 --- a/base/base_tests/stl_helpers_test.cpp +++ b/base/base_tests/stl_helpers_test.cpp @@ -91,7 +91,7 @@ UNIT_TEST(LessBy) std::vector v = {{2, 2}, {0, 4}, {3, 1}, {4, 0}, {1, 3}}; std::sort(v.begin(), v.end(), my::LessBy(&Value::first)); - for (size_t i = 0; i < v.size(); ++i) + for (int i = 0; i < static_cast(v.size()); ++i) TEST_EQUAL(i, v[i].first, ()); std::vector pv; @@ -99,7 +99,7 @@ UNIT_TEST(LessBy) pv.push_back(&p); std::sort(pv.begin(), pv.end(), my::LessBy(&Value::second)); - for (size_t i = 0; i < pv.size(); ++i) + for (int i = 0; i < static_cast(pv.size()); ++i) TEST_EQUAL(i, pv[i]->second, ()); } diff --git a/base/levenshtein_dfa.cpp b/base/levenshtein_dfa.cpp index 9c0b09b00c..82da404b61 100644 --- a/base/levenshtein_dfa.cpp +++ b/base/levenshtein_dfa.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace strings { @@ -200,7 +201,9 @@ LevenshteinDFA::LevenshteinDFA(UniString const & s, size_t prefixSize, m_alphabet.assign(s.begin(), s.end()); CHECK_LESS_OR_EQUAL(prefixSize, s.size(), ()); - for (auto it = s.begin(); std::distance(it, s.begin()) < prefixSize; ++it) + auto pSize = static_cast::difference_type>(prefixSize); + for (auto it = s.begin(); std::distance(it, s.begin()) < pSize; ++it) { for (auto const & misprints : prefixMisprints) { diff --git a/coding/diff.hpp b/coding/diff.hpp index 4287df422a..91e7c55432 100644 --- a/coding/diff.hpp +++ b/coding/diff.hpp @@ -155,14 +155,16 @@ public: DstIterT const dstBeg, DstIterT const dstEnd, PatchCoderT & patchCoder) { - if (srcEnd - srcBeg < m_BlockSize || dstEnd - dstBeg < m_BlockSize) + if (srcEnd - srcBeg < static_cast(m_BlockSize) || + dstEnd - dstBeg < static_cast(m_BlockSize)) { m_FineGrainedDiff.Diff(srcBeg, srcEnd, dstBeg, dstEnd, patchCoder); return; } HasherT hasher; HashPosMultiMapT srcHashes; - for (SrcIterT src = srcBeg; srcEnd - src >= m_BlockSize; src += m_BlockSize) + for (SrcIterT src = srcBeg; srcEnd - src >= static_cast(m_BlockSize); + src += m_BlockSize) srcHashes.insert(HashPosMultiMapValue(hasher.Init(src, m_BlockSize), src - srcBeg)); SrcIterT srcLastDiff = srcBeg; DstIterT dst = dstBeg, dstNext = dstBeg + m_BlockSize, dstLastDiff = dstBeg; @@ -187,7 +189,7 @@ public: patchCoder.Copy(m_BlockSize); srcLastDiff = srcBeg + srcBlockEqualPos + m_BlockSize; dst = dstLastDiff = dstNext; - if (dstEnd - dstNext < m_BlockSize) + if (dstEnd - dstNext < static_cast(m_BlockSize)) break; dstNext = dst + m_BlockSize; h = hasher.Init(dst, m_BlockSize); diff --git a/coding/point_to_integer.cpp b/coding/point_to_integer.cpp index b477b8d3ec..39d9cb583c 100644 --- a/coding/point_to_integer.cpp +++ b/coding/point_to_integer.cpp @@ -7,8 +7,9 @@ int64_t PointToInt64Obsolete(double x, double y, uint32_t coordBits) { int64_t const res = static_cast(PointUToUint64Obsolete(PointDToPointU(x, y, coordBits))); - ASSERT_LESS_OR_EQUAL(res, 3ULL << 2 * POINT_COORD_BITS, ()); ASSERT_GREATER_OR_EQUAL(res, 0, ("Highest bits of (ix, iy) are not used, so res should be > 0.")); + ASSERT_LESS_OR_EQUAL(static_cast(res), + static_cast(3ULL << 2 * POINT_COORD_BITS), ()); return res; } @@ -19,7 +20,9 @@ int64_t PointToInt64Obsolete(m2::PointD const & pt, uint32_t coordBits) m2::PointD Int64ToPointObsolete(int64_t v, uint32_t coordBits) { - ASSERT_LESS_OR_EQUAL(v, 3ULL << 2 * POINT_COORD_BITS, ()); + ASSERT_GREATER_OR_EQUAL(v, 0, ("Highest bits of (ix, iy) are not used, so res should be > 0.")); + ASSERT_LESS_OR_EQUAL(static_cast(v), + static_cast(3ULL << 2 * POINT_COORD_BITS), ()); return PointUToPointD(Uint64ToPointUObsolete(static_cast(v)), coordBits); } diff --git a/drape/drape_tests/buffer_tests.cpp b/drape/drape_tests/buffer_tests.cpp index 1cc91da836..d68bd36076 100644 --- a/drape/drape_tests/buffer_tests.cpp +++ b/drape/drape_tests/buffer_tests.cpp @@ -68,12 +68,12 @@ UNIT_TEST(ParticalUploadDataTest) { size_t const kPart1Size = 3 * 30; float part1Data[kPart1Size]; - for (int i = 0; i < kPart1Size; ++i) + for (size_t i = 0; i < kPart1Size; ++i) part1Data[i] = (float)i; size_t const kPart2Size = 3 * 100; float part2Data[kPart2Size]; - for (int i = 0; i < kPart2Size; ++i) + for (size_t i = 0; i < kPart2Size; ++i) part2Data[i] = (float)i; unique_ptr buffer(new DataBuffer(3 * sizeof(float), 100)); diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp index e36a4cb07c..6deb0f1593 100644 --- a/drape/overlay_tree.cpp +++ b/drape/overlay_tree.cpp @@ -104,7 +104,7 @@ bool OverlayTree::Frame() } m_frameCounter++; - if (m_frameCounter >= m_frameUpdatePeriod) + if (m_frameCounter >= static_cast(m_frameUpdatePeriod)) m_frameCounter = kInvalidFrame; return IsNeedUpdate(); diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 9b12207baa..92252f8c5d 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -1018,8 +1018,9 @@ bool UserEventStream::EndDrag(Touch const & t, bool cancelled) CheckAutoRotate(); - if (!cancelled && m_kineticScrollEnabled && m_scroller.IsActive() && - m_kineticTimer.TimeElapsedAs().count() >= kKineticDelayMs) + auto const ms = static_cast( + m_kineticTimer.TimeElapsedAs().count()); + if (!cancelled && m_kineticScrollEnabled && m_scroller.IsActive() && ms >= kKineticDelayMs) { drape_ptr anim = m_scroller.CreateKineticAnimation(m_navigator.Screen()); if (anim != nullptr) @@ -1108,7 +1109,8 @@ void UserEventStream::DetectShortTap(Touch const & touch) if (DetectForceTap(touch)) return; - auto const ms = m_touchTimer.TimeElapsedAs().count(); + auto const ms = static_cast( + m_touchTimer.TimeElapsedAs().count()); if (ms > kDoubleTapPauseMs) { m_state = STATE_EMPTY; @@ -1124,7 +1126,8 @@ void UserEventStream::DetectLongTap(Touch const & touch) if (DetectForceTap(touch)) return; - auto const ms = m_touchTimer.TimeElapsedAs().count(); + auto const ms = static_cast( + m_touchTimer.TimeElapsedAs().count()); if (ms > kLongTouchMs) { TEST_CALL(LONG_TAP_DETECTED); @@ -1136,7 +1139,8 @@ void UserEventStream::DetectLongTap(Touch const & touch) bool UserEventStream::DetectDoubleTap(Touch const & touch) { - auto const ms = m_touchTimer.TimeElapsedAs().count(); + auto const ms = static_cast( + m_touchTimer.TimeElapsedAs().count()); if (m_state != STATE_WAIT_DOUBLE_TAP || ms > kDoubleTapPauseMs) return false; diff --git a/generator/feature_segments_checker/feature_segments_checker.cpp b/generator/feature_segments_checker/feature_segments_checker.cpp index 6e17b3c013..43d16ba9db 100644 --- a/generator/feature_segments_checker/feature_segments_checker.cpp +++ b/generator/feature_segments_checker/feature_segments_checker.cpp @@ -95,7 +95,7 @@ bool LinearLeastSquaresFactors(vector const & xs, vector const & double constexpr kEpsilon = 1e-6; size_t const n = xs.size(); double mx = 0, my = 0, mxy = 0, mx2 = 0; - for (int i = 0; i < n; ++i) + for (size_t i = 0; i < n; ++i) { mx += xs[i] / n; my += ys[i] / n; @@ -271,7 +271,7 @@ public: return; double const k = (endAltitude - startAltitude) / realFeatureLengthMeters; - for (TAltitude i = 1; i + 1 < numPoints; ++i) + for (uint32_t i = 1; i + 1 < numPoints; ++i) { int32_t const deviation = static_cast(GetY(k, startAltitude, pointDists[i])) - pointAltitudes[i]; diff --git a/generator/generator_tests/tesselator_test.cpp b/generator/generator_tests/tesselator_test.cpp index a6b04ae9c0..a4719fd6e7 100644 --- a/generator/generator_tests/tesselator_test.cpp +++ b/generator/generator_tests/tesselator_test.cpp @@ -32,7 +32,7 @@ namespace size_t count; info.ForEachTriangle(DoDump(count)); - TEST_EQUAL(count, trianglesCount, ()); + TEST_EQUAL(count, static_cast(trianglesCount), ()); return count; } diff --git a/generator/ugc_db.cpp b/generator/ugc_db.cpp index d7a7fec5b1..0b998cf825 100644 --- a/generator/ugc_db.cpp +++ b/generator/ugc_db.cpp @@ -21,7 +21,7 @@ namespace generator static int callback(void * results_ptr, int argc, char ** argv, char ** azColName) { Results & results = *reinterpret_cast(results_ptr); - for (size_t i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { if (results.empty) results.empty = false; diff --git a/geometry/cellid.hpp b/geometry/cellid.hpp index a6a16e97a0..2af9231d7c 100644 --- a/geometry/cellid.hpp +++ b/geometry/cellid.hpp @@ -250,7 +250,7 @@ public: { ASSERT_GREATER(v, 0, ()); ASSERT(0 < depth && depth <= DEPTH_LEVELS, (v, depth)); - ASSERT_LESS_OR_EQUAL(v, TreeSizeForDepth(depth), ()); + ASSERT_LESS_OR_EQUAL(static_cast(v), TreeSizeForDepth(depth), ()); uint64_t bits = 0; int level = 0; --v; @@ -258,7 +258,7 @@ public: { bits <<= 2; ++level; - uint64_t subtreeSize = TreeSizeForDepth(depth - level); + int64_t subtreeSize = static_cast(TreeSizeForDepth(depth - level)); for (--v; v >= subtreeSize; v -= subtreeSize) ++bits; } diff --git a/indexer/cell_coverer.hpp b/indexer/cell_coverer.hpp index 3a433572ec..4b02983985 100644 --- a/indexer/cell_coverer.hpp +++ b/indexer/cell_coverer.hpp @@ -169,8 +169,9 @@ void CoverSpiral(m2::RectD rect, int maxDepth, vector & result) }; auto const coordsAreValid = [](pair const & xy) { - return xy.first >= 0 && xy.second >= 0 && xy.first <= CellId::MAX_COORD && - xy.second <= CellId::MAX_COORD; + return xy.first >= 0 && xy.second >= 0 && + static_cast(xy.first) <= CellId::MAX_COORD && + static_cast(xy.second) <= CellId::MAX_COORD; }; m2::RectD coveredRect; diff --git a/indexer/interval_index_builder.hpp b/indexer/interval_index_builder.hpp index 86fa29d511..fc6a111573 100644 --- a/indexer/interval_index_builder.hpp +++ b/indexer/interval_index_builder.hpp @@ -10,6 +10,7 @@ #include "base/logging.hpp" #include "std/vector.hpp" +#include // +------------------------------+ // | Header | // +------------------------------+ @@ -140,8 +141,7 @@ public: for (CellIdValueIter it = beg; it != end; ++it) { CHECK_LESS(it->GetCell(), 1ULL << keyBits, ()); - // We use static_cast(value) in BuildLeaves to store values difference as VarInt. - CHECK_EQUAL(it->GetValue(), static_cast(it->GetValue()), ()); + CHECK_LESS_OR_EQUAL(it->GetValue(), std::numeric_limits::max(), ()); } return true; diff --git a/map/gps_track_storage.cpp b/map/gps_track_storage.cpp index 115bb4370b..a2a74041dc 100644 --- a/map/gps_track_storage.cpp +++ b/map/gps_track_storage.cpp @@ -171,7 +171,8 @@ void GpsTrackStorage::Append(vector const & items) TruncFile(); // Write position must be after last item position - ASSERT_EQUAL(m_stream.tellp(), GetItemOffset(m_itemCount), ()); + ASSERT_EQUAL(m_stream.tellp(), static_cast( + GetItemOffset(m_itemCount)), ()); vector buff(min(kItemBlockSize, items.size()) * kPointSize); for (size_t i = 0; i < items.size();) @@ -212,7 +213,8 @@ void GpsTrackStorage::Clear() MYTHROW(WriteException, ("File:", m_filePath)); // Write position is set to the first item in the file - ASSERT_EQUAL(m_stream.tellp(), GetItemOffset(0), ()); + ASSERT_EQUAL(m_stream.tellp(), static_cast( + GetItemOffset(0)), ()); } void GpsTrackStorage::ForEach(std::function const & fn) @@ -308,7 +310,8 @@ void GpsTrackStorage::TruncFile() m_itemCount = newItemCount; // Write position must be after last item position (end of file) - ASSERT_EQUAL(m_stream.tellp(), GetItemOffset(m_itemCount), ()); + ASSERT_EQUAL(m_stream.tellp(), static_cast( + GetItemOffset(m_itemCount)), ()); } size_t GpsTrackStorage::GetFirstItemIndex() const diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp index 966c22a8e0..abcf4fb241 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp @@ -241,7 +241,7 @@ void TrafficMode::OnItemSelected(QItemSelection const & selected, QItemSelection auto const row = selected.front().top(); - CHECK_LESS(row, m_segments.size(), ()); + CHECK_LESS(row, static_cast(m_segments.size()), ()); m_currentSegment = &m_segments[row]; auto const & partnerSegment = m_currentSegment->GetPartnerSegment(); diff --git a/platform/http_request.cpp b/platform/http_request.cpp index 20f6d7037d..50c54e8d92 100644 --- a/platform/http_request.cpp +++ b/platform/http_request.cpp @@ -290,7 +290,8 @@ public: { // Check that resume information is correct with existing file. uint64_t size; - if (my::GetFileSize(filePath + DOWNLOADING_FILE_EXTENSION, size) && size <= fileSize) + if (my::GetFileSize(filePath + DOWNLOADING_FILE_EXTENSION, size) && + size <= static_cast(fileSize)) openMode = FileWriter::OP_WRITE_EXISTING; else m_strategy.InitChunks(fileSize, chunkSize); diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index ba9ce9c40c..83ccc1073c 100644 --- a/routing/bicycle_directions.cpp +++ b/routing/bicycle_directions.cpp @@ -345,7 +345,8 @@ void BicycleDirectionsEngine::FillPathSegmentsAndAdjacentEdgesMap( continue; } - CHECK_EQUAL(prevJunctions.size(), abs(static_cast(inSegId - startSegId)) + 1, ()); + CHECK_EQUAL(prevJunctions.size(), static_cast::size_type>( + abs(static_cast(inSegId - startSegId)) + 1), ()); prevJunctions.push_back(currJunction); diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 1f0aa06d65..dfb30a7cc6 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -763,7 +763,7 @@ RouterResultCode IndexRouter::ProcessLeaps(vector const & input, [lastMwmId](Segment const & s) { return s.GetMwmId() == lastMwmId; }); auto const finishLeapStart = distance(input.begin(), finishLeapStartIt); - for (size_t i = 0; i <= finishLeapStart; ++i) + for (vector::difference_type i = 0; i <= finishLeapStart; ++i) { auto const & current = input[i]; @@ -780,7 +780,7 @@ RouterResultCode IndexRouter::ProcessLeaps(vector const & input, { bool const isStartLeap = i == 0; i = isStartLeap ? startLeapEnd : input.size() - 1; - CHECK_LESS(i, input.size(), ()); + CHECK_LESS(static_cast::size_type>(i), input.size(), ()); auto const & next = input[i]; // First start-to-mwm-exit and last mwm-enter-to-finish leaps need special processing. @@ -807,7 +807,7 @@ RouterResultCode IndexRouter::ProcessLeaps(vector const & input, else { ++i; - CHECK_LESS(i, input.size(), ()); + CHECK_LESS(static_cast::size_type>(i), input.size(), ()); auto const & next = input[i]; CHECK(!IndexGraphStarter::IsFakeSegment(current), ()); diff --git a/search/keyword_matcher.cpp b/search/keyword_matcher.cpp index 68d20980f0..422ed0a3e3 100644 --- a/search/keyword_matcher.cpp +++ b/search/keyword_matcher.cpp @@ -57,9 +57,9 @@ KeywordMatcher::Score KeywordMatcher::CalcScore(strings::UniString const * token int8_t prevTokenMatchDistance = 0; bool prefixMatched = true; - for (int i = 0; i < m_keywords.size(); ++i) + for (decltype(m_keywords)::size_type i = 0; i < m_keywords.size(); ++i) { - for (int j = 0; j < count && !isQueryTokenMatched[i]; ++j) + for (size_t j = 0; j < count && !isQueryTokenMatched[i]; ++j) { if (!isNameTokenMatched[j] && m_keywords[i] == tokens[j]) { @@ -74,7 +74,7 @@ KeywordMatcher::Score KeywordMatcher::CalcScore(strings::UniString const * token if (!m_prefix.empty()) { prefixMatched = false; - for (int j = 0; j < count && !prefixMatched; ++j) + for (size_t j = 0; j < count && !prefixMatched; ++j) { if (!isNameTokenMatched[j] && strings::StartsWith(tokens[j].begin(), tokens[j].end(), m_prefix.begin(), m_prefix.end())) diff --git a/search/result.cpp b/search/result.cpp index a6ee26ddeb..5379c78be2 100644 --- a/search/result.cpp +++ b/search/result.cpp @@ -193,7 +193,8 @@ bool Results::AddResult(Result && result) if (result.IsSuggest()) { - if (distance(m_results.begin(), it) >= kMaxNumSuggests) + auto d = distance(m_results.begin(), it); + if (d >= static_cast(kMaxNumSuggests)) return false; for (auto i = m_results.begin(); i != it; ++i) diff --git a/search/search_quality/assessment_tool/main_model.cpp b/search/search_quality/assessment_tool/main_model.cpp index a749b1a708..9d6ae575ad 100644 --- a/search/search_quality/assessment_tool/main_model.cpp +++ b/search/search_quality/assessment_tool/main_model.cpp @@ -115,7 +115,7 @@ void MainModel::OnSampleSelected(int index) CHECK(m_threadChecker.CalledOnOriginalThread(), ()); CHECK_GREATER_OR_EQUAL(index, 0, ()); - CHECK_LESS(index, m_contexts.Size(), ()); + CHECK_LESS(static_cast(index), m_contexts.Size(), ()); CHECK(m_view, ()); m_selectedSample = index; @@ -176,31 +176,33 @@ void MainModel::OnSampleSelected(int index) void MainModel::OnResultSelected(int index) { CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ()); - CHECK_LESS(m_selectedSample, m_contexts.Size(), ()); + CHECK_LESS(static_cast(m_selectedSample), m_contexts.Size(), ()); auto const & context = m_contexts[m_selectedSample]; auto const & foundResults = context.m_foundResults; CHECK_GREATER_OR_EQUAL(index, 0, ()); - CHECK_LESS(index, foundResults.GetCount(), ()); + CHECK_LESS(static_cast(index), foundResults.GetCount(), ()); m_view->MoveViewportToResult(foundResults[index]); } void MainModel::OnNonFoundResultSelected(int index) { CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ()); - CHECK_LESS(m_selectedSample, m_contexts.Size(), ()); + CHECK_LESS(static_cast(m_selectedSample), m_contexts.Size(), ()); auto const & context = m_contexts[m_selectedSample]; auto const & results = context.m_nonFoundResults; CHECK_GREATER_OR_EQUAL(index, 0, ()); - CHECK_LESS(index, results.size(), ()); + CHECK_LESS(static_cast(index), + results.size(), ()); m_view->MoveViewportToResult(results[index]); } void MainModel::OnShowViewportClicked() { CHECK(m_selectedSample != kInvalidIndex, ()); - CHECK_LESS(m_selectedSample, m_contexts.Size(), ()); + CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ()); + CHECK_LESS(static_cast(m_selectedSample), m_contexts.Size(), ()); auto const & context = m_contexts[m_selectedSample]; m_view->MoveViewportToRect(context.m_sample.m_viewport); @@ -209,7 +211,8 @@ void MainModel::OnShowViewportClicked() void MainModel::OnShowPositionClicked() { CHECK(m_selectedSample != kInvalidIndex, ()); - CHECK_LESS(m_selectedSample, m_contexts.Size(), ()); + CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ()); + CHECK_LESS(static_cast(m_selectedSample), m_contexts.Size(), ()); static int constexpr kViewportAroundTopResultsSizeM = 100; static double constexpr kViewportAroundTopResultsScale = 1.2; @@ -258,7 +261,8 @@ bool MainModel::HasChanges() { return m_contexts.HasChanges(); } bool MainModel::AlreadyInSamples(FeatureID const & id) { CHECK(m_selectedSample != kInvalidIndex, ()); - CHECK(m_selectedSample < m_contexts.Size(), ()); + CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ()); + CHECK_LESS(static_cast(m_selectedSample), m_contexts.Size(), ()); bool found = false; ForAnyMatchingEntry(m_contexts[m_selectedSample], id, [&](Edits & edits, size_t index) { @@ -272,7 +276,8 @@ bool MainModel::AlreadyInSamples(FeatureID const & id) void MainModel::AddNonFoundResult(FeatureID const & id) { CHECK(m_selectedSample != kInvalidIndex, ()); - CHECK(m_selectedSample < m_contexts.Size(), ()); + CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ()); + CHECK_LESS(static_cast(m_selectedSample), m_contexts.Size(), ()); auto & context = m_contexts[m_selectedSample]; @@ -296,7 +301,9 @@ void MainModel::OnUpdate(View::ResultType type, size_t sampleIndex, Edits::Updat { using Type = Edits::Update::Type; - CHECK_LESS(sampleIndex, m_contexts.Size(), ()); + CHECK_GREATER_OR_EQUAL(sampleIndex, 0, ()); + CHECK_LESS(static_cast(sampleIndex), m_contexts.Size(), ()); + auto & context = m_contexts[sampleIndex]; if (update.m_type == Type::Add) @@ -395,7 +402,7 @@ void MainModel::ShowMarks(Context const & context) void MainModel::OnChangeAllRelevancesClicked(Edits::Relevance relevance) { CHECK_GREATER_OR_EQUAL(m_selectedSample, 0, ()); - CHECK_LESS(m_selectedSample, m_contexts.Size(), ()); + CHECK_LESS(static_cast(m_selectedSample), m_contexts.Size(), ()); auto & context = m_contexts[m_selectedSample]; context.m_foundResultsEdits.SetAllRelevances(relevance); diff --git a/search/search_tests/keyword_matcher_test.cpp b/search/search_tests/keyword_matcher_test.cpp index 69f483c4a2..1203fc4770 100644 --- a/search/search_tests/keyword_matcher_test.cpp +++ b/search/search_tests/keyword_matcher_test.cpp @@ -260,7 +260,8 @@ string GetManyTokens(string tokenPrefix, int tokenCount, bool countForward = tru UNIT_TEST(KeywordMatcher_QueryTooLong) { static_assert(kMaxNumTokens >= 2, ""); - for (int queryLength = kMaxNumTokens - 2; queryLength <= kMaxNumTokens + 2; ++queryLength) + for (int queryLength = kMaxNumTokens - 2; + queryLength <= static_cast(kMaxNumTokens + 2); ++queryLength) { string const query = GetManyTokens("Q", queryLength); string const queryWithPrefix = query + " Prefix"; diff --git a/storage/storage_integration_tests/storage_http_tests.cpp b/storage/storage_integration_tests/storage_http_tests.cpp index cc4b727320..ad6ab5b9d7 100644 --- a/storage/storage_integration_tests/storage_http_tests.cpp +++ b/storage/storage_integration_tests/storage_http_tests.cpp @@ -102,8 +102,10 @@ UNIT_CLASS_TEST(StorageHttpTest, StorageDownloadNodeAndDeleteNode) NodeAttrs nodeAttrs; m_storage.GetNodeAttrs(countryId, nodeAttrs); - TEST_EQUAL(mapSize.first, nodeAttrs.m_downloadingProgress.first, (countryId)); - TEST_EQUAL(mapSize.second, nodeAttrs.m_downloadingProgress.second, (countryId)); + TEST_EQUAL(static_cast(mapSize.first), + nodeAttrs.m_downloadingProgress.first, (countryId)); + TEST_EQUAL(static_cast(mapSize.second), + nodeAttrs.m_downloadingProgress.second, (countryId)); TEST_EQUAL(countryId, kCountryId, (countryId)); }; @@ -142,8 +144,10 @@ UNIT_CLASS_TEST(StorageHttpTest, StorageDownloadAndDeleteDisputedNode) NodeAttrs nodeAttrs; m_storage.GetNodeAttrs(countryId, nodeAttrs); - TEST_EQUAL(mapSize.first, nodeAttrs.m_downloadingProgress.first, (countryId)); - TEST_EQUAL(mapSize.second, nodeAttrs.m_downloadingProgress.second, (countryId)); + TEST_EQUAL(static_cast(mapSize.first), + nodeAttrs.m_downloadingProgress.first, (countryId)); + TEST_EQUAL(static_cast(mapSize.second), + nodeAttrs.m_downloadingProgress.second, (countryId)); }; InitStorage(m_storage, UpdateWithoutChecks, progressFunction); diff --git a/storage/storage_tests/storage_tests.cpp b/storage/storage_tests/storage_tests.cpp index fba4184f13..8967c6d428 100644 --- a/storage/storage_tests/storage_tests.cpp +++ b/storage/storage_tests/storage_tests.cpp @@ -337,12 +337,14 @@ protected: LOG(LINFO, (m_countryFile, "downloading progress:", progress)); - TEST_GREATER(progress.first, m_bytesDownloaded, (m_countryFile)); + TEST_GREATER(progress.first, static_cast< + decltype(progress.first)>(m_bytesDownloaded), (m_countryFile)); m_bytesDownloaded = progress.first; TEST_LESS_OR_EQUAL(m_bytesDownloaded, m_totalBytesToDownload, (m_countryFile)); TLocalAndRemoteSize localAndRemoteSize = m_storage.CountrySizeInBytes(m_countryId, m_files); - TEST_EQUAL(m_totalBytesToDownload, localAndRemoteSize.second, (m_countryFile)); + TEST_EQUAL(static_cast(m_totalBytesToDownload), + localAndRemoteSize.second, (m_countryFile)); } Storage & m_storage; @@ -1435,12 +1437,12 @@ UNIT_TEST(StorageTest_GetUpdateInfoSingleMwm) storage.GetUpdateInfo("OutdatedCountry1", updateInfo); TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 1, ()); TEST_EQUAL(updateInfo.m_totalUpdateSizeInBytes, 50, ()); - TEST_EQUAL(updateInfo.m_sizeDifference, 50 - country1Size, ()); + TEST_EQUAL(updateInfo.m_sizeDifference, static_cast(50 - country1Size), ()); storage.GetUpdateInfo("OutdatedCountry2", updateInfo); TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 1, ()); TEST_EQUAL(updateInfo.m_totalUpdateSizeInBytes, 1000, ()); - TEST_EQUAL(updateInfo.m_sizeDifference, 1000 - country2Size, ()); + TEST_EQUAL(updateInfo.m_sizeDifference, static_cast(1000 - country2Size), ()); storage.GetUpdateInfo("Abkhazia", updateInfo); TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 0, ()); @@ -1457,7 +1459,8 @@ UNIT_TEST(StorageTest_GetUpdateInfoSingleMwm) storage.GetUpdateInfo(storage.GetRootId(), updateInfo); TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 2, ()); TEST_EQUAL(updateInfo.m_totalUpdateSizeInBytes, 1050, ()); - TEST_EQUAL(updateInfo.m_sizeDifference, (1000 + 50) - (country1Size + country2Size), ()); + TEST_EQUAL(updateInfo.m_sizeDifference, + static_cast((1000 + 50) - (country1Size + country2Size)), ()); } #endif // defined(OMIM_OS_DESKTOP) From 1c9ae86fe0d701af12fcb8c9548bd870ba61f4fa Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Mon, 25 Jun 2018 17:57:42 +0300 Subject: [PATCH 02/12] After merge --- base/assert.hpp | 7 +++++++ base/base_tests/levenshtein_dfa_test.cpp | 2 ++ coding/compressed_bit_vector.cpp | 2 ++ coding/zlib.cpp | 2 ++ editor/edits_migration.cpp | 2 ++ editor/osm_editor.cpp | 1 + editor/xml_feature.cpp | 2 ++ generator/osm_element.cpp | 2 ++ geometry/line2d.cpp | 2 ++ indexer/feature_decl.cpp | 2 ++ indexer/ftraits.hpp | 2 ++ indexer/ftypes_matcher.cpp | 2 ++ indexer/mwm_set.cpp | 2 ++ indexer/postcodes_matcher.cpp | 2 ++ kml/serdes.cpp | 2 ++ kml/types.hpp | 6 ++++++ map/booking_filter_cache.cpp | 2 ++ map/bookmark.cpp | 4 ++++ map/bookmark_helpers.hpp | 2 ++ map/bookmark_manager.cpp | 2 ++ map/chart_generator.cpp | 4 ++++ map/cloud.cpp | 2 ++ map/cloud.hpp | 6 ++++++ map/discovery/discovery_manager.cpp | 2 ++ map/mwm_url.cpp | 2 ++ map/osm_opening_hours.hpp | 2 ++ map/routing_manager.cpp | 2 ++ map/routing_mark.cpp | 4 ++++ map/user.cpp | 2 ++ map/user_mark.cpp | 2 ++ partners_api/banner.hpp | 2 ++ partners_api/taxi_places_loader.cpp | 2 ++ partners_api/taxi_provider.hpp | 4 ++++ platform/country_defines.cpp | 2 ++ platform/local_country_file_utils.cpp | 2 ++ platform/measurement_utils.cpp | 4 ++++ platform/measurement_utils.hpp | 2 ++ platform/mwm_traits.cpp | 5 +++++ platform/platform.cpp | 4 ++++ platform/settings.cpp | 4 ++++ routing/cross_mwm_connector.cpp | 2 ++ routing/cross_mwm_connector.hpp | 2 ++ routing/edge_estimator.cpp | 2 ++ routing/index_router.cpp | 4 ++++ routing/index_router.hpp | 2 ++ routing/road_graph.cpp | 2 ++ routing/routing_session.cpp | 2 ++ routing/routing_settings.cpp | 2 ++ routing/transit_info.hpp | 2 ++ routing/vehicle_mask.cpp | 2 ++ search/geocoder.cpp | 2 ++ search/geocoder_context.cpp | 6 ++++++ search/geocoder_locality.cpp | 2 ++ search/house_numbers_matcher.cpp | 6 ++++++ search/mwm_context.cpp | 2 ++ search/nested_rects_cache.cpp | 2 ++ search/ranker.cpp | 4 ++++ search/retrieval.cpp | 4 ++-- storage/storage_defines.cpp | 10 ++++++++++ traffic/speed_groups.cpp | 2 ++ ugc/storage.hpp | 2 ++ 61 files changed, 171 insertions(+), 2 deletions(-) diff --git a/base/assert.hpp b/base/assert.hpp index 16c78dc89e..abbd8b01b9 100644 --- a/base/assert.hpp +++ b/base/assert.hpp @@ -91,3 +91,10 @@ namespace my #define ASSERT_GREATER(X, Y, msg) #define ASSERT_GREATER_OR_EQUAL(X, Y, msg) #endif + +// The macro that causes the warning to be ignored: control reaches end of +// non-void function. +#define INCORRECT_VALUE_IN_THE_SWITCH() do { \ + CHECK(false, ("Incorrect value in the switch statment")); \ + std::abort(); \ +} while(false) diff --git a/base/base_tests/levenshtein_dfa_test.cpp b/base/base_tests/levenshtein_dfa_test.cpp index 2d7cab01b1..2c27c0ea3b 100644 --- a/base/base_tests/levenshtein_dfa_test.cpp +++ b/base/base_tests/levenshtein_dfa_test.cpp @@ -42,6 +42,8 @@ string DebugPrint(Status status) case Status::Rejects: return "Rejects"; case Status::Intermediate: return "Intermediate"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(Result const & result) diff --git a/coding/compressed_bit_vector.cpp b/coding/compressed_bit_vector.cpp index 88a863c27f..01ed947c15 100644 --- a/coding/compressed_bit_vector.cpp +++ b/coding/compressed_bit_vector.cpp @@ -461,6 +461,8 @@ string DebugPrint(CompressedBitVector::StorageStrategy strat) case CompressedBitVector::StorageStrategy::Dense: return "Dense"; case CompressedBitVector::StorageStrategy::Sparse: return "Sparse"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } // static diff --git a/coding/zlib.cpp b/coding/zlib.cpp index 00412b3f7a..80b3c7ece5 100644 --- a/coding/zlib.cpp +++ b/coding/zlib.cpp @@ -19,6 +19,8 @@ int ToInt(ZLib::Deflate::Level level) case Level::BestCompression: return Z_BEST_COMPRESSION; case Level::DefaultCompression: return Z_DEFAULT_COMPRESSION; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace diff --git a/editor/edits_migration.cpp b/editor/edits_migration.cpp index 9230d751e2..f0d410fa52 100644 --- a/editor/edits_migration.cpp +++ b/editor/edits_migration.cpp @@ -118,5 +118,7 @@ FeatureID MigrateFeatureIndex(osm::Editor::ForEachFeaturesNearByFn & forEach, case XMLFeature::Type::Relation: return MigrateWayOrRelatonFeatureIndex(forEach, xml, featureStatus, generateID); } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace editor diff --git a/editor/osm_editor.cpp b/editor/osm_editor.cpp index c1f1c7aa1c..9aa56222cf 100644 --- a/editor/osm_editor.cpp +++ b/editor/osm_editor.cpp @@ -1210,5 +1210,6 @@ void Editor::LoadMwmEdits(xml_node const & mwm, MwmSet::MwmId const & mwmId, boo } } + const char * const Editor::kPlaceDoesNotExistMessage = "The place has gone or never existed. This is an auto-generated note from MAPS.ME application: a user reports a POI that is visible on a map (which can be outdated), but cannot be found on the ground."; } // namespace osm diff --git a/editor/xml_feature.cpp b/editor/xml_feature.cpp index 8ea1188845..1e785f06ea 100644 --- a/editor/xml_feature.cpp +++ b/editor/xml_feature.cpp @@ -400,6 +400,8 @@ string XMLFeature::TypeToString(Type type) case Type::Way: return kWayType; case Type::Relation: return kRelationType; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } // static diff --git a/generator/osm_element.cpp b/generator/osm_element.cpp index 2a12bb8a62..a6f63b7d4a 100644 --- a/generator/osm_element.cpp +++ b/generator/osm_element.cpp @@ -28,6 +28,8 @@ std::string DebugPrint(OsmElement::EntityType e) case OsmElement::EntityType::Member: return "member"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } diff --git a/geometry/line2d.cpp b/geometry/line2d.cpp index 061474463c..fc94522155 100644 --- a/geometry/line2d.cpp +++ b/geometry/line2d.cpp @@ -61,6 +61,8 @@ string DebugPrint(LineIntersector::Result::Type type) case Type::One: return "One"; case Type::Infinity: return "Infinity"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(LineIntersector::Result const & result) diff --git a/indexer/feature_decl.cpp b/indexer/feature_decl.cpp index 9ad4ac8572..6379891958 100644 --- a/indexer/feature_decl.cpp +++ b/indexer/feature_decl.cpp @@ -19,6 +19,8 @@ string DebugPrint(feature::EGeomType type) case EGeomType::GEOM_LINE: return "GEOM_LINE"; case EGeomType::GEOM_AREA: return "GEOM_AREA"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } // static diff --git a/indexer/ftraits.hpp b/indexer/ftraits.hpp index 83e4c73ccb..4af7c9874d 100644 --- a/indexer/ftraits.hpp +++ b/indexer/ftraits.hpp @@ -207,6 +207,8 @@ inline std::string DebugPrint(WheelchairAvailability wheelchair) case WheelchairAvailability::Yes: return "Yes"; case WheelchairAvailability::Limited: return "Limited"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } class Wheelchair : public TraitsBase diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 09c739be36..5caf6ae454 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -357,6 +357,8 @@ char const * IsHotelChecker::GetHotelTypeTag(Type type) case Type::Resort: return "resort"; case Type::Count: CHECK(false, ("Can't get hotel type tag")); return ""; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } IsWifiChecker::IsWifiChecker() diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 6b2766cb26..855555310f 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -448,6 +448,8 @@ string DebugPrint(MwmSet::RegResult result) case MwmSet::RegResult::UnsupportedFileFormat: return "UnsupportedFileFormat"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(MwmSet::Event::Type type) diff --git a/indexer/postcodes_matcher.cpp b/indexer/postcodes_matcher.cpp index 7eacf1fe1b..031de717f0 100644 --- a/indexer/postcodes_matcher.cpp +++ b/indexer/postcodes_matcher.cpp @@ -64,6 +64,8 @@ public: case TStringSet::Status::Prefix: return isPrefix; case TStringSet::Status::Full: return true; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } inline size_t GetMaxNumTokensInPostcode() const { return m_maxNumTokensInPostcode; } diff --git a/kml/serdes.cpp b/kml/serdes.cpp index 0fbb0fdeed..a0cb2c018d 100644 --- a/kml/serdes.cpp +++ b/kml/serdes.cpp @@ -122,6 +122,8 @@ std::string GetStyleForPredefinedColor(PredefinedColor color) case PredefinedColor::Count: return {}; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } BookmarkIcon GetIcon(std::string const & iconName) diff --git a/kml/types.hpp b/kml/types.hpp index 76d6d525ac..ec862f1fdd 100644 --- a/kml/types.hpp +++ b/kml/types.hpp @@ -43,6 +43,8 @@ inline std::string DebugPrint(PredefinedColor color) case PredefinedColor::Orange: return "Orange"; case PredefinedColor::Count: return {}; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } enum class AccessRules : uint8_t @@ -61,6 +63,8 @@ inline std::string DebugPrint(AccessRules accessRules) case AccessRules::Public: return "Public"; case AccessRules::Count: return {}; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } enum class BookmarkIcon : uint16_t @@ -116,6 +120,8 @@ inline std::string DebugPrint(BookmarkIcon icon) case BookmarkIcon::Water: return "Water"; case BookmarkIcon::Count: return {}; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } struct ColorData diff --git a/map/booking_filter_cache.cpp b/map/booking_filter_cache.cpp index 32dc68d6ae..8db2cafbb1 100644 --- a/map/booking_filter_cache.cpp +++ b/map/booking_filter_cache.cpp @@ -106,6 +106,8 @@ std::string DebugPrint(Cache::HotelStatus status) case Cache::HotelStatus::Unavailable: return "Unavailable"; case Cache::HotelStatus::Available: return "Available"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace availability } // namespace filter diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 6f766b75c0..58599d4302 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -36,6 +36,8 @@ std::string GetBookmarkIconType(kml::BookmarkIcon const & icon) ASSERT(false, ("Invalid bookmark icon type")); return {}; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace @@ -105,6 +107,8 @@ df::ColorConstant Bookmark::GetColorConstant() const case kml::PredefinedColor::Count: return "BookmarkRed"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } bool Bookmark::HasCreationAnimation() const diff --git a/map/bookmark_helpers.hpp b/map/bookmark_helpers.hpp index fba7c17565..f2b4d0dad8 100644 --- a/map/bookmark_helpers.hpp +++ b/map/bookmark_helpers.hpp @@ -26,6 +26,8 @@ inline std::string DebugPrint(KmlFileType fileType) case KmlFileType::Text: return "Text"; case KmlFileType::Binary: return "Binary"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } std::unique_ptr LoadKmlFile(std::string const & file, KmlFileType fileType); diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 3fa0a056ca..90c2514cf9 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -97,6 +97,8 @@ bool IsValidFilterType(BookmarkManager::CategoryFilterType const filter, case BookmarkManager::CategoryFilterType::Public: return fromCatalog; case BookmarkManager::CategoryFilterType::Private: return !fromCatalog; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } class FindMarkFunctor diff --git a/map/chart_generator.cpp b/map/chart_generator.cpp index 6d1f754674..efaefca667 100644 --- a/map/chart_generator.cpp +++ b/map/chart_generator.cpp @@ -63,6 +63,8 @@ agg::rgba8 GetLineColor(MapStyle mapStyle) case MapStyleMerged: return agg::rgba8(30, 150, 240, 255); } + + INCORRECT_VALUE_IN_THE_SWITCH(); } agg::rgba8 GetCurveColor(MapStyle mapStyle) @@ -80,6 +82,8 @@ agg::rgba8 GetCurveColor(MapStyle mapStyle) case MapStyleMerged: return agg::rgba8(30, 150, 240, 20); } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace diff --git a/map/cloud.cpp b/map/cloud.cpp index 6614784d42..4337ff024d 100644 --- a/map/cloud.cpp +++ b/map/cloud.cpp @@ -128,6 +128,8 @@ bool CanUpload(uint64_t totalUploadingSize) return platform::GetCurrentNetworkPolicy().CanUse() && totalUploadingSize <= kMaxWwanUploadingSizeInBytes; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } struct SnapshotCreateRequestData diff --git a/map/cloud.hpp b/map/cloud.hpp index 2482cdfee7..0639b8ac64 100644 --- a/map/cloud.hpp +++ b/map/cloud.hpp @@ -391,6 +391,8 @@ inline std::string DebugPrint(Cloud::SynchronizationType type) case Cloud::SynchronizationType::Backup: return "Backup"; case Cloud::SynchronizationType::Restore: return "Restore"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } inline std::string DebugPrint(Cloud::SynchronizationResult result) @@ -404,6 +406,8 @@ inline std::string DebugPrint(Cloud::SynchronizationResult result) case Cloud::SynchronizationResult::UserInterrupted: return "UserInterrupted"; case Cloud::SynchronizationResult::InvalidCall: return "InvalidCall"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } inline std::string DebugPrint(Cloud::RestoringRequestResult result) @@ -414,4 +418,6 @@ inline std::string DebugPrint(Cloud::RestoringRequestResult result) case Cloud::RestoringRequestResult::NoBackup: return "NoBackup"; case Cloud::RestoringRequestResult::NotEnoughDiskSpace: return "NotEnoughDiskSpace"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } diff --git a/map/discovery/discovery_manager.cpp b/map/discovery/discovery_manager.cpp index 40965df746..7cf9a54eb1 100644 --- a/map/discovery/discovery_manager.cpp +++ b/map/discovery/discovery_manager.cpp @@ -16,6 +16,8 @@ std::string GetQuery(discovery::ItemType const type) case discovery::ItemType::LocalExperts: case discovery::ItemType::Viator: ASSERT(false, ()); return ""; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace diff --git a/map/mwm_url.cpp b/map/mwm_url.cpp index e78a4b1bfb..b1eee93812 100644 --- a/map/mwm_url.cpp +++ b/map/mwm_url.cpp @@ -259,6 +259,8 @@ ParsedMapApi::ParsingResult ParsedMapApi::Parse(Uri const & uri) return ParsingResult::Lead; } } + + INCORRECT_VALUE_IN_THE_SWITCH(); } bool ParsedMapApi::RouteKeyValue(string const & key, string const & value, vector & pattern) diff --git a/map/osm_opening_hours.hpp b/map/osm_opening_hours.hpp index ea725fdea0..368ff84d6c 100644 --- a/map/osm_opening_hours.hpp +++ b/map/osm_opening_hours.hpp @@ -27,6 +27,8 @@ inline string DebugPrint(EPlaceState state) case EPlaceState::CloseSoon: return "EPlaceState::CloseSoon"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } inline EPlaceState PlaceStateCheck(string const & openingHours, time_t timestamp) diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index 6ee463daf2..2347deaceb 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -207,6 +207,8 @@ VehicleType GetVehicleType(RouterType routerType) case RouterType::Transit: return VehicleType::Transit; case RouterType::Count: CHECK(false, ("Invalid type", routerType)); return VehicleType::Count; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace diff --git a/map/routing_mark.cpp b/map/routing_mark.cpp index 1a43dcb79d..0ab90d534c 100644 --- a/map/routing_mark.cpp +++ b/map/routing_mark.cpp @@ -102,6 +102,8 @@ uint16_t RouteMarkPoint::GetPriority() const } } } + + INCORRECT_VALUE_IN_THE_SWITCH(); } uint32_t RouteMarkPoint::GetIndex() const @@ -112,6 +114,8 @@ uint32_t RouteMarkPoint::GetIndex() const case RouteMarkType::Finish: return 1; case RouteMarkType::Intermediate: return static_cast(m_markData.m_intermediateIndex + 2); } + + INCORRECT_VALUE_IN_THE_SWITCH(); } void RouteMarkPoint::SetMarkData(RouteMarkData && data) diff --git a/map/user.cpp b/map/user.cpp index 0804180a41..ef4fcc8696 100644 --- a/map/user.cpp +++ b/map/user.cpp @@ -68,6 +68,8 @@ std::string AuthenticationUrl(std::string const & socialToken, return ss.str(); } } + + INCORRECT_VALUE_IN_THE_SWITCH(); } std::string UserDetailsUrl() diff --git a/map/user_mark.cpp b/map/user_mark.cpp index bed1e11490..f757f29f33 100644 --- a/map/user_mark.cpp +++ b/map/user_mark.cpp @@ -86,4 +86,6 @@ string DebugPrint(UserMark::Type type) case UserMark::Type::USER_MARK_TYPES_COUNT: return "USER_MARK_TYPES_COUNT"; case UserMark::Type::USER_MARK_TYPES_COUNT_MAX: return "USER_MARK_TYPES_COUNT_MAX"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } diff --git a/partners_api/banner.hpp b/partners_api/banner.hpp index 706dda5c43..bbee5c477f 100644 --- a/partners_api/banner.hpp +++ b/partners_api/banner.hpp @@ -32,5 +32,7 @@ inline std::string DebugPrint(Banner::Type type) case Banner::Type::Mopub: return "Mopub"; case Banner::Type::Google: return "Google"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace ads diff --git a/partners_api/taxi_places_loader.cpp b/partners_api/taxi_places_loader.cpp index 4c8288b40a..1bf69ae6cb 100644 --- a/partners_api/taxi_places_loader.cpp +++ b/partners_api/taxi_places_loader.cpp @@ -55,6 +55,8 @@ std::string Loader::GetFileNameByProvider(Provider::Type const type) case Provider::Type::Yandex: return "taxi_places/yandex.json"; case Provider::Type::Count: LOG(LERROR, ("Incorrect taxi provider")); return ""; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace places } // namespace taxi diff --git a/partners_api/taxi_provider.hpp b/partners_api/taxi_provider.hpp index 32a3019e7c..f1ca17d852 100644 --- a/partners_api/taxi_provider.hpp +++ b/partners_api/taxi_provider.hpp @@ -82,6 +82,8 @@ inline std::string DebugPrint(Provider::Type type) case Provider::Type::Maxim: return "Maxim"; case Provider::Type::Count: ASSERT(false, ()); return ""; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } inline std::string DebugPrint(ErrorCode code) @@ -91,6 +93,8 @@ inline std::string DebugPrint(ErrorCode code) case ErrorCode::NoProducts: return "NoProducts"; case ErrorCode::RemoteError: return "RemoteError"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } inline std::string DebugPrint(ProviderError error) diff --git a/platform/country_defines.cpp b/platform/country_defines.cpp index d6ab946822..4fd2b7684a 100644 --- a/platform/country_defines.cpp +++ b/platform/country_defines.cpp @@ -38,4 +38,6 @@ string DebugPrint(MapOptions options) case MapOptions::Diff: return "Diff"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } diff --git a/platform/local_country_file_utils.cpp b/platform/local_country_file_utils.cpp index c71990b408..ac507eaf57 100644 --- a/platform/local_country_file_utils.cpp +++ b/platform/local_country_file_utils.cpp @@ -467,5 +467,7 @@ string DebugPrint(CountryIndexes::Index index) case CountryIndexes::Index::Offsets: return "Offsets"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace platform diff --git a/platform/measurement_utils.cpp b/platform/measurement_utils.cpp index f591e7aeb3..a0d48dc25d 100644 --- a/platform/measurement_utils.cpp +++ b/platform/measurement_utils.cpp @@ -63,6 +63,8 @@ bool FormatDistance(double m, string & res) case Units::Imperial: return FormatDistanceImpl(m, res, " mi", " ft", 1609.344, 0.3048); case Units::Metric: return FormatDistanceImpl(m, res, " km", " m", 1000.0, 1.0); } + + INCORRECT_VALUE_IN_THE_SWITCH(); } @@ -209,6 +211,8 @@ string FormatSpeedUnits(Units units) case Units::Imperial: return "mph"; case Units::Metric: return "km/h"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } bool OSMDistanceToMeters(string const & osmRawValue, double & outMeters) diff --git a/platform/measurement_utils.hpp b/platform/measurement_utils.hpp index 00a67a1754..3af3248ac6 100644 --- a/platform/measurement_utils.hpp +++ b/platform/measurement_utils.hpp @@ -19,6 +19,8 @@ inline string DebugPrint(Units units) case Units::Imperial: return "Units::Imperial"; case Units::Metric: return "Units::Metric"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } inline double MetersToMiles(double m) { return m * 0.000621371192; } diff --git a/platform/mwm_traits.cpp b/platform/mwm_traits.cpp index 9ec21e7212..d9d3355b6c 100644 --- a/platform/mwm_traits.cpp +++ b/platform/mwm_traits.cpp @@ -1,6 +1,7 @@ #include "mwm_traits.hpp" #include "base/logging.hpp" +#include "base/macros.hpp" namespace version { @@ -39,6 +40,8 @@ string DebugPrint(MwmTraits::SearchIndexFormat format) case MwmTraits::SearchIndexFormat::CompressedBitVector: return "CompressedBitVector"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(MwmTraits::HouseToStreetTableFormat format) @@ -50,5 +53,7 @@ string DebugPrint(MwmTraits::HouseToStreetTableFormat format) case MwmTraits::HouseToStreetTableFormat::Unknown: return "Unknown"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace version diff --git a/platform/platform.cpp b/platform/platform.cpp index 39a9e86905..39cb0589e3 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -306,6 +306,8 @@ string DebugPrint(Platform::EError err) case Platform::ERR_IO_ERROR: return "An I/O error occurred."; case Platform::ERR_UNKNOWN: return "Unknown"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(Platform::ChargingStatus status) @@ -316,4 +318,6 @@ string DebugPrint(Platform::ChargingStatus status) case Platform::ChargingStatus::Plugged: return "Plugged"; case Platform::ChargingStatus::Unplugged: return "Unplugged"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } diff --git a/platform/settings.cpp b/platform/settings.cpp index 7d9afacfd3..ac608631c7 100644 --- a/platform/settings.cpp +++ b/platform/settings.cpp @@ -280,6 +280,8 @@ string ToString(measurement_utils::Units const & v) case measurement_utils::Units::Imperial: return "Foot"; case measurement_utils::Units::Metric: return "Metric"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } template <> @@ -336,6 +338,8 @@ string ToString(Transliteration::Mode const & mode) case Transliteration::Mode::Enabled: return "Enabled"; case Transliteration::Mode::Disabled: return "Disabled"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } template <> diff --git a/routing/cross_mwm_connector.cpp b/routing/cross_mwm_connector.cpp index f4de901e22..5b662b2e44 100644 --- a/routing/cross_mwm_connector.cpp +++ b/routing/cross_mwm_connector.cpp @@ -13,6 +13,8 @@ std::string DebugPrint(WeightsLoadState state) case WeightsLoadState::NotExists: return "NotExists"; case WeightsLoadState::Loaded: return "Loaded"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace connector } // namespace routing diff --git a/routing/cross_mwm_connector.hpp b/routing/cross_mwm_connector.hpp index cec680a002..7d623dbea6 100644 --- a/routing/cross_mwm_connector.hpp +++ b/routing/cross_mwm_connector.hpp @@ -180,6 +180,8 @@ public: case connector::WeightsLoadState::NotExists: case connector::WeightsLoadState::Loaded: return true; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } template diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index 58cb9013d1..0c257d3034 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -214,6 +214,8 @@ shared_ptr EdgeEstimator::Create(VehicleType vehicleType, double CHECK(false, ("Can't create EdgeEstimator for", vehicleType)); return nullptr; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } // static diff --git a/routing/index_router.cpp b/routing/index_router.cpp index dfb30a7cc6..d5f7145fdd 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -98,6 +98,8 @@ shared_ptr CreateVehicleModelFactory( CHECK(false, ("Can't create VehicleModelFactoryInterface for", vehicleType)); return nullptr; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } unique_ptr CreateDirectionsEngine(VehicleType vehicleType, @@ -115,6 +117,8 @@ unique_ptr CreateDirectionsEngine(VehicleType vehicleType, CHECK(false, ("Can't create DirectionsEngine for", vehicleType)); return nullptr; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } shared_ptr CreateTrafficStash(VehicleType vehicleType, shared_ptr numMwmIds, diff --git a/routing/index_router.hpp b/routing/index_router.hpp index 4b7ec5b7b6..893aa48fad 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -127,6 +127,8 @@ private: case AStarAlgorithm::Result::Cancelled: return RouterResultCode::Cancelled; case AStarAlgorithm::Result::OK: return RouterResultCode::NoError; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } template diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp index f152dbfd9e..f6889ea047 100644 --- a/routing/road_graph.cpp +++ b/routing/road_graph.cpp @@ -310,6 +310,8 @@ string DebugPrint(IRoadGraph::Mode mode) case IRoadGraph::Mode::ObeyOnewayTag: return "ObeyOnewayTag"; case IRoadGraph::Mode::IgnoreOnewayTag: return "IgnoreOnewayTag"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } IRoadGraph::RoadInfo MakeRoadInfoForTesting(bool bidirectional, double speedKMPH, diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index fcd91502a3..e27afd7085 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -802,5 +802,7 @@ string DebugPrint(RoutingSession::State state) case RoutingSession::RouteNoFollowing: return "RouteNoFollowing"; case RoutingSession::RouteRebuilding: return "RouteRebuilding"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace routing diff --git a/routing/routing_settings.cpp b/routing/routing_settings.cpp index c3a26f9899..1117dc1fcf 100644 --- a/routing/routing_settings.cpp +++ b/routing/routing_settings.cpp @@ -26,5 +26,7 @@ RoutingSettings GetRoutingSettings(VehicleType vehicleType) CHECK(false, ("Can't create GetRoutingSettings for", vehicleType)); return {}; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace routing diff --git a/routing/transit_info.hpp b/routing/transit_info.hpp index 7393f04410..14e84fa49b 100644 --- a/routing/transit_info.hpp +++ b/routing/transit_info.hpp @@ -149,5 +149,7 @@ inline std::string DebugPrint(TransitInfo::Type type) case TransitInfo::Type::Edge: return "Edge"; case TransitInfo::Type::Transfer: return "Transfer"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace routing diff --git a/routing/vehicle_mask.cpp b/routing/vehicle_mask.cpp index bf9a60cff1..d87039b51d 100644 --- a/routing/vehicle_mask.cpp +++ b/routing/vehicle_mask.cpp @@ -19,6 +19,8 @@ string DebugPrint(VehicleType vehicleType) case VehicleType::Transit: return "Transit"; case VehicleType::Count: return "Count"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string ToString(VehicleType vehicleType) { return DebugPrint(vehicleType); } diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 0ee6a292f5..2b13b6c2ff 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -1414,6 +1414,8 @@ CBV Geocoder::RetrieveGeometryFeatures(MwmContext const & context, m2::RectD con case RECT_ID_LOCALITY: return m_localityRectsCache.Get(context, rect, m_params.GetScale()); case RECT_ID_COUNT: ASSERT(false, ("Invalid RectId.")); return CBV(); } + + INCORRECT_VALUE_IN_THE_SWITCH(); } bool Geocoder::GetTypeInGeocoding(BaseContext const & ctx, uint32_t featureId, Model::Type & type) diff --git a/search/geocoder_context.cpp b/search/geocoder_context.cpp index 50bc7025f6..e3fabd4184 100644 --- a/search/geocoder_context.cpp +++ b/search/geocoder_context.cpp @@ -24,6 +24,8 @@ BaseContext::TokenType BaseContext::FromModelType(Model::Type type) case Model::TYPE_COUNTRY: return TOKEN_TYPE_COUNTRY; case Model::TYPE_COUNT: return TOKEN_TYPE_COUNT; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } // static @@ -35,6 +37,8 @@ BaseContext::TokenType BaseContext::FromRegionType(Region::Type type) case Region::TYPE_COUNTRY: return TOKEN_TYPE_COUNTRY; case Region::TYPE_COUNT: return TOKEN_TYPE_COUNT; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } size_t BaseContext::SkipUsedTokens(size_t curToken) const @@ -97,5 +101,7 @@ string DebugPrint(BaseContext::TokenType type) case BaseContext::TOKEN_TYPE_POSTCODE: return "POSTCODE"; case BaseContext::TOKEN_TYPE_COUNT: return "COUNT"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace search diff --git a/search/geocoder_locality.cpp b/search/geocoder_locality.cpp index 2cf619eff0..3e982d9645 100644 --- a/search/geocoder_locality.cpp +++ b/search/geocoder_locality.cpp @@ -13,6 +13,8 @@ Model::Type Region::ToModelType(Type type) case Region::TYPE_COUNTRY: return Model::TYPE_COUNTRY; case Region::TYPE_COUNT: return Model::TYPE_COUNT; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } std::string DebugPrint(Locality const & locality) diff --git a/search/house_numbers_matcher.cpp b/search/house_numbers_matcher.cpp index 06da74bf05..1b6c5fee08 100644 --- a/search/house_numbers_matcher.cpp +++ b/search/house_numbers_matcher.cpp @@ -166,6 +166,8 @@ public: case TStrings::Status::Prefix: return isPrefix; case TStrings::Status::Full: return true; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } private: @@ -236,6 +238,8 @@ public: case TPatterns::Status::Prefix: return true; case TPatterns::Status::Full: return true; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } private: @@ -250,6 +254,8 @@ private: case 'U': return Token::TYPE_BUILDING_PART_OR_LETTER; default: CHECK(false, ("Unexpected character:", c)); return Token::TYPE_SEPARATOR; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } static Token::Type TokenToType(Token const & token) { return token.m_type; } diff --git a/search/mwm_context.cpp b/search/mwm_context.cpp index 433200e225..a911e8a006 100644 --- a/search/mwm_context.cpp +++ b/search/mwm_context.cpp @@ -37,6 +37,8 @@ bool MwmContext::GetFeature(uint32_t index, FeatureType & ft) const ft.SetID(FeatureID(GetId(), index)); return true; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } bool MwmContext::GetStreetIndex(uint32_t houseId, uint32_t & streetId) diff --git a/search/nested_rects_cache.cpp b/search/nested_rects_cache.cpp index a3e2b8b294..cf20c23f50 100644 --- a/search/nested_rects_cache.cpp +++ b/search/nested_rects_cache.cpp @@ -82,6 +82,8 @@ double NestedRectsCache::GetRadiusMeters(RectScale scale) case RECT_SCALE_LARGE: return 2500.0; case RECT_SCALE_COUNT: return 5000.0; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } void NestedRectsCache::Update() diff --git a/search/ranker.cpp b/search/ranker.cpp index b4c39cb4c8..a7445935ab 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -145,6 +145,8 @@ ftypes::Type GetLocalityIndex(feature::TypesHolder const & types) case VILLAGE: return NONE; case LOCALITY_COUNT: return type; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } // TODO: Format street and house number according to local country's rules. @@ -430,6 +432,8 @@ Result Ranker::MakeResult(RankerResult const & rankerResult, bool needAddress, case RankerResult::Type::TYPE_LATLON: return Result(r.GetCenter(), name, address); } ASSERT(false, ("Bad RankerResult type:", static_cast(r.GetResultType()))); + + INCORRECT_VALUE_IN_THE_SWITCH(); }; auto res = mk(rankerResult); diff --git a/search/retrieval.cpp b/search/retrieval.cpp index a94d292458..fe80a7c2d9 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -367,14 +367,14 @@ unique_ptr Retrieval::Retrieve(Args &&... args) con ASSERT(m_root0, ()); return r(*m_root0, m_context, m_cancellable, forward(args)...); } - break; case version::MwmTraits::SearchIndexFormat::CompressedBitVector: { R r; ASSERT(m_root1, ()); return r(*m_root1, m_context, m_cancellable, forward(args)...); } - break; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace search diff --git a/storage/storage_defines.cpp b/storage/storage_defines.cpp index 17e359bb5c..c4d6d07776 100644 --- a/storage/storage_defines.cpp +++ b/storage/storage_defines.cpp @@ -1,5 +1,7 @@ #include "storage/storage_defines.hpp" +#include "base/assert.hpp" + #include using namespace std; @@ -32,6 +34,8 @@ string DebugPrint(Status status) case Status::EOutOfMemFailed: return "OutOfMemFailed"s; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(NodeStatus status) @@ -57,6 +61,8 @@ string DebugPrint(NodeStatus status) case NodeStatus::Partly: return "Partly"s; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(NodeErrorCode status) @@ -72,6 +78,8 @@ string DebugPrint(NodeErrorCode status) case NodeErrorCode::NoInetConnection: return "NoInetConnection"s; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } StatusAndError ParseStatus(Status innerStatus) @@ -99,6 +107,8 @@ StatusAndError ParseStatus(Status innerStatus) case Status::EOutOfMemFailed: return StatusAndError(NodeStatus::Error, NodeErrorCode::OutOfMemFailed); } + + INCORRECT_VALUE_IN_THE_SWITCH(); } string DebugPrint(StatusAndError statusAndError) diff --git a/traffic/speed_groups.cpp b/traffic/speed_groups.cpp index 926be45bfd..ff7e6f23a1 100644 --- a/traffic/speed_groups.cpp +++ b/traffic/speed_groups.cpp @@ -34,5 +34,7 @@ string DebugPrint(SpeedGroup const & group) case SpeedGroup::Unknown: return "Unknown"; case SpeedGroup::Count: return "Count"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace traffic diff --git a/ugc/storage.hpp b/ugc/storage.hpp index 9f1b2c337d..4a86993ad7 100644 --- a/ugc/storage.hpp +++ b/ugc/storage.hpp @@ -59,6 +59,8 @@ inline std::string DebugPrint(Storage::SettingResult const & result) case Storage::SettingResult::InvalidUGC: return "Invalid UGC"; case Storage::SettingResult::WritingError: return "Writing Error"; } + + INCORRECT_VALUE_IN_THE_SWITCH(); } } // namespace ugc From ff599cbaa1361e37c53c0644113494981c0fe977 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Thu, 21 Jun 2018 20:28:14 +0300 Subject: [PATCH 03/12] Fixed warn: multi-line comment --- routing/routing_tests/restriction_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routing/routing_tests/restriction_test.cpp b/routing/routing_tests/restriction_test.cpp index bc7fbf47cc..ee4793123a 100644 --- a/routing/routing_tests/restriction_test.cpp +++ b/routing/routing_tests/restriction_test.cpp @@ -217,13 +217,13 @@ UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionNoF5F2RestrictionOnl // F4 // | // 2 * -// | \ +// | ↖ // F0 F2 -// | \ +// | ↖ // 1 * * -// | \ +// | ↖ // F0 F2 -// | \ +// | ↖ // 0 *---F1--*--F1--*--F3---* Start // 0 1 2 3 // Note. All features are two setments and two-way. From b41b621bce0eae7744d1b9cad634bdf1a28eead2 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 11:17:16 +0300 Subject: [PATCH 04/12] Killed 3party warnings --- 3party/agg/CMakeLists.txt | 1 + 3party/freetype/CMakeLists.txt | 2 ++ 3party/icu/CMakeLists.txt | 1 + 3party/minizip/CMakeLists.txt | 1 + 3party/opening_hours/CMakeLists.txt | 2 ++ 3party/succinct/CMakeLists.txt | 1 + cmake/OmimHelpers.cmake | 6 ++++++ 7 files changed, 14 insertions(+) diff --git a/3party/agg/CMakeLists.txt b/3party/agg/CMakeLists.txt index 1d21209693..5c506574b9 100644 --- a/3party/agg/CMakeLists.txt +++ b/3party/agg/CMakeLists.txt @@ -1,6 +1,7 @@ project(agg) add_clang_compile_options("-Wno-deprecated-declarations") +add_gcc_compile_options("-Wno-deprecated-declarations") set(CMAKE_PREFIX_PATH ./) diff --git a/3party/freetype/CMakeLists.txt b/3party/freetype/CMakeLists.txt index bc4005c2b9..d3ab9c9a70 100644 --- a/3party/freetype/CMakeLists.txt +++ b/3party/freetype/CMakeLists.txt @@ -9,6 +9,8 @@ endif () add_compile_options("-Wall") add_clang_compile_options("-Wno-unused-function") +add_gcc_compile_options("-Wno-pointer-to-int-cast") +add_gcc_compile_options("-Wno-unused-function") include_directories(include) diff --git a/3party/icu/CMakeLists.txt b/3party/icu/CMakeLists.txt index 7c1ffbc423..fb1ec350bb 100644 --- a/3party/icu/CMakeLists.txt +++ b/3party/icu/CMakeLists.txt @@ -11,6 +11,7 @@ add_definitions( ) add_clang_compile_options("-Wno-deprecated-declarations") +add_gcc_compile_options("-Wno-deprecated-declarations") set(CMAKE_PREFIX_PATH ./) diff --git a/3party/minizip/CMakeLists.txt b/3party/minizip/CMakeLists.txt index 728f1f5a55..8e41eafbaa 100644 --- a/3party/minizip/CMakeLists.txt +++ b/3party/minizip/CMakeLists.txt @@ -3,6 +3,7 @@ project(minizip) add_definitions(-DUSE_FILE32API -DNOCRYPT) add_clang_compile_options("-Wno-unused-value") +add_gcc_compile_options("-Wno-unused-value") set( SRC diff --git a/3party/opening_hours/CMakeLists.txt b/3party/opening_hours/CMakeLists.txt index 752184c616..616d9fc769 100644 --- a/3party/opening_hours/CMakeLists.txt +++ b/3party/opening_hours/CMakeLists.txt @@ -12,6 +12,8 @@ add_compile_options( ) add_clang_compile_options("-Wno-unused-local-typedef") +add_gcc_compile_options("-Wno-unused-local-typedef") +add_gcc_compile_options("-Wno-return-type") set( SRC diff --git a/3party/succinct/CMakeLists.txt b/3party/succinct/CMakeLists.txt index 030f2f055b..ad3d1e2ae0 100644 --- a/3party/succinct/CMakeLists.txt +++ b/3party/succinct/CMakeLists.txt @@ -5,6 +5,7 @@ add_definitions(-DLTC_NO_ROLC) include_directories(src/headers) add_clang_compile_options("-Wno-unused-local-typedef") +add_gcc_compile_options("-Wno-unused-local-typedef") set( SRC diff --git a/cmake/OmimHelpers.cmake b/cmake/OmimHelpers.cmake index 340de3905a..4fb6e4e4b4 100644 --- a/cmake/OmimHelpers.cmake +++ b/cmake/OmimHelpers.cmake @@ -162,6 +162,12 @@ function(add_clang_compile_options) endif() endfunction() +function(add_gcc_compile_options) + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + add_compile_options(${ARGV}) + endif() +endfunction() + function(export_directory_flags filename) get_directory_property(include_directories INCLUDE_DIRECTORIES) get_directory_property(definitions COMPILE_DEFINITIONS) From e5811353c10ed89000c1be6ecda98bd206094909 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 11:52:18 +0300 Subject: [PATCH 05/12] Disabled warn in boost headers. (Include dir marked as system) --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b697ce263e..9c34da3977 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,9 +203,10 @@ include_directories( ${CMAKE_HOME_DIRECTORY} ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} ) +include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) if (USE_ASAN) From bb257b4c22d9d56d6c0988d6883336ad191f5f74 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 12:38:48 +0300 Subject: [PATCH 06/12] Fixed warn: ignoring return value --- drape_frontend/gui/ruler_helper.cpp | 3 ++- map/bookmark_manager.cpp | 9 +++++++-- map/framework.cpp | 3 ++- map/gps_track_filter.cpp | 3 ++- map/routing_manager.cpp | 5 ++++- platform/measurement_utils.cpp | 10 +++++++--- qt/mainwindow.cpp | 4 +++- search/features_layer_matcher.hpp | 3 ++- 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/drape_frontend/gui/ruler_helper.cpp b/drape_frontend/gui/ruler_helper.cpp index 22be59f7f2..498afdcf82 100644 --- a/drape_frontend/gui/ruler_helper.cpp +++ b/drape_frontend/gui/ruler_helper.cpp @@ -225,7 +225,8 @@ double RulerHelper::CalcMetresDiff(double value) auto conversionFn = &Identity; auto units = measurement_utils::Units::Metric; - UNUSED_VALUE(settings::Get(settings::kMeasurementUnits, units)); + if (!settings::Get(settings::kMeasurementUnits, units)) + LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); if (units == measurement_utils::Units::Imperial) { diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 90c2514cf9..5bb39e6960 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -346,7 +346,10 @@ bool MigrateIfNeeded() { auto const newBookmarksDir = GetBookmarksDirectory(); if (!GetPlatform().IsFileExistsByFullPath(newBookmarksDir)) - UNUSED_VALUE(GetPlatform().MkDirChecked(newBookmarksDir)); + { + if(!GetPlatform().MkDirChecked(newBookmarksDir)) + LOG(LWARNING, ("Could not create directory:", newBookmarksDir)); + } OnMigrationSuccess(0 /* originalCount */, 0 /* convertedCount */); return true; } @@ -896,7 +899,9 @@ void BookmarkManager::SaveState() const void BookmarkManager::LoadState() { - UNUSED_VALUE(settings::Get(kLastEditedBookmarkCategory, m_lastCategoryUrl)); + if(!settings::Get(kLastEditedBookmarkCategory, m_lastCategoryUrl)) + LOG(LWARNING, ("Unable to read settings:", kLastEditedBookmarkCategory)); + uint32_t color; if (settings::Get(kLastEditedBookmarkColor, color) && color > static_cast(kml::PredefinedColor::None) && diff --git a/map/framework.cpp b/map/framework.cpp index 9f812536d1..ce6b0be202 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1924,7 +1924,8 @@ void Framework::SetupMeasurementSystem() GetPlatform().SetupMeasurementSystem(); auto units = measurement_utils::Units::Metric; - UNUSED_VALUE(settings::Get(settings::kMeasurementUnits, units)); + if (!settings::Get(settings::kMeasurementUnits, units)) + LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); m_routingManager.SetTurnNotificationsUnits(units); } diff --git a/map/gps_track_filter.cpp b/map/gps_track_filter.cpp index ef2db67c49..130d97d10e 100644 --- a/map/gps_track_filter.cpp +++ b/map/gps_track_filter.cpp @@ -57,7 +57,8 @@ GpsTrackFilter::GpsTrackFilter() , m_countLastInfo(0) , m_countAcceptedInfo(0) { - UNUSED_VALUE(settings::Get(kMinHorizontalAccuracyKey, m_minAccuracy)); + if (!settings::Get(kMinHorizontalAccuracyKey, m_minAccuracy)) + LOG(LWARNING, ("Unable to read settings:", kMinHorizontalAccuracyKey)); } void GpsTrackFilter::Process(vector const & inPoints, diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index 2347deaceb..af173a578f 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -1039,7 +1039,10 @@ bool RoutingManager::IsTrackingReporterEnabled() const return false; bool enableTracking = true; - UNUSED_VALUE(settings::Get(tracking::Reporter::kEnableTrackingKey, enableTracking)); + if (!settings::Get(tracking::Reporter::kEnableTrackingKey, enableTracking)) + LOG(LWARNING, ("Unable to read settings:", + tracking::Reporter::kEnableTrackingKey)); + return enableTracking; } diff --git a/platform/measurement_utils.cpp b/platform/measurement_utils.cpp index a0d48dc25d..f3352e36fa 100644 --- a/platform/measurement_utils.cpp +++ b/platform/measurement_utils.cpp @@ -7,6 +7,7 @@ #include "base/math.hpp" #include "base/stl_add.hpp" #include "base/string_utils.hpp" +#include "base/logging.hpp" #include "std/cstring.hpp" #include "std/iomanip.hpp" @@ -55,7 +56,8 @@ bool FormatDistanceImpl(double m, string & res, bool FormatDistance(double m, string & res) { auto units = Units::Metric; - UNUSED_VALUE(Get(settings::kMeasurementUnits, units)); + if (!Get(settings::kMeasurementUnits, units)) + LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); /// @todo Put string units resources. switch (units) @@ -165,7 +167,8 @@ void FormatMercator(m2::PointD const & mercator, string & lat, string & lon, int string FormatAltitude(double altitudeInMeters) { Units units = Units::Metric; - UNUSED_VALUE(Get(settings::kMeasurementUnits, units)); + if (!Get(settings::kMeasurementUnits, units)) + LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); ostringstream ss; ss << fixed << setprecision(0); @@ -182,7 +185,8 @@ string FormatAltitude(double altitudeInMeters) string FormatSpeedWithDeviceUnits(double metersPerSecond) { auto units = Units::Metric; - UNUSED_VALUE(Get(settings::kMeasurementUnits, units)); + if (!Get(settings::kMeasurementUnits, units)) + LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); return FormatSpeedWithUnits(metersPerSecond, units); } diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index bad2b9c906..09930b960e 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -124,7 +124,9 @@ MainWindow::MainWindow(Framework & framework, bool apiOpenGLES3, QString const & #ifndef NO_DOWNLOADER // Show intro dialog if necessary bool bShow = true; - (void)settings::Get("ShowWelcome", bShow); + const string showWelcome = "ShowWelcome"; + if (!settings::Get(showWelcome, bShow)) + LOG(LWARNING, ("Unable to read settings:", showWelcome)); if (bShow) { diff --git a/search/features_layer_matcher.hpp b/search/features_layer_matcher.hpp index 7742b6bb71..9433444d4e 100644 --- a/search/features_layer_matcher.hpp +++ b/search/features_layer_matcher.hpp @@ -377,7 +377,8 @@ private: /// Correct fix would be injection into ForEachInIntervalAndScale, so deleted features will /// never /// be emitted and used in other code. - UNUSED_VALUE(m_context->GetFeature(id, ft)); + if (!m_context->GetFeature(id, ft)) + LOG(LWARNING, ("GetFeature() returned false.")); } MwmContext * m_context; From 8497b01a73c1ce012f6612f01dd72a236f17e8b0 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 12:55:19 +0300 Subject: [PATCH 07/12] Fixed warn: mangled name for .. will change in C++17 because the exception specification is part of a function type --- CMakeLists.txt | 2 ++ cmake/OmimHelpers.cmake | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c34da3977..e746ece555 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,6 +261,8 @@ add_compile_options( ) add_clang_compile_options("-Wshorten-64-to-32") +add_clang_cpp_compile_options("-Wno-noexcept-type") +add_gcc_cpp_compile_options("-Wno-noexcept-type") add_subdirectory(base) add_subdirectory(coding) diff --git a/cmake/OmimHelpers.cmake b/cmake/OmimHelpers.cmake index 4fb6e4e4b4..0dbdb0c139 100644 --- a/cmake/OmimHelpers.cmake +++ b/cmake/OmimHelpers.cmake @@ -168,6 +168,18 @@ function(add_gcc_compile_options) endif() endfunction() +function(add_clang_cpp_compile_options) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options("$<$:${ARGV}>") + endif() +endfunction() + +function(add_gcc_cpp_compile_options) + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") + add_compile_options("$<$:${ARGV}>") + endif() +endfunction() + function(export_directory_flags filename) get_directory_property(include_directories INCLUDE_DIRECTORIES) get_directory_property(definitions COMPILE_DEFINITIONS) From e21efb9d6007addf436d978a053b0181d1356175 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 14:44:45 +0300 Subject: [PATCH 08/12] Removed unused locally typedefs --- map/chart_generator.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/map/chart_generator.cpp b/map/chart_generator.cpp index efaefca667..792aa1d66a 100644 --- a/map/chart_generator.cpp +++ b/map/chart_generator.cpp @@ -223,8 +223,6 @@ bool GenerateChartByPoints(uint32_t width, uint32_t height, vector c using TBlender = BlendAdaptor; using TPixelFormat = agg::pixfmt_custom_blend_rgba; using TBaseRenderer = agg::renderer_base; - using TPrimitivesRenderer = agg::renderer_primitives; - using TSolidRenderer = agg::renderer_scanline_aa_solid; using TPath = agg::poly_container_adaptor>; using TStroke = agg::conv_stroke; From 1143dd2b8abd07fd76e0c7a58df1acd1fda9ba1a Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 14:46:06 +0300 Subject: [PATCH 09/12] =?UTF-8?q?Fixed=20warn:=20suggest=20parentheses=20a?= =?UTF-8?q?round=20comparison=20in=20operand=20of=20=E2=80=98=3D=3D?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routing/routing_tests/index_graph_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index b4d6dbc045..3f42c487e2 100644 --- a/routing/routing_tests/index_graph_test.cpp +++ b/routing/routing_tests/index_graph_test.cpp @@ -309,8 +309,8 @@ UNIT_TEST(FindPathManhattan) ? finish.m_projections[0].m_segment.GetFeatureId() : finish.m_projections[0].m_segment.GetFeatureId() - kCitySize; - if (start.m_projections[0].m_segment.GetFeatureId() < kCitySize == - finish.m_projections[0].m_segment.GetFeatureId() < kCitySize) + if ((start.m_projections[0].m_segment.GetFeatureId() < kCitySize) == + (finish.m_projections[0].m_segment.GetFeatureId() < kCitySize)) { uint32_t segDelta = AbsDelta(start.m_projections[0].m_segment.GetSegmentIdx(), finish.m_projections[0].m_segment.GetSegmentIdx()); From f3e856daf41c6907a8e4c610d8d1135474b28d09 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 15:07:01 +0300 Subject: [PATCH 10/12] Fixed warn: subobject-linkage --- generator/osm_o5m_source.hpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/generator/osm_o5m_source.hpp b/generator/osm_o5m_source.hpp index c5f924ccd3..aec6d60a3e 100644 --- a/generator/osm_o5m_source.hpp +++ b/generator/osm_o5m_source.hpp @@ -2,6 +2,7 @@ #pragma once #include "base/stl_helpers.hpp" +#include "base/assert.hpp" #include #include @@ -14,10 +15,9 @@ #include #include -using TReadFunc = std::function; - -namespace +namespace osm { +using TReadFunc = std::function; class StreamBuffer { @@ -108,10 +108,7 @@ private: m_position = m_buffer.begin(); } }; -} // anonymous namespace -namespace osm -{ class O5MSource { From 2a8cf2837351996c39bd5e43843c21009f033f5c Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 15:18:30 +0300 Subject: [PATCH 11/12] Fixed warn: multi-line comment --- routing/routing_tests/index_graph_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index 3f42c487e2..c06482469d 100644 --- a/routing/routing_tests/index_graph_test.cpp +++ b/routing/routing_tests/index_graph_test.cpp @@ -352,7 +352,7 @@ UNIT_TEST(FindPathManhattan) // Roads y: // // fast road R0 * - * - * -1 -// / \ +// ↗ ↘ // slow road R1 * - - * - - * - - * - - * 0 // J0 J1 // From 5ea4f835145fe8edfa6facc32e15c46452450e48 Mon Sep 17 00:00:00 2001 From: Maksim Andrianov Date: Fri, 22 Jun 2018 20:34:26 +0300 Subject: [PATCH 12/12] Review fixes --- 3party/freetype/CMakeLists.txt | 6 +++-- 3party/opening_hours/CMakeLists.txt | 6 +++-- base/assert.hpp | 2 +- base/base_tests/levenshtein_dfa_test.cpp | 3 +-- base/base_tests/stl_helpers_test.cpp | 8 +++--- base/levenshtein_dfa.cpp | 4 +-- coding/compressed_bit_vector.cpp | 3 +-- coding/point_to_integer.cpp | 6 ++--- coding/zlib.cpp | 3 +-- drape_frontend/gui/ruler_helper.cpp | 3 +-- drape_frontend/user_event_stream.cpp | 1 + editor/edits_migration.cpp | 3 +-- editor/xml_feature.cpp | 3 +-- generator/osm_element.cpp | 3 +-- generator/osm_o5m_source.hpp | 2 +- geometry/line2d.cpp | 3 +-- indexer/feature_decl.cpp | 3 +-- indexer/ftraits.hpp | 3 +-- indexer/ftypes_matcher.cpp | 3 +-- indexer/interval_index_builder.hpp | 26 ++++++++++++------- indexer/mwm_set.cpp | 3 +-- indexer/postcodes_matcher.cpp | 3 +-- kml/serdes.cpp | 3 +-- kml/types.hpp | 9 +++---- map/booking_filter_cache.cpp | 3 +-- map/bookmark.cpp | 6 ++--- map/bookmark_helpers.hpp | 3 +-- map/bookmark_manager.cpp | 13 +++++----- map/chart_generator.cpp | 6 ++--- map/cloud.cpp | 3 +-- map/cloud.hpp | 9 +++---- map/discovery/discovery_manager.cpp | 2 +- map/framework.cpp | 3 +-- map/gps_track_filter.cpp | 3 +-- map/mwm_url.cpp | 3 +-- map/osm_opening_hours.hpp | 5 ++-- map/routing_manager.cpp | 7 ++--- map/routing_mark.cpp | 6 ++--- map/user.cpp | 3 +-- map/user_mark.cpp | 3 +-- .../openlr_assessment_tool/traffic_mode.cpp | 2 +- partners_api/banner.hpp | 5 ++-- partners_api/taxi_places_loader.cpp | 3 +-- partners_api/taxi_provider.hpp | 6 ++--- platform/country_defines.cpp | 3 +-- platform/local_country_file_utils.cpp | 3 +-- platform/measurement_utils.cpp | 15 ++++------- platform/measurement_utils.hpp | 3 +-- platform/mwm_traits.cpp | 6 ++--- platform/platform.cpp | 6 ++--- platform/settings.cpp | 6 ++--- platform/settings.hpp | 8 ++++++ qt/mainwindow.cpp | 5 ++-- routing/bicycle_directions.cpp | 2 +- routing/cross_mwm_connector.cpp | 3 +-- routing/cross_mwm_connector.hpp | 3 +-- routing/edge_estimator.cpp | 3 +-- routing/index_router.cpp | 14 +++++----- routing/index_router.hpp | 3 +-- routing/road_graph.cpp | 3 +-- routing/routing_session.cpp | 3 +-- routing/routing_settings.cpp | 3 +-- routing/routing_tests/index_graph_test.cpp | 2 +- routing/routing_tests/restriction_test.cpp | 8 +++--- routing/transit_info.hpp | 3 +-- routing/vehicle_mask.cpp | 3 +-- search/geocoder.cpp | 3 +-- search/geocoder_context.cpp | 9 +++---- search/geocoder_locality.cpp | 3 +-- search/house_numbers_matcher.cpp | 9 +++---- search/keyword_matcher.cpp | 2 +- search/mwm_context.cpp | 3 +-- search/nested_rects_cache.cpp | 3 +-- search/ranker.cpp | 6 ++--- search/result.cpp | 2 +- search/retrieval.cpp | 3 +-- .../assessment_tool/main_model.cpp | 3 +-- search/search_tests/keyword_matcher_test.cpp | 5 ++-- storage/storage_defines.cpp | 12 +++------ .../storage_http_tests.cpp | 8 +++--- storage/storage_tests/storage_tests.cpp | 6 ++--- traffic/speed_groups.cpp | 3 +-- ugc/serdes.hpp | 2 +- ugc/storage.hpp | 3 +-- 84 files changed, 166 insertions(+), 233 deletions(-) diff --git a/3party/freetype/CMakeLists.txt b/3party/freetype/CMakeLists.txt index d3ab9c9a70..a7e59c4fff 100644 --- a/3party/freetype/CMakeLists.txt +++ b/3party/freetype/CMakeLists.txt @@ -9,8 +9,10 @@ endif () add_compile_options("-Wall") add_clang_compile_options("-Wno-unused-function") -add_gcc_compile_options("-Wno-pointer-to-int-cast") -add_gcc_compile_options("-Wno-unused-function") +add_gcc_compile_options( + "-Wno-pointer-to-int-cast" + "-Wno-unused-function" +) include_directories(include) diff --git a/3party/opening_hours/CMakeLists.txt b/3party/opening_hours/CMakeLists.txt index 616d9fc769..ac4cc60787 100644 --- a/3party/opening_hours/CMakeLists.txt +++ b/3party/opening_hours/CMakeLists.txt @@ -12,8 +12,10 @@ add_compile_options( ) add_clang_compile_options("-Wno-unused-local-typedef") -add_gcc_compile_options("-Wno-unused-local-typedef") -add_gcc_compile_options("-Wno-return-type") +add_gcc_compile_options( + "-Wno-unused-local-typedef" + "-Wno-return-type" +) set( SRC diff --git a/base/assert.hpp b/base/assert.hpp index abbd8b01b9..ab16850ed7 100644 --- a/base/assert.hpp +++ b/base/assert.hpp @@ -94,7 +94,7 @@ namespace my // The macro that causes the warning to be ignored: control reaches end of // non-void function. -#define INCORRECT_VALUE_IN_THE_SWITCH() do { \ +#define CHECK_SWITCH() do { \ CHECK(false, ("Incorrect value in the switch statment")); \ std::abort(); \ } while(false) diff --git a/base/base_tests/levenshtein_dfa_test.cpp b/base/base_tests/levenshtein_dfa_test.cpp index 2c27c0ea3b..112d1e2228 100644 --- a/base/base_tests/levenshtein_dfa_test.cpp +++ b/base/base_tests/levenshtein_dfa_test.cpp @@ -42,8 +42,7 @@ string DebugPrint(Status status) case Status::Rejects: return "Rejects"; case Status::Intermediate: return "Intermediate"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(Result const & result) diff --git a/base/base_tests/stl_helpers_test.cpp b/base/base_tests/stl_helpers_test.cpp index 59f8315455..12ebe85699 100644 --- a/base/base_tests/stl_helpers_test.cpp +++ b/base/base_tests/stl_helpers_test.cpp @@ -91,16 +91,16 @@ UNIT_TEST(LessBy) std::vector v = {{2, 2}, {0, 4}, {3, 1}, {4, 0}, {1, 3}}; std::sort(v.begin(), v.end(), my::LessBy(&Value::first)); - for (int i = 0; i < static_cast(v.size()); ++i) - TEST_EQUAL(i, v[i].first, ()); + for (size_t i = 0; i < v.size(); ++i) + TEST_EQUAL(i, static_cast(v[i].first), ()); std::vector pv; for (auto const & p : v) pv.push_back(&p); std::sort(pv.begin(), pv.end(), my::LessBy(&Value::second)); - for (int i = 0; i < static_cast(pv.size()); ++i) - TEST_EQUAL(i, pv[i]->second, ()); + for (size_t i = 0; i < pv.size(); ++i) + TEST_EQUAL(i, static_cast(pv[i]->second), ()); } { diff --git a/base/levenshtein_dfa.cpp b/base/levenshtein_dfa.cpp index 82da404b61..7ea5023724 100644 --- a/base/levenshtein_dfa.cpp +++ b/base/levenshtein_dfa.cpp @@ -4,11 +4,11 @@ #include "base/stl_helpers.hpp" #include +#include #include #include #include #include -#include namespace strings { @@ -201,7 +201,7 @@ LevenshteinDFA::LevenshteinDFA(UniString const & s, size_t prefixSize, m_alphabet.assign(s.begin(), s.end()); CHECK_LESS_OR_EQUAL(prefixSize, s.size(), ()); - auto pSize = static_cast::difference_type>(prefixSize); for (auto it = s.begin(); std::distance(it, s.begin()) < pSize; ++it) { diff --git a/coding/compressed_bit_vector.cpp b/coding/compressed_bit_vector.cpp index 01ed947c15..45b00abdcb 100644 --- a/coding/compressed_bit_vector.cpp +++ b/coding/compressed_bit_vector.cpp @@ -461,8 +461,7 @@ string DebugPrint(CompressedBitVector::StorageStrategy strat) case CompressedBitVector::StorageStrategy::Dense: return "Dense"; case CompressedBitVector::StorageStrategy::Sparse: return "Sparse"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } // static diff --git a/coding/point_to_integer.cpp b/coding/point_to_integer.cpp index 39d9cb583c..2e809e7bf1 100644 --- a/coding/point_to_integer.cpp +++ b/coding/point_to_integer.cpp @@ -8,8 +8,7 @@ int64_t PointToInt64Obsolete(double x, double y, uint32_t coordBits) int64_t const res = static_cast(PointUToUint64Obsolete(PointDToPointU(x, y, coordBits))); ASSERT_GREATER_OR_EQUAL(res, 0, ("Highest bits of (ix, iy) are not used, so res should be > 0.")); - ASSERT_LESS_OR_EQUAL(static_cast(res), - static_cast(3ULL << 2 * POINT_COORD_BITS), ()); + ASSERT_LESS_OR_EQUAL(static_cast(res), uint64_t{3} << 2 * POINT_COORD_BITS, ()); return res; } @@ -21,8 +20,7 @@ int64_t PointToInt64Obsolete(m2::PointD const & pt, uint32_t coordBits) m2::PointD Int64ToPointObsolete(int64_t v, uint32_t coordBits) { ASSERT_GREATER_OR_EQUAL(v, 0, ("Highest bits of (ix, iy) are not used, so res should be > 0.")); - ASSERT_LESS_OR_EQUAL(static_cast(v), - static_cast(3ULL << 2 * POINT_COORD_BITS), ()); + ASSERT_LESS_OR_EQUAL(static_cast(v), uint64_t{3} << 2 * POINT_COORD_BITS, ()); return PointUToPointD(Uint64ToPointUObsolete(static_cast(v)), coordBits); } diff --git a/coding/zlib.cpp b/coding/zlib.cpp index 80b3c7ece5..9b156cd629 100644 --- a/coding/zlib.cpp +++ b/coding/zlib.cpp @@ -19,8 +19,7 @@ int ToInt(ZLib::Deflate::Level level) case Level::BestCompression: return Z_BEST_COMPRESSION; case Level::DefaultCompression: return Z_DEFAULT_COMPRESSION; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace diff --git a/drape_frontend/gui/ruler_helper.cpp b/drape_frontend/gui/ruler_helper.cpp index 498afdcf82..ba48c7e7c1 100644 --- a/drape_frontend/gui/ruler_helper.cpp +++ b/drape_frontend/gui/ruler_helper.cpp @@ -225,8 +225,7 @@ double RulerHelper::CalcMetresDiff(double value) auto conversionFn = &Identity; auto units = measurement_utils::Units::Metric; - if (!settings::Get(settings::kMeasurementUnits, units)) - LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); + settings::TryGet(settings::kMeasurementUnits, units); if (units == measurement_utils::Units::Imperial) { diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 92252f8c5d..e84b61b2a2 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -20,6 +20,7 @@ #include #include +#include #ifdef DEBUG #define TEST_CALL(action) if (m_testFn) m_testFn(action) diff --git a/editor/edits_migration.cpp b/editor/edits_migration.cpp index f0d410fa52..6e94f39f53 100644 --- a/editor/edits_migration.cpp +++ b/editor/edits_migration.cpp @@ -118,7 +118,6 @@ FeatureID MigrateFeatureIndex(osm::Editor::ForEachFeaturesNearByFn & forEach, case XMLFeature::Type::Relation: return MigrateWayOrRelatonFeatureIndex(forEach, xml, featureStatus, generateID); } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace editor diff --git a/editor/xml_feature.cpp b/editor/xml_feature.cpp index 1e785f06ea..596ebb7c06 100644 --- a/editor/xml_feature.cpp +++ b/editor/xml_feature.cpp @@ -400,8 +400,7 @@ string XMLFeature::TypeToString(Type type) case Type::Way: return kWayType; case Type::Relation: return kRelationType; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } // static diff --git a/generator/osm_element.cpp b/generator/osm_element.cpp index a6f63b7d4a..2da58ee258 100644 --- a/generator/osm_element.cpp +++ b/generator/osm_element.cpp @@ -28,8 +28,7 @@ std::string DebugPrint(OsmElement::EntityType e) case OsmElement::EntityType::Member: return "member"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } diff --git a/generator/osm_o5m_source.hpp b/generator/osm_o5m_source.hpp index aec6d60a3e..5966ede0de 100644 --- a/generator/osm_o5m_source.hpp +++ b/generator/osm_o5m_source.hpp @@ -1,8 +1,8 @@ // See O5M Format definition at https://wiki.openstreetmap.org/wiki/O5m #pragma once -#include "base/stl_helpers.hpp" #include "base/assert.hpp" +#include "base/stl_helpers.hpp" #include #include diff --git a/geometry/line2d.cpp b/geometry/line2d.cpp index fc94522155..d0074d37b2 100644 --- a/geometry/line2d.cpp +++ b/geometry/line2d.cpp @@ -61,8 +61,7 @@ string DebugPrint(LineIntersector::Result::Type type) case Type::One: return "One"; case Type::Infinity: return "Infinity"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(LineIntersector::Result const & result) diff --git a/indexer/feature_decl.cpp b/indexer/feature_decl.cpp index 6379891958..37ea6c72cd 100644 --- a/indexer/feature_decl.cpp +++ b/indexer/feature_decl.cpp @@ -19,8 +19,7 @@ string DebugPrint(feature::EGeomType type) case EGeomType::GEOM_LINE: return "GEOM_LINE"; case EGeomType::GEOM_AREA: return "GEOM_AREA"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } // static diff --git a/indexer/ftraits.hpp b/indexer/ftraits.hpp index 4af7c9874d..5fcc471c7d 100644 --- a/indexer/ftraits.hpp +++ b/indexer/ftraits.hpp @@ -207,8 +207,7 @@ inline std::string DebugPrint(WheelchairAvailability wheelchair) case WheelchairAvailability::Yes: return "Yes"; case WheelchairAvailability::Limited: return "Limited"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } class Wheelchair : public TraitsBase diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 5caf6ae454..f8b9dc09a1 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -357,8 +357,7 @@ char const * IsHotelChecker::GetHotelTypeTag(Type type) case Type::Resort: return "resort"; case Type::Count: CHECK(false, ("Can't get hotel type tag")); return ""; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } IsWifiChecker::IsWifiChecker() diff --git a/indexer/interval_index_builder.hpp b/indexer/interval_index_builder.hpp index fc6a111573..c2d8f00cdf 100644 --- a/indexer/interval_index_builder.hpp +++ b/indexer/interval_index_builder.hpp @@ -1,16 +1,21 @@ #pragma once + #include "indexer/interval_index.hpp" + #include "coding/byte_stream.hpp" #include "coding/endianness.hpp" #include "coding/varint.hpp" #include "coding/write_to_sink.hpp" + #include "base/assert.hpp" #include "base/base.hpp" #include "base/bits.hpp" #include "base/logging.hpp" -#include "std/vector.hpp" +#include #include +#include + // +------------------------------+ // | Header | // +------------------------------+ @@ -67,15 +72,15 @@ public: WriteZeroesToSink(writer, 4 * (m_Levels + 2)); uint64_t const afterHeaderPos = writer.Pos(); - vector levelOffset; + std::vector levelOffset; { - vector offsets; + std::vector offsets; levelOffset.push_back(static_cast(writer.Pos())); BuildLeaves(writer, beg, end, offsets); levelOffset.push_back(static_cast(writer.Pos())); for (int i = 1; i <= static_cast(m_Levels); ++i) { - vector nextOffsets; + std::vector nextOffsets; BuildLevel(writer, beg, end, i, &offsets[0], &offsets[0] + offsets.size(), nextOffsets); nextOffsets.swap(offsets); levelOffset.push_back(static_cast(writer.Pos())); @@ -141,7 +146,8 @@ public: for (CellIdValueIter it = beg; it != end; ++it) { CHECK_LESS(it->GetCell(), 1ULL << keyBits, ()); - CHECK_LESS_OR_EQUAL(it->GetValue(), std::numeric_limits::max(), ()); + // We use static_cast(value) in BuildLeaves to store values difference as VarInt. + CHECK_LESS_OR_EQUAL(it->GetValue(), static_cast(std::numeric_limits::max()), ()); } return true; @@ -150,10 +156,10 @@ public: template uint32_t WriteNode(SinkT & sink, uint32_t offset, uint32_t * childSizes) { - vector bitmapSerial, listSerial; + std::vector bitmapSerial, listSerial; bitmapSerial.reserve(1024); listSerial.reserve(1024); - PushBackByteSink > bitmapSink(bitmapSerial), listSink(listSerial); + PushBackByteSink > bitmapSink(bitmapSerial), listSink(listSerial); WriteBitmapNode(bitmapSink, offset, childSizes); WriteListNode(listSink, offset, childSizes); if (bitmapSerial.size() <= listSerial.size()) @@ -173,12 +179,12 @@ public: template void BuildLevel(Writer & writer, CellIdValueIter const & beg, CellIdValueIter const & end, int level, uint32_t const * childSizesBeg, uint32_t const * childSizesEnd, - vector & sizes) + std::vector & sizes) { UNUSED_VALUE(childSizesEnd); ASSERT_GREATER(level, 0, ()); uint32_t const skipBits = m_LeafBytes * 8 + (level - 1) * m_BitsPerLevel; - vector expandedSizes(1 << m_BitsPerLevel); + std::vector expandedSizes(1 << m_BitsPerLevel); uint64_t prevKey = static_cast(-1); uint32_t childOffset = 0; uint32_t nextChildOffset = 0; @@ -206,7 +212,7 @@ public: template void BuildLeaves(Writer & writer, CellIdValueIter const & beg, CellIdValueIter const & end, - vector & sizes) + std::vector & sizes) { using Value = typename CellIdValueIter::value_type::ValueType; diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 855555310f..9c7adfcefc 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -448,8 +448,7 @@ string DebugPrint(MwmSet::RegResult result) case MwmSet::RegResult::UnsupportedFileFormat: return "UnsupportedFileFormat"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(MwmSet::Event::Type type) diff --git a/indexer/postcodes_matcher.cpp b/indexer/postcodes_matcher.cpp index 031de717f0..78c2e0ad07 100644 --- a/indexer/postcodes_matcher.cpp +++ b/indexer/postcodes_matcher.cpp @@ -64,8 +64,7 @@ public: case TStringSet::Status::Prefix: return isPrefix; case TStringSet::Status::Full: return true; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } inline size_t GetMaxNumTokensInPostcode() const { return m_maxNumTokensInPostcode; } diff --git a/kml/serdes.cpp b/kml/serdes.cpp index a0cb2c018d..fe6dbab05b 100644 --- a/kml/serdes.cpp +++ b/kml/serdes.cpp @@ -122,8 +122,7 @@ std::string GetStyleForPredefinedColor(PredefinedColor color) case PredefinedColor::Count: return {}; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } BookmarkIcon GetIcon(std::string const & iconName) diff --git a/kml/types.hpp b/kml/types.hpp index ec862f1fdd..55855ea67b 100644 --- a/kml/types.hpp +++ b/kml/types.hpp @@ -43,8 +43,7 @@ inline std::string DebugPrint(PredefinedColor color) case PredefinedColor::Orange: return "Orange"; case PredefinedColor::Count: return {}; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } enum class AccessRules : uint8_t @@ -63,8 +62,7 @@ inline std::string DebugPrint(AccessRules accessRules) case AccessRules::Public: return "Public"; case AccessRules::Count: return {}; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } enum class BookmarkIcon : uint16_t @@ -120,8 +118,7 @@ inline std::string DebugPrint(BookmarkIcon icon) case BookmarkIcon::Water: return "Water"; case BookmarkIcon::Count: return {}; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } struct ColorData diff --git a/map/booking_filter_cache.cpp b/map/booking_filter_cache.cpp index 8db2cafbb1..4a8c7aacd5 100644 --- a/map/booking_filter_cache.cpp +++ b/map/booking_filter_cache.cpp @@ -106,8 +106,7 @@ std::string DebugPrint(Cache::HotelStatus status) case Cache::HotelStatus::Unavailable: return "Unavailable"; case Cache::HotelStatus::Available: return "Available"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace availability } // namespace filter diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 58599d4302..2ed09ae523 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -36,8 +36,7 @@ std::string GetBookmarkIconType(kml::BookmarkIcon const & icon) ASSERT(false, ("Invalid bookmark icon type")); return {}; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace @@ -107,8 +106,7 @@ df::ColorConstant Bookmark::GetColorConstant() const case kml::PredefinedColor::Count: return "BookmarkRed"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } bool Bookmark::HasCreationAnimation() const diff --git a/map/bookmark_helpers.hpp b/map/bookmark_helpers.hpp index f2b4d0dad8..8ba57f344b 100644 --- a/map/bookmark_helpers.hpp +++ b/map/bookmark_helpers.hpp @@ -26,8 +26,7 @@ inline std::string DebugPrint(KmlFileType fileType) case KmlFileType::Text: return "Text"; case KmlFileType::Binary: return "Binary"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } std::unique_ptr LoadKmlFile(std::string const & file, KmlFileType fileType); diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 5bb39e6960..1fc02e4dc0 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -97,8 +97,7 @@ bool IsValidFilterType(BookmarkManager::CategoryFilterType const filter, case BookmarkManager::CategoryFilterType::Public: return fromCatalog; case BookmarkManager::CategoryFilterType::Private: return !fromCatalog; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } class FindMarkFunctor @@ -345,10 +344,11 @@ bool MigrateIfNeeded() if (files.empty()) { auto const newBookmarksDir = GetBookmarksDirectory(); - if (!GetPlatform().IsFileExistsByFullPath(newBookmarksDir)) + if (!GetPlatform().IsFileExistsByFullPath(newBookmarksDir) && + !GetPlatform().MkDirChecked(newBookmarksDir)) { - if(!GetPlatform().MkDirChecked(newBookmarksDir)) - LOG(LWARNING, ("Could not create directory:", newBookmarksDir)); + LOG(LWARNING, ("Could not create directory:", newBookmarksDir)); + return false; } OnMigrationSuccess(0 /* originalCount */, 0 /* convertedCount */); return true; @@ -899,8 +899,7 @@ void BookmarkManager::SaveState() const void BookmarkManager::LoadState() { - if(!settings::Get(kLastEditedBookmarkCategory, m_lastCategoryUrl)) - LOG(LWARNING, ("Unable to read settings:", kLastEditedBookmarkCategory)); + settings::TryGet(kLastEditedBookmarkCategory, m_lastCategoryUrl); uint32_t color; if (settings::Get(kLastEditedBookmarkColor, color) && diff --git a/map/chart_generator.cpp b/map/chart_generator.cpp index 792aa1d66a..8983afd2b3 100644 --- a/map/chart_generator.cpp +++ b/map/chart_generator.cpp @@ -63,8 +63,7 @@ agg::rgba8 GetLineColor(MapStyle mapStyle) case MapStyleMerged: return agg::rgba8(30, 150, 240, 255); } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } agg::rgba8 GetCurveColor(MapStyle mapStyle) @@ -82,8 +81,7 @@ agg::rgba8 GetCurveColor(MapStyle mapStyle) case MapStyleMerged: return agg::rgba8(30, 150, 240, 20); } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace diff --git a/map/cloud.cpp b/map/cloud.cpp index 4337ff024d..c72f62a6a0 100644 --- a/map/cloud.cpp +++ b/map/cloud.cpp @@ -128,8 +128,7 @@ bool CanUpload(uint64_t totalUploadingSize) return platform::GetCurrentNetworkPolicy().CanUse() && totalUploadingSize <= kMaxWwanUploadingSizeInBytes; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } struct SnapshotCreateRequestData diff --git a/map/cloud.hpp b/map/cloud.hpp index 0639b8ac64..52a5ccf446 100644 --- a/map/cloud.hpp +++ b/map/cloud.hpp @@ -391,8 +391,7 @@ inline std::string DebugPrint(Cloud::SynchronizationType type) case Cloud::SynchronizationType::Backup: return "Backup"; case Cloud::SynchronizationType::Restore: return "Restore"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } inline std::string DebugPrint(Cloud::SynchronizationResult result) @@ -406,8 +405,7 @@ inline std::string DebugPrint(Cloud::SynchronizationResult result) case Cloud::SynchronizationResult::UserInterrupted: return "UserInterrupted"; case Cloud::SynchronizationResult::InvalidCall: return "InvalidCall"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } inline std::string DebugPrint(Cloud::RestoringRequestResult result) @@ -418,6 +416,5 @@ inline std::string DebugPrint(Cloud::RestoringRequestResult result) case Cloud::RestoringRequestResult::NoBackup: return "NoBackup"; case Cloud::RestoringRequestResult::NotEnoughDiskSpace: return "NotEnoughDiskSpace"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } diff --git a/map/discovery/discovery_manager.cpp b/map/discovery/discovery_manager.cpp index 7cf9a54eb1..eec782d717 100644 --- a/map/discovery/discovery_manager.cpp +++ b/map/discovery/discovery_manager.cpp @@ -17,7 +17,7 @@ std::string GetQuery(discovery::ItemType const type) case discovery::ItemType::Viator: ASSERT(false, ()); return ""; } - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace diff --git a/map/framework.cpp b/map/framework.cpp index ce6b0be202..494bb86889 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1924,8 +1924,7 @@ void Framework::SetupMeasurementSystem() GetPlatform().SetupMeasurementSystem(); auto units = measurement_utils::Units::Metric; - if (!settings::Get(settings::kMeasurementUnits, units)) - LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); + settings::TryGet(settings::kMeasurementUnits, units); m_routingManager.SetTurnNotificationsUnits(units); } diff --git a/map/gps_track_filter.cpp b/map/gps_track_filter.cpp index 130d97d10e..1ce1ffd57b 100644 --- a/map/gps_track_filter.cpp +++ b/map/gps_track_filter.cpp @@ -57,8 +57,7 @@ GpsTrackFilter::GpsTrackFilter() , m_countLastInfo(0) , m_countAcceptedInfo(0) { - if (!settings::Get(kMinHorizontalAccuracyKey, m_minAccuracy)) - LOG(LWARNING, ("Unable to read settings:", kMinHorizontalAccuracyKey)); + settings::TryGet(kMinHorizontalAccuracyKey, m_minAccuracy); } void GpsTrackFilter::Process(vector const & inPoints, diff --git a/map/mwm_url.cpp b/map/mwm_url.cpp index b1eee93812..82f25f80a4 100644 --- a/map/mwm_url.cpp +++ b/map/mwm_url.cpp @@ -259,8 +259,7 @@ ParsedMapApi::ParsingResult ParsedMapApi::Parse(Uri const & uri) return ParsingResult::Lead; } } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } bool ParsedMapApi::RouteKeyValue(string const & key, string const & value, vector & pattern) diff --git a/map/osm_opening_hours.hpp b/map/osm_opening_hours.hpp index 368ff84d6c..c173dbd7ba 100644 --- a/map/osm_opening_hours.hpp +++ b/map/osm_opening_hours.hpp @@ -2,6 +2,8 @@ #include "3party/opening_hours/opening_hours.hpp" +#include "base/assert.hpp" + #include "std/chrono.hpp" namespace osm @@ -27,8 +29,7 @@ inline string DebugPrint(EPlaceState state) case EPlaceState::CloseSoon: return "EPlaceState::CloseSoon"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } inline EPlaceState PlaceStateCheck(string const & openingHours, time_t timestamp) diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index af173a578f..91739aa548 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -207,8 +207,7 @@ VehicleType GetVehicleType(RouterType routerType) case RouterType::Transit: return VehicleType::Transit; case RouterType::Count: CHECK(false, ("Invalid type", routerType)); return VehicleType::Count; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace @@ -1039,9 +1038,7 @@ bool RoutingManager::IsTrackingReporterEnabled() const return false; bool enableTracking = true; - if (!settings::Get(tracking::Reporter::kEnableTrackingKey, enableTracking)) - LOG(LWARNING, ("Unable to read settings:", - tracking::Reporter::kEnableTrackingKey)); + settings::TryGet(tracking::Reporter::kEnableTrackingKey, enableTracking); return enableTracking; } diff --git a/map/routing_mark.cpp b/map/routing_mark.cpp index 0ab90d534c..8a8fceefba 100644 --- a/map/routing_mark.cpp +++ b/map/routing_mark.cpp @@ -102,8 +102,7 @@ uint16_t RouteMarkPoint::GetPriority() const } } } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } uint32_t RouteMarkPoint::GetIndex() const @@ -114,8 +113,7 @@ uint32_t RouteMarkPoint::GetIndex() const case RouteMarkType::Finish: return 1; case RouteMarkType::Intermediate: return static_cast(m_markData.m_intermediateIndex + 2); } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } void RouteMarkPoint::SetMarkData(RouteMarkData && data) diff --git a/map/user.cpp b/map/user.cpp index ef4fcc8696..7f73ca2bd1 100644 --- a/map/user.cpp +++ b/map/user.cpp @@ -68,8 +68,7 @@ std::string AuthenticationUrl(std::string const & socialToken, return ss.str(); } } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } std::string UserDetailsUrl() diff --git a/map/user_mark.cpp b/map/user_mark.cpp index f757f29f33..60d97a8947 100644 --- a/map/user_mark.cpp +++ b/map/user_mark.cpp @@ -86,6 +86,5 @@ string DebugPrint(UserMark::Type type) case UserMark::Type::USER_MARK_TYPES_COUNT: return "USER_MARK_TYPES_COUNT"; case UserMark::Type::USER_MARK_TYPES_COUNT_MAX: return "USER_MARK_TYPES_COUNT_MAX"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp index abcf4fb241..3b818c180e 100644 --- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp +++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp @@ -241,7 +241,7 @@ void TrafficMode::OnItemSelected(QItemSelection const & selected, QItemSelection auto const row = selected.front().top(); - CHECK_LESS(row, static_cast(m_segments.size()), ()); + CHECK_LESS(static_cast(row), m_segments.size(), ()); m_currentSegment = &m_segments[row]; auto const & partnerSegment = m_currentSegment->GetPartnerSegment(); diff --git a/partners_api/banner.hpp b/partners_api/banner.hpp index bbee5c477f..099b38651e 100644 --- a/partners_api/banner.hpp +++ b/partners_api/banner.hpp @@ -1,5 +1,7 @@ #pragma once +#include "base/assert.hpp" + #include namespace ads @@ -32,7 +34,6 @@ inline std::string DebugPrint(Banner::Type type) case Banner::Type::Mopub: return "Mopub"; case Banner::Type::Google: return "Google"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace ads diff --git a/partners_api/taxi_places_loader.cpp b/partners_api/taxi_places_loader.cpp index 1bf69ae6cb..b430ff4529 100644 --- a/partners_api/taxi_places_loader.cpp +++ b/partners_api/taxi_places_loader.cpp @@ -55,8 +55,7 @@ std::string Loader::GetFileNameByProvider(Provider::Type const type) case Provider::Type::Yandex: return "taxi_places/yandex.json"; case Provider::Type::Count: LOG(LERROR, ("Incorrect taxi provider")); return ""; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace places } // namespace taxi diff --git a/partners_api/taxi_provider.hpp b/partners_api/taxi_provider.hpp index f1ca17d852..a5536d5c03 100644 --- a/partners_api/taxi_provider.hpp +++ b/partners_api/taxi_provider.hpp @@ -82,8 +82,7 @@ inline std::string DebugPrint(Provider::Type type) case Provider::Type::Maxim: return "Maxim"; case Provider::Type::Count: ASSERT(false, ()); return ""; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } inline std::string DebugPrint(ErrorCode code) @@ -93,8 +92,7 @@ inline std::string DebugPrint(ErrorCode code) case ErrorCode::NoProducts: return "NoProducts"; case ErrorCode::RemoteError: return "RemoteError"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } inline std::string DebugPrint(ProviderError error) diff --git a/platform/country_defines.cpp b/platform/country_defines.cpp index 4fd2b7684a..1533887524 100644 --- a/platform/country_defines.cpp +++ b/platform/country_defines.cpp @@ -38,6 +38,5 @@ string DebugPrint(MapOptions options) case MapOptions::Diff: return "Diff"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } diff --git a/platform/local_country_file_utils.cpp b/platform/local_country_file_utils.cpp index ac507eaf57..2afaf2f204 100644 --- a/platform/local_country_file_utils.cpp +++ b/platform/local_country_file_utils.cpp @@ -467,7 +467,6 @@ string DebugPrint(CountryIndexes::Index index) case CountryIndexes::Index::Offsets: return "Offsets"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace platform diff --git a/platform/measurement_utils.cpp b/platform/measurement_utils.cpp index f3352e36fa..42ab2b5fc5 100644 --- a/platform/measurement_utils.cpp +++ b/platform/measurement_utils.cpp @@ -56,8 +56,7 @@ bool FormatDistanceImpl(double m, string & res, bool FormatDistance(double m, string & res) { auto units = Units::Metric; - if (!Get(settings::kMeasurementUnits, units)) - LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); + TryGet(settings::kMeasurementUnits, units); /// @todo Put string units resources. switch (units) @@ -65,8 +64,7 @@ bool FormatDistance(double m, string & res) case Units::Imperial: return FormatDistanceImpl(m, res, " mi", " ft", 1609.344, 0.3048); case Units::Metric: return FormatDistanceImpl(m, res, " km", " m", 1000.0, 1.0); } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } @@ -167,8 +165,7 @@ void FormatMercator(m2::PointD const & mercator, string & lat, string & lon, int string FormatAltitude(double altitudeInMeters) { Units units = Units::Metric; - if (!Get(settings::kMeasurementUnits, units)) - LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); + TryGet(settings::kMeasurementUnits, units); ostringstream ss; ss << fixed << setprecision(0); @@ -185,8 +182,7 @@ string FormatAltitude(double altitudeInMeters) string FormatSpeedWithDeviceUnits(double metersPerSecond) { auto units = Units::Metric; - if (!Get(settings::kMeasurementUnits, units)) - LOG(LWARNING, ("Unable to read settings:", settings::kMeasurementUnits)); + TryGet(settings::kMeasurementUnits, units); return FormatSpeedWithUnits(metersPerSecond, units); } @@ -215,8 +211,7 @@ string FormatSpeedUnits(Units units) case Units::Imperial: return "mph"; case Units::Metric: return "km/h"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } bool OSMDistanceToMeters(string const & osmRawValue, double & outMeters) diff --git a/platform/measurement_utils.hpp b/platform/measurement_utils.hpp index 3af3248ac6..d4251b509e 100644 --- a/platform/measurement_utils.hpp +++ b/platform/measurement_utils.hpp @@ -19,8 +19,7 @@ inline string DebugPrint(Units units) case Units::Imperial: return "Units::Imperial"; case Units::Metric: return "Units::Metric"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } inline double MetersToMiles(double m) { return m * 0.000621371192; } diff --git a/platform/mwm_traits.cpp b/platform/mwm_traits.cpp index d9d3355b6c..471effd226 100644 --- a/platform/mwm_traits.cpp +++ b/platform/mwm_traits.cpp @@ -40,8 +40,7 @@ string DebugPrint(MwmTraits::SearchIndexFormat format) case MwmTraits::SearchIndexFormat::CompressedBitVector: return "CompressedBitVector"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(MwmTraits::HouseToStreetTableFormat format) @@ -53,7 +52,6 @@ string DebugPrint(MwmTraits::HouseToStreetTableFormat format) case MwmTraits::HouseToStreetTableFormat::Unknown: return "Unknown"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace version diff --git a/platform/platform.cpp b/platform/platform.cpp index 39cb0589e3..3f2edf3d36 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -306,8 +306,7 @@ string DebugPrint(Platform::EError err) case Platform::ERR_IO_ERROR: return "An I/O error occurred."; case Platform::ERR_UNKNOWN: return "Unknown"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(Platform::ChargingStatus status) @@ -318,6 +317,5 @@ string DebugPrint(Platform::ChargingStatus status) case Platform::ChargingStatus::Plugged: return "Plugged"; case Platform::ChargingStatus::Unplugged: return "Unplugged"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } diff --git a/platform/settings.cpp b/platform/settings.cpp index ac608631c7..f26b39d2e4 100644 --- a/platform/settings.cpp +++ b/platform/settings.cpp @@ -280,8 +280,7 @@ string ToString(measurement_utils::Units const & v) case measurement_utils::Units::Imperial: return "Foot"; case measurement_utils::Units::Metric: return "Metric"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } template <> @@ -338,8 +337,7 @@ string ToString(Transliteration::Mode const & mode) case Transliteration::Mode::Enabled: return "Enabled"; case Transliteration::Mode::Disabled: return "Disabled"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } template <> diff --git a/platform/settings.hpp b/platform/settings.hpp index e6d42945da..213a535ca2 100644 --- a/platform/settings.hpp +++ b/platform/settings.hpp @@ -35,6 +35,14 @@ WARN_UNUSED_RESULT bool Get(string const & key, Value & outValue) string strVal; return StringStorage::Instance().GetValue(key, strVal) && FromString(strVal, outValue); } + +template +void TryGet(string const & key, Value & outValue) +{ + bool unused = Get(key, outValue); + UNUSED_VALUE(unused); +} + /// Automatically saves setting to external file template void Set(string const & key, Value const & value) diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 09930b960e..4a3b9c80a8 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -124,9 +124,8 @@ MainWindow::MainWindow(Framework & framework, bool apiOpenGLES3, QString const & #ifndef NO_DOWNLOADER // Show intro dialog if necessary bool bShow = true; - const string showWelcome = "ShowWelcome"; - if (!settings::Get(showWelcome, bShow)) - LOG(LWARNING, ("Unable to read settings:", showWelcome)); + string const showWelcome = "ShowWelcome"; + settings::TryGet(showWelcome, bShow); if (bShow) { diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index 83ccc1073c..c4496e4229 100644 --- a/routing/bicycle_directions.cpp +++ b/routing/bicycle_directions.cpp @@ -345,7 +345,7 @@ void BicycleDirectionsEngine::FillPathSegmentsAndAdjacentEdgesMap( continue; } - CHECK_EQUAL(prevJunctions.size(), static_cast::size_type>( + CHECK_EQUAL(prevJunctions.size(), static_cast( abs(static_cast(inSegId - startSegId)) + 1), ()); prevJunctions.push_back(currJunction); diff --git a/routing/cross_mwm_connector.cpp b/routing/cross_mwm_connector.cpp index 5b662b2e44..575c3467c8 100644 --- a/routing/cross_mwm_connector.cpp +++ b/routing/cross_mwm_connector.cpp @@ -13,8 +13,7 @@ std::string DebugPrint(WeightsLoadState state) case WeightsLoadState::NotExists: return "NotExists"; case WeightsLoadState::Loaded: return "Loaded"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace connector } // namespace routing diff --git a/routing/cross_mwm_connector.hpp b/routing/cross_mwm_connector.hpp index 7d623dbea6..deeeef2d6f 100644 --- a/routing/cross_mwm_connector.hpp +++ b/routing/cross_mwm_connector.hpp @@ -180,8 +180,7 @@ public: case connector::WeightsLoadState::NotExists: case connector::WeightsLoadState::Loaded: return true; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } template diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index 0c257d3034..6a45224845 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -214,8 +214,7 @@ shared_ptr EdgeEstimator::Create(VehicleType vehicleType, double CHECK(false, ("Can't create EdgeEstimator for", vehicleType)); return nullptr; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } // static diff --git a/routing/index_router.cpp b/routing/index_router.cpp index d5f7145fdd..36653fc488 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -98,8 +98,7 @@ shared_ptr CreateVehicleModelFactory( CHECK(false, ("Can't create VehicleModelFactoryInterface for", vehicleType)); return nullptr; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } unique_ptr CreateDirectionsEngine(VehicleType vehicleType, @@ -117,8 +116,7 @@ unique_ptr CreateDirectionsEngine(VehicleType vehicleType, CHECK(false, ("Can't create DirectionsEngine for", vehicleType)); return nullptr; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } shared_ptr CreateTrafficStash(VehicleType vehicleType, shared_ptr numMwmIds, @@ -765,9 +763,9 @@ RouterResultCode IndexRouter::ProcessLeaps(vector const & input, auto const lastMwmId = input[input.size() - 2].GetMwmId(); auto const finishLeapStartIt = find_if(startLeapEndIt, input.end(), [lastMwmId](Segment const & s) { return s.GetMwmId() == lastMwmId; }); - auto const finishLeapStart = distance(input.begin(), finishLeapStartIt); + auto const finishLeapStart = static_cast(distance(input.begin(), finishLeapStartIt)); - for (vector::difference_type i = 0; i <= finishLeapStart; ++i) + for (size_t i = 0; i <= finishLeapStart; ++i) { auto const & current = input[i]; @@ -784,7 +782,7 @@ RouterResultCode IndexRouter::ProcessLeaps(vector const & input, { bool const isStartLeap = i == 0; i = isStartLeap ? startLeapEnd : input.size() - 1; - CHECK_LESS(static_cast::size_type>(i), input.size(), ()); + CHECK_LESS(static_cast(i), input.size(), ()); auto const & next = input[i]; // First start-to-mwm-exit and last mwm-enter-to-finish leaps need special processing. @@ -811,7 +809,7 @@ RouterResultCode IndexRouter::ProcessLeaps(vector const & input, else { ++i; - CHECK_LESS(static_cast::size_type>(i), input.size(), ()); + CHECK_LESS(static_cast(i), input.size(), ()); auto const & next = input[i]; CHECK(!IndexGraphStarter::IsFakeSegment(current), ()); diff --git a/routing/index_router.hpp b/routing/index_router.hpp index 893aa48fad..418115eabe 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -127,8 +127,7 @@ private: case AStarAlgorithm::Result::Cancelled: return RouterResultCode::Cancelled; case AStarAlgorithm::Result::OK: return RouterResultCode::NoError; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } template diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp index f6889ea047..db342212c3 100644 --- a/routing/road_graph.cpp +++ b/routing/road_graph.cpp @@ -310,8 +310,7 @@ string DebugPrint(IRoadGraph::Mode mode) case IRoadGraph::Mode::ObeyOnewayTag: return "ObeyOnewayTag"; case IRoadGraph::Mode::IgnoreOnewayTag: return "IgnoreOnewayTag"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } IRoadGraph::RoadInfo MakeRoadInfoForTesting(bool bidirectional, double speedKMPH, diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index e27afd7085..32e604348f 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -802,7 +802,6 @@ string DebugPrint(RoutingSession::State state) case RoutingSession::RouteNoFollowing: return "RouteNoFollowing"; case RoutingSession::RouteRebuilding: return "RouteRebuilding"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace routing diff --git a/routing/routing_settings.cpp b/routing/routing_settings.cpp index 1117dc1fcf..8a2994dab5 100644 --- a/routing/routing_settings.cpp +++ b/routing/routing_settings.cpp @@ -26,7 +26,6 @@ RoutingSettings GetRoutingSettings(VehicleType vehicleType) CHECK(false, ("Can't create GetRoutingSettings for", vehicleType)); return {}; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace routing diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index c06482469d..daaeb92395 100644 --- a/routing/routing_tests/index_graph_test.cpp +++ b/routing/routing_tests/index_graph_test.cpp @@ -352,7 +352,7 @@ UNIT_TEST(FindPathManhattan) // Roads y: // // fast road R0 * - * - * -1 -// ↗ ↘ +// ╱ ╲ // slow road R1 * - - * - - * - - * - - * 0 // J0 J1 // diff --git a/routing/routing_tests/restriction_test.cpp b/routing/routing_tests/restriction_test.cpp index ee4793123a..ea48b74e7f 100644 --- a/routing/routing_tests/restriction_test.cpp +++ b/routing/routing_tests/restriction_test.cpp @@ -217,13 +217,13 @@ UNIT_CLASS_TEST(RestrictionTest, TriangularGraph_RestrictionNoF5F2RestrictionOnl // F4 // | // 2 * -// | ↖ +// | ╲ // F0 F2 -// | ↖ +// | ╲ // 1 * * -// | ↖ +// | ╲ // F0 F2 -// | ↖ +// | ╲ // 0 *---F1--*--F1--*--F3---* Start // 0 1 2 3 // Note. All features are two setments and two-way. diff --git a/routing/transit_info.hpp b/routing/transit_info.hpp index 14e84fa49b..41b5815d29 100644 --- a/routing/transit_info.hpp +++ b/routing/transit_info.hpp @@ -149,7 +149,6 @@ inline std::string DebugPrint(TransitInfo::Type type) case TransitInfo::Type::Edge: return "Edge"; case TransitInfo::Type::Transfer: return "Transfer"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace routing diff --git a/routing/vehicle_mask.cpp b/routing/vehicle_mask.cpp index d87039b51d..d0f685deaf 100644 --- a/routing/vehicle_mask.cpp +++ b/routing/vehicle_mask.cpp @@ -19,8 +19,7 @@ string DebugPrint(VehicleType vehicleType) case VehicleType::Transit: return "Transit"; case VehicleType::Count: return "Count"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string ToString(VehicleType vehicleType) { return DebugPrint(vehicleType); } diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 2b13b6c2ff..f6ad7d6dee 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -1414,8 +1414,7 @@ CBV Geocoder::RetrieveGeometryFeatures(MwmContext const & context, m2::RectD con case RECT_ID_LOCALITY: return m_localityRectsCache.Get(context, rect, m_params.GetScale()); case RECT_ID_COUNT: ASSERT(false, ("Invalid RectId.")); return CBV(); } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } bool Geocoder::GetTypeInGeocoding(BaseContext const & ctx, uint32_t featureId, Model::Type & type) diff --git a/search/geocoder_context.cpp b/search/geocoder_context.cpp index e3fabd4184..21e42e235e 100644 --- a/search/geocoder_context.cpp +++ b/search/geocoder_context.cpp @@ -24,8 +24,7 @@ BaseContext::TokenType BaseContext::FromModelType(Model::Type type) case Model::TYPE_COUNTRY: return TOKEN_TYPE_COUNTRY; case Model::TYPE_COUNT: return TOKEN_TYPE_COUNT; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } // static @@ -37,8 +36,7 @@ BaseContext::TokenType BaseContext::FromRegionType(Region::Type type) case Region::TYPE_COUNTRY: return TOKEN_TYPE_COUNTRY; case Region::TYPE_COUNT: return TOKEN_TYPE_COUNT; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } size_t BaseContext::SkipUsedTokens(size_t curToken) const @@ -101,7 +99,6 @@ string DebugPrint(BaseContext::TokenType type) case BaseContext::TOKEN_TYPE_POSTCODE: return "POSTCODE"; case BaseContext::TOKEN_TYPE_COUNT: return "COUNT"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace search diff --git a/search/geocoder_locality.cpp b/search/geocoder_locality.cpp index 3e982d9645..f92b233223 100644 --- a/search/geocoder_locality.cpp +++ b/search/geocoder_locality.cpp @@ -13,8 +13,7 @@ Model::Type Region::ToModelType(Type type) case Region::TYPE_COUNTRY: return Model::TYPE_COUNTRY; case Region::TYPE_COUNT: return Model::TYPE_COUNT; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } std::string DebugPrint(Locality const & locality) diff --git a/search/house_numbers_matcher.cpp b/search/house_numbers_matcher.cpp index 1b6c5fee08..8ade89e197 100644 --- a/search/house_numbers_matcher.cpp +++ b/search/house_numbers_matcher.cpp @@ -166,8 +166,7 @@ public: case TStrings::Status::Prefix: return isPrefix; case TStrings::Status::Full: return true; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } private: @@ -238,8 +237,7 @@ public: case TPatterns::Status::Prefix: return true; case TPatterns::Status::Full: return true; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } private: @@ -254,8 +252,7 @@ private: case 'U': return Token::TYPE_BUILDING_PART_OR_LETTER; default: CHECK(false, ("Unexpected character:", c)); return Token::TYPE_SEPARATOR; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } static Token::Type TokenToType(Token const & token) { return token.m_type; } diff --git a/search/keyword_matcher.cpp b/search/keyword_matcher.cpp index 422ed0a3e3..4ebdb53ea6 100644 --- a/search/keyword_matcher.cpp +++ b/search/keyword_matcher.cpp @@ -57,7 +57,7 @@ KeywordMatcher::Score KeywordMatcher::CalcScore(strings::UniString const * token int8_t prevTokenMatchDistance = 0; bool prefixMatched = true; - for (decltype(m_keywords)::size_type i = 0; i < m_keywords.size(); ++i) + for (size_t i = 0; i < m_keywords.size(); ++i) { for (size_t j = 0; j < count && !isQueryTokenMatched[i]; ++j) { diff --git a/search/mwm_context.cpp b/search/mwm_context.cpp index a911e8a006..81f49d95e1 100644 --- a/search/mwm_context.cpp +++ b/search/mwm_context.cpp @@ -37,8 +37,7 @@ bool MwmContext::GetFeature(uint32_t index, FeatureType & ft) const ft.SetID(FeatureID(GetId(), index)); return true; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } bool MwmContext::GetStreetIndex(uint32_t houseId, uint32_t & streetId) diff --git a/search/nested_rects_cache.cpp b/search/nested_rects_cache.cpp index cf20c23f50..439c223e0b 100644 --- a/search/nested_rects_cache.cpp +++ b/search/nested_rects_cache.cpp @@ -82,8 +82,7 @@ double NestedRectsCache::GetRadiusMeters(RectScale scale) case RECT_SCALE_LARGE: return 2500.0; case RECT_SCALE_COUNT: return 5000.0; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } void NestedRectsCache::Update() diff --git a/search/ranker.cpp b/search/ranker.cpp index a7445935ab..355f5d5f92 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -145,8 +145,7 @@ ftypes::Type GetLocalityIndex(feature::TypesHolder const & types) case VILLAGE: return NONE; case LOCALITY_COUNT: return type; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } // TODO: Format street and house number according to local country's rules. @@ -432,8 +431,7 @@ Result Ranker::MakeResult(RankerResult const & rankerResult, bool needAddress, case RankerResult::Type::TYPE_LATLON: return Result(r.GetCenter(), name, address); } ASSERT(false, ("Bad RankerResult type:", static_cast(r.GetResultType()))); - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); }; auto res = mk(rankerResult); diff --git a/search/result.cpp b/search/result.cpp index 5379c78be2..23f0c59ff7 100644 --- a/search/result.cpp +++ b/search/result.cpp @@ -193,7 +193,7 @@ bool Results::AddResult(Result && result) if (result.IsSuggest()) { - auto d = distance(m_results.begin(), it); + auto const d = distance(m_results.begin(), it); if (d >= static_cast(kMaxNumSuggests)) return false; diff --git a/search/retrieval.cpp b/search/retrieval.cpp index fe80a7c2d9..8206b35c44 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -374,7 +374,6 @@ unique_ptr Retrieval::Retrieve(Args &&... args) con return r(*m_root1, m_context, m_cancellable, forward(args)...); } } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace search diff --git a/search/search_quality/assessment_tool/main_model.cpp b/search/search_quality/assessment_tool/main_model.cpp index 9d6ae575ad..345cbaf8c6 100644 --- a/search/search_quality/assessment_tool/main_model.cpp +++ b/search/search_quality/assessment_tool/main_model.cpp @@ -193,8 +193,7 @@ void MainModel::OnNonFoundResultSelected(int index) auto const & results = context.m_nonFoundResults; CHECK_GREATER_OR_EQUAL(index, 0, ()); - CHECK_LESS(static_cast(index), - results.size(), ()); + CHECK_LESS(static_cast(index), results.size(), ()); m_view->MoveViewportToResult(results[index]); } diff --git a/search/search_tests/keyword_matcher_test.cpp b/search/search_tests/keyword_matcher_test.cpp index 1203fc4770..3112fec91b 100644 --- a/search/search_tests/keyword_matcher_test.cpp +++ b/search/search_tests/keyword_matcher_test.cpp @@ -260,8 +260,9 @@ string GetManyTokens(string tokenPrefix, int tokenCount, bool countForward = tru UNIT_TEST(KeywordMatcher_QueryTooLong) { static_assert(kMaxNumTokens >= 2, ""); - for (int queryLength = kMaxNumTokens - 2; - queryLength <= static_cast(kMaxNumTokens + 2); ++queryLength) + int const minLength = kMaxNumTokens - 2; + int const maxLength = kMaxNumTokens + 2; + for (int queryLength = minLength; queryLength <= maxLength; ++queryLength) { string const query = GetManyTokens("Q", queryLength); string const queryWithPrefix = query + " Prefix"; diff --git a/storage/storage_defines.cpp b/storage/storage_defines.cpp index c4d6d07776..186e67e96e 100644 --- a/storage/storage_defines.cpp +++ b/storage/storage_defines.cpp @@ -34,8 +34,7 @@ string DebugPrint(Status status) case Status::EOutOfMemFailed: return "OutOfMemFailed"s; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(NodeStatus status) @@ -61,8 +60,7 @@ string DebugPrint(NodeStatus status) case NodeStatus::Partly: return "Partly"s; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(NodeErrorCode status) @@ -78,8 +76,7 @@ string DebugPrint(NodeErrorCode status) case NodeErrorCode::NoInetConnection: return "NoInetConnection"s; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } StatusAndError ParseStatus(Status innerStatus) @@ -107,8 +104,7 @@ StatusAndError ParseStatus(Status innerStatus) case Status::EOutOfMemFailed: return StatusAndError(NodeStatus::Error, NodeErrorCode::OutOfMemFailed); } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } string DebugPrint(StatusAndError statusAndError) diff --git a/storage/storage_integration_tests/storage_http_tests.cpp b/storage/storage_integration_tests/storage_http_tests.cpp index ad6ab5b9d7..19b06122d4 100644 --- a/storage/storage_integration_tests/storage_http_tests.cpp +++ b/storage/storage_integration_tests/storage_http_tests.cpp @@ -102,9 +102,9 @@ UNIT_CLASS_TEST(StorageHttpTest, StorageDownloadNodeAndDeleteNode) NodeAttrs nodeAttrs; m_storage.GetNodeAttrs(countryId, nodeAttrs); - TEST_EQUAL(static_cast(mapSize.first), + TEST_EQUAL(static_cast(mapSize.first), nodeAttrs.m_downloadingProgress.first, (countryId)); - TEST_EQUAL(static_cast(mapSize.second), + TEST_EQUAL(static_cast(mapSize.second), nodeAttrs.m_downloadingProgress.second, (countryId)); TEST_EQUAL(countryId, kCountryId, (countryId)); }; @@ -144,9 +144,9 @@ UNIT_CLASS_TEST(StorageHttpTest, StorageDownloadAndDeleteDisputedNode) NodeAttrs nodeAttrs; m_storage.GetNodeAttrs(countryId, nodeAttrs); - TEST_EQUAL(static_cast(mapSize.first), + TEST_EQUAL(static_cast(mapSize.first), nodeAttrs.m_downloadingProgress.first, (countryId)); - TEST_EQUAL(static_cast(mapSize.second), + TEST_EQUAL(static_cast(mapSize.second), nodeAttrs.m_downloadingProgress.second, (countryId)); }; diff --git a/storage/storage_tests/storage_tests.cpp b/storage/storage_tests/storage_tests.cpp index 8967c6d428..e5f94f7814 100644 --- a/storage/storage_tests/storage_tests.cpp +++ b/storage/storage_tests/storage_tests.cpp @@ -1437,12 +1437,12 @@ UNIT_TEST(StorageTest_GetUpdateInfoSingleMwm) storage.GetUpdateInfo("OutdatedCountry1", updateInfo); TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 1, ()); TEST_EQUAL(updateInfo.m_totalUpdateSizeInBytes, 50, ()); - TEST_EQUAL(updateInfo.m_sizeDifference, static_cast(50 - country1Size), ()); + TEST_EQUAL(updateInfo.m_sizeDifference, 50 - static_cast(country1Size), ()); storage.GetUpdateInfo("OutdatedCountry2", updateInfo); TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 1, ()); TEST_EQUAL(updateInfo.m_totalUpdateSizeInBytes, 1000, ()); - TEST_EQUAL(updateInfo.m_sizeDifference, static_cast(1000 - country2Size), ()); + TEST_EQUAL(updateInfo.m_sizeDifference, 1000 - static_cast(country2Size), ()); storage.GetUpdateInfo("Abkhazia", updateInfo); TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 0, ()); @@ -1460,7 +1460,7 @@ UNIT_TEST(StorageTest_GetUpdateInfoSingleMwm) TEST_EQUAL(updateInfo.m_numberOfMwmFilesToUpdate, 2, ()); TEST_EQUAL(updateInfo.m_totalUpdateSizeInBytes, 1050, ()); TEST_EQUAL(updateInfo.m_sizeDifference, - static_cast((1000 + 50) - (country1Size + country2Size)), ()); + (1000 + 50) - static_cast((country1Size + country2Size)), ()); } #endif // defined(OMIM_OS_DESKTOP) diff --git a/traffic/speed_groups.cpp b/traffic/speed_groups.cpp index ff7e6f23a1..a136e5721d 100644 --- a/traffic/speed_groups.cpp +++ b/traffic/speed_groups.cpp @@ -34,7 +34,6 @@ string DebugPrint(SpeedGroup const & group) case SpeedGroup::Unknown: return "Unknown"; case SpeedGroup::Count: return "Count"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace traffic diff --git a/ugc/serdes.hpp b/ugc/serdes.hpp index 2ae89cbbd1..57b58f8097 100644 --- a/ugc/serdes.hpp +++ b/ugc/serdes.hpp @@ -207,7 +207,7 @@ public: { auto const size = DesVarUint(); m.reserve(size); - for (int i = 0; i < size; ++i) + for (size_t i = 0; i < size; ++i) { std::pair p; (*this)(p); diff --git a/ugc/storage.hpp b/ugc/storage.hpp index 4a86993ad7..b9947925e2 100644 --- a/ugc/storage.hpp +++ b/ugc/storage.hpp @@ -59,8 +59,7 @@ inline std::string DebugPrint(Storage::SettingResult const & result) case Storage::SettingResult::InvalidUGC: return "Invalid UGC"; case Storage::SettingResult::WritingError: return "Writing Error"; } - - INCORRECT_VALUE_IN_THE_SWITCH(); + CHECK_SWITCH(); } } // namespace ugc