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..a7e59c4fff 100644 --- a/3party/freetype/CMakeLists.txt +++ b/3party/freetype/CMakeLists.txt @@ -9,6 +9,10 @@ endif () add_compile_options("-Wall") add_clang_compile_options("-Wno-unused-function") +add_gcc_compile_options( + "-Wno-pointer-to-int-cast" + "-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..ac4cc60787 100644 --- a/3party/opening_hours/CMakeLists.txt +++ b/3party/opening_hours/CMakeLists.txt @@ -12,6 +12,10 @@ add_compile_options( ) add_clang_compile_options("-Wno-unused-local-typedef") +add_gcc_compile_options( + "-Wno-unused-local-typedef" + "-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/CMakeLists.txt b/CMakeLists.txt index b697ce263e..e746ece555 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) @@ -260,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/base/assert.hpp b/base/assert.hpp index 16c78dc89e..ab16850ed7 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 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 2d7cab01b1..112d1e2228 100644 --- a/base/base_tests/levenshtein_dfa_test.cpp +++ b/base/base_tests/levenshtein_dfa_test.cpp @@ -42,6 +42,7 @@ string DebugPrint(Status status) case Status::Rejects: return "Rejects"; case Status::Intermediate: return "Intermediate"; } + 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 424007c40f..12ebe85699 100644 --- a/base/base_tests/stl_helpers_test.cpp +++ b/base/base_tests/stl_helpers_test.cpp @@ -92,7 +92,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) - TEST_EQUAL(i, v[i].first, ()); + TEST_EQUAL(i, static_cast(v[i].first), ()); std::vector pv; for (auto const & p : v) @@ -100,7 +100,7 @@ UNIT_TEST(LessBy) std::sort(pv.begin(), pv.end(), my::LessBy(&Value::second)); for (size_t i = 0; i < pv.size(); ++i) - TEST_EQUAL(i, pv[i]->second, ()); + TEST_EQUAL(i, static_cast(pv[i]->second), ()); } { diff --git a/base/levenshtein_dfa.cpp b/base/levenshtein_dfa.cpp index 9c0b09b00c..7ea5023724 100644 --- a/base/levenshtein_dfa.cpp +++ b/base/levenshtein_dfa.cpp @@ -4,6 +4,7 @@ #include "base/stl_helpers.hpp" #include +#include #include #include #include @@ -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 const 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/cmake/OmimHelpers.cmake b/cmake/OmimHelpers.cmake index 340de3905a..0dbdb0c139 100644 --- a/cmake/OmimHelpers.cmake +++ b/cmake/OmimHelpers.cmake @@ -162,6 +162,24 @@ 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(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) diff --git a/coding/compressed_bit_vector.cpp b/coding/compressed_bit_vector.cpp index 88a863c27f..45b00abdcb 100644 --- a/coding/compressed_bit_vector.cpp +++ b/coding/compressed_bit_vector.cpp @@ -461,6 +461,7 @@ string DebugPrint(CompressedBitVector::StorageStrategy strat) case CompressedBitVector::StorageStrategy::Dense: return "Dense"; case CompressedBitVector::StorageStrategy::Sparse: return "Sparse"; } + CHECK_SWITCH(); } // static 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..2e809e7bf1 100644 --- a/coding/point_to_integer.cpp +++ b/coding/point_to_integer.cpp @@ -7,8 +7,8 @@ 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), uint64_t{3} << 2 * POINT_COORD_BITS, ()); return res; } @@ -19,7 +19,8 @@ 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), 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 00412b3f7a..9b156cd629 100644 --- a/coding/zlib.cpp +++ b/coding/zlib.cpp @@ -19,6 +19,7 @@ int ToInt(ZLib::Deflate::Level level) case Level::BestCompression: return Z_BEST_COMPRESSION; case Level::DefaultCompression: return Z_DEFAULT_COMPRESSION; } + CHECK_SWITCH(); } } // namespace 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/gui/ruler_helper.cpp b/drape_frontend/gui/ruler_helper.cpp index 22be59f7f2..ba48c7e7c1 100644 --- a/drape_frontend/gui/ruler_helper.cpp +++ b/drape_frontend/gui/ruler_helper.cpp @@ -225,7 +225,7 @@ double RulerHelper::CalcMetresDiff(double value) auto conversionFn = &Identity; auto units = measurement_utils::Units::Metric; - UNUSED_VALUE(settings::Get(settings::kMeasurementUnits, units)); + 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 9b12207baa..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) @@ -1018,8 +1019,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 +1110,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 +1127,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 +1140,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/editor/edits_migration.cpp b/editor/edits_migration.cpp index 9230d751e2..6e94f39f53 100644 --- a/editor/edits_migration.cpp +++ b/editor/edits_migration.cpp @@ -118,5 +118,6 @@ FeatureID MigrateFeatureIndex(osm::Editor::ForEachFeaturesNearByFn & forEach, case XMLFeature::Type::Relation: return MigrateWayOrRelatonFeatureIndex(forEach, xml, featureStatus, generateID); } + CHECK_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..596ebb7c06 100644 --- a/editor/xml_feature.cpp +++ b/editor/xml_feature.cpp @@ -400,6 +400,7 @@ string XMLFeature::TypeToString(Type type) case Type::Way: return kWayType; case Type::Relation: return kRelationType; } + CHECK_SWITCH(); } // static 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/osm_element.cpp b/generator/osm_element.cpp index 2a12bb8a62..2da58ee258 100644 --- a/generator/osm_element.cpp +++ b/generator/osm_element.cpp @@ -28,6 +28,7 @@ std::string DebugPrint(OsmElement::EntityType e) case OsmElement::EntityType::Member: return "member"; } + CHECK_SWITCH(); } diff --git a/generator/osm_o5m_source.hpp b/generator/osm_o5m_source.hpp index c5f924ccd3..5966ede0de 100644 --- a/generator/osm_o5m_source.hpp +++ b/generator/osm_o5m_source.hpp @@ -1,6 +1,7 @@ // See O5M Format definition at https://wiki.openstreetmap.org/wiki/O5m #pragma once +#include "base/assert.hpp" #include "base/stl_helpers.hpp" #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 { 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/geometry/line2d.cpp b/geometry/line2d.cpp index 061474463c..d0074d37b2 100644 --- a/geometry/line2d.cpp +++ b/geometry/line2d.cpp @@ -61,6 +61,7 @@ string DebugPrint(LineIntersector::Result::Type type) case Type::One: return "One"; case Type::Infinity: return "Infinity"; } + CHECK_SWITCH(); } string DebugPrint(LineIntersector::Result const & result) 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/feature_decl.cpp b/indexer/feature_decl.cpp index 9ad4ac8572..37ea6c72cd 100644 --- a/indexer/feature_decl.cpp +++ b/indexer/feature_decl.cpp @@ -19,6 +19,7 @@ string DebugPrint(feature::EGeomType type) case EGeomType::GEOM_LINE: return "GEOM_LINE"; case EGeomType::GEOM_AREA: return "GEOM_AREA"; } + CHECK_SWITCH(); } // static diff --git a/indexer/ftraits.hpp b/indexer/ftraits.hpp index 83e4c73ccb..5fcc471c7d 100644 --- a/indexer/ftraits.hpp +++ b/indexer/ftraits.hpp @@ -207,6 +207,7 @@ inline std::string DebugPrint(WheelchairAvailability wheelchair) case WheelchairAvailability::Yes: return "Yes"; case WheelchairAvailability::Limited: return "Limited"; } + CHECK_SWITCH(); } class Wheelchair : public TraitsBase diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 09c739be36..f8b9dc09a1 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -357,6 +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 ""; } + CHECK_SWITCH(); } IsWifiChecker::IsWifiChecker() diff --git a/indexer/interval_index_builder.hpp b/indexer/interval_index_builder.hpp index 86fa29d511..c2d8f00cdf 100644 --- a/indexer/interval_index_builder.hpp +++ b/indexer/interval_index_builder.hpp @@ -1,14 +1,20 @@ #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 | @@ -66,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 +147,7 @@ public: { 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(), 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 6b2766cb26..9c7adfcefc 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -448,6 +448,7 @@ string DebugPrint(MwmSet::RegResult result) case MwmSet::RegResult::UnsupportedFileFormat: return "UnsupportedFileFormat"; } + CHECK_SWITCH(); } string DebugPrint(MwmSet::Event::Type type) diff --git a/indexer/postcodes_matcher.cpp b/indexer/postcodes_matcher.cpp index 7eacf1fe1b..78c2e0ad07 100644 --- a/indexer/postcodes_matcher.cpp +++ b/indexer/postcodes_matcher.cpp @@ -64,6 +64,7 @@ public: case TStringSet::Status::Prefix: return isPrefix; case TStringSet::Status::Full: return true; } + CHECK_SWITCH(); } inline size_t GetMaxNumTokensInPostcode() const { return m_maxNumTokensInPostcode; } diff --git a/kml/serdes.cpp b/kml/serdes.cpp index 0fbb0fdeed..fe6dbab05b 100644 --- a/kml/serdes.cpp +++ b/kml/serdes.cpp @@ -122,6 +122,7 @@ std::string GetStyleForPredefinedColor(PredefinedColor color) case PredefinedColor::Count: return {}; } + CHECK_SWITCH(); } BookmarkIcon GetIcon(std::string const & iconName) diff --git a/kml/types.hpp b/kml/types.hpp index 76d6d525ac..55855ea67b 100644 --- a/kml/types.hpp +++ b/kml/types.hpp @@ -43,6 +43,7 @@ inline std::string DebugPrint(PredefinedColor color) case PredefinedColor::Orange: return "Orange"; case PredefinedColor::Count: return {}; } + CHECK_SWITCH(); } enum class AccessRules : uint8_t @@ -61,6 +62,7 @@ inline std::string DebugPrint(AccessRules accessRules) case AccessRules::Public: return "Public"; case AccessRules::Count: return {}; } + CHECK_SWITCH(); } enum class BookmarkIcon : uint16_t @@ -116,6 +118,7 @@ inline std::string DebugPrint(BookmarkIcon icon) case BookmarkIcon::Water: return "Water"; case BookmarkIcon::Count: return {}; } + CHECK_SWITCH(); } struct ColorData diff --git a/map/booking_filter_cache.cpp b/map/booking_filter_cache.cpp index 32dc68d6ae..4a8c7aacd5 100644 --- a/map/booking_filter_cache.cpp +++ b/map/booking_filter_cache.cpp @@ -106,6 +106,7 @@ std::string DebugPrint(Cache::HotelStatus status) case Cache::HotelStatus::Unavailable: return "Unavailable"; case Cache::HotelStatus::Available: return "Available"; } + CHECK_SWITCH(); } } // namespace availability } // namespace filter diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 6f766b75c0..2ed09ae523 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -36,6 +36,7 @@ std::string GetBookmarkIconType(kml::BookmarkIcon const & icon) ASSERT(false, ("Invalid bookmark icon type")); return {}; } + CHECK_SWITCH(); } } // namespace @@ -105,6 +106,7 @@ df::ColorConstant Bookmark::GetColorConstant() const case kml::PredefinedColor::Count: return "BookmarkRed"; } + CHECK_SWITCH(); } bool Bookmark::HasCreationAnimation() const diff --git a/map/bookmark_helpers.hpp b/map/bookmark_helpers.hpp index fba7c17565..8ba57f344b 100644 --- a/map/bookmark_helpers.hpp +++ b/map/bookmark_helpers.hpp @@ -26,6 +26,7 @@ inline std::string DebugPrint(KmlFileType fileType) case KmlFileType::Text: return "Text"; case KmlFileType::Binary: return "Binary"; } + 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 3fa0a056ca..1fc02e4dc0 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -97,6 +97,7 @@ bool IsValidFilterType(BookmarkManager::CategoryFilterType const filter, case BookmarkManager::CategoryFilterType::Public: return fromCatalog; case BookmarkManager::CategoryFilterType::Private: return !fromCatalog; } + CHECK_SWITCH(); } class FindMarkFunctor @@ -343,8 +344,12 @@ bool MigrateIfNeeded() if (files.empty()) { auto const newBookmarksDir = GetBookmarksDirectory(); - if (!GetPlatform().IsFileExistsByFullPath(newBookmarksDir)) - UNUSED_VALUE(GetPlatform().MkDirChecked(newBookmarksDir)); + if (!GetPlatform().IsFileExistsByFullPath(newBookmarksDir) && + !GetPlatform().MkDirChecked(newBookmarksDir)) + { + LOG(LWARNING, ("Could not create directory:", newBookmarksDir)); + return false; + } OnMigrationSuccess(0 /* originalCount */, 0 /* convertedCount */); return true; } @@ -894,7 +899,8 @@ void BookmarkManager::SaveState() const void BookmarkManager::LoadState() { - UNUSED_VALUE(settings::Get(kLastEditedBookmarkCategory, m_lastCategoryUrl)); + settings::TryGet(kLastEditedBookmarkCategory, m_lastCategoryUrl); + uint32_t color; if (settings::Get(kLastEditedBookmarkColor, color) && color > static_cast(kml::PredefinedColor::None) && diff --git a/map/chart_generator.cpp b/map/chart_generator.cpp index 6d1f754674..8983afd2b3 100644 --- a/map/chart_generator.cpp +++ b/map/chart_generator.cpp @@ -63,6 +63,7 @@ agg::rgba8 GetLineColor(MapStyle mapStyle) case MapStyleMerged: return agg::rgba8(30, 150, 240, 255); } + CHECK_SWITCH(); } agg::rgba8 GetCurveColor(MapStyle mapStyle) @@ -80,6 +81,7 @@ agg::rgba8 GetCurveColor(MapStyle mapStyle) case MapStyleMerged: return agg::rgba8(30, 150, 240, 20); } + CHECK_SWITCH(); } } // namespace @@ -219,8 +221,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; diff --git a/map/cloud.cpp b/map/cloud.cpp index 6614784d42..c72f62a6a0 100644 --- a/map/cloud.cpp +++ b/map/cloud.cpp @@ -128,6 +128,7 @@ bool CanUpload(uint64_t totalUploadingSize) return platform::GetCurrentNetworkPolicy().CanUse() && totalUploadingSize <= kMaxWwanUploadingSizeInBytes; } + CHECK_SWITCH(); } struct SnapshotCreateRequestData diff --git a/map/cloud.hpp b/map/cloud.hpp index 2482cdfee7..52a5ccf446 100644 --- a/map/cloud.hpp +++ b/map/cloud.hpp @@ -391,6 +391,7 @@ inline std::string DebugPrint(Cloud::SynchronizationType type) case Cloud::SynchronizationType::Backup: return "Backup"; case Cloud::SynchronizationType::Restore: return "Restore"; } + CHECK_SWITCH(); } inline std::string DebugPrint(Cloud::SynchronizationResult result) @@ -404,6 +405,7 @@ inline std::string DebugPrint(Cloud::SynchronizationResult result) case Cloud::SynchronizationResult::UserInterrupted: return "UserInterrupted"; case Cloud::SynchronizationResult::InvalidCall: return "InvalidCall"; } + CHECK_SWITCH(); } inline std::string DebugPrint(Cloud::RestoringRequestResult result) @@ -414,4 +416,5 @@ inline std::string DebugPrint(Cloud::RestoringRequestResult result) case Cloud::RestoringRequestResult::NoBackup: return "NoBackup"; case Cloud::RestoringRequestResult::NotEnoughDiskSpace: return "NotEnoughDiskSpace"; } + CHECK_SWITCH(); } diff --git a/map/discovery/discovery_manager.cpp b/map/discovery/discovery_manager.cpp index 35fb7a5f66..13693bb942 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 ""; } + + CHECK_SWITCH(); } } // namespace diff --git a/map/framework.cpp b/map/framework.cpp index cb7f97dffb..c10d0baa0b 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1932,7 +1932,7 @@ void Framework::SetupMeasurementSystem() GetPlatform().SetupMeasurementSystem(); auto units = measurement_utils::Units::Metric; - UNUSED_VALUE(settings::Get(settings::kMeasurementUnits, units)); + settings::TryGet(settings::kMeasurementUnits, units); m_routingManager.SetTurnNotificationsUnits(units); } diff --git a/map/gps_track_filter.cpp b/map/gps_track_filter.cpp index ef2db67c49..1ce1ffd57b 100644 --- a/map/gps_track_filter.cpp +++ b/map/gps_track_filter.cpp @@ -57,7 +57,7 @@ GpsTrackFilter::GpsTrackFilter() , m_countLastInfo(0) , m_countAcceptedInfo(0) { - UNUSED_VALUE(settings::Get(kMinHorizontalAccuracyKey, m_minAccuracy)); + settings::TryGet(kMinHorizontalAccuracyKey, m_minAccuracy); } void GpsTrackFilter::Process(vector const & inPoints, 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/map/mwm_url.cpp b/map/mwm_url.cpp index e78a4b1bfb..82f25f80a4 100644 --- a/map/mwm_url.cpp +++ b/map/mwm_url.cpp @@ -259,6 +259,7 @@ ParsedMapApi::ParsingResult ParsedMapApi::Parse(Uri const & uri) return ParsingResult::Lead; } } + 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 ea725fdea0..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,6 +29,7 @@ inline string DebugPrint(EPlaceState state) case EPlaceState::CloseSoon: return "EPlaceState::CloseSoon"; } + CHECK_SWITCH(); } inline EPlaceState PlaceStateCheck(string const & openingHours, time_t timestamp) diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index ab60aa2e09..bed1b8c245 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -207,6 +207,7 @@ VehicleType GetVehicleType(RouterType routerType) case RouterType::Transit: return VehicleType::Transit; case RouterType::Count: CHECK(false, ("Invalid type", routerType)); return VehicleType::Count; } + CHECK_SWITCH(); } } // namespace @@ -1037,7 +1038,8 @@ bool RoutingManager::IsTrackingReporterEnabled() const return false; bool enableTracking = true; - UNUSED_VALUE(settings::Get(tracking::Reporter::kEnableTrackingKey, enableTracking)); + settings::TryGet(tracking::Reporter::kEnableTrackingKey, enableTracking); + return enableTracking; } diff --git a/map/routing_mark.cpp b/map/routing_mark.cpp index 1a43dcb79d..8a8fceefba 100644 --- a/map/routing_mark.cpp +++ b/map/routing_mark.cpp @@ -102,6 +102,7 @@ uint16_t RouteMarkPoint::GetPriority() const } } } + CHECK_SWITCH(); } uint32_t RouteMarkPoint::GetIndex() const @@ -112,6 +113,7 @@ uint32_t RouteMarkPoint::GetIndex() const case RouteMarkType::Finish: return 1; case RouteMarkType::Intermediate: return static_cast(m_markData.m_intermediateIndex + 2); } + CHECK_SWITCH(); } void RouteMarkPoint::SetMarkData(RouteMarkData && data) diff --git a/map/user.cpp b/map/user.cpp index 0804180a41..7f73ca2bd1 100644 --- a/map/user.cpp +++ b/map/user.cpp @@ -68,6 +68,7 @@ std::string AuthenticationUrl(std::string const & socialToken, return ss.str(); } } + CHECK_SWITCH(); } std::string UserDetailsUrl() diff --git a/map/user_mark.cpp b/map/user_mark.cpp index bed1e11490..60d97a8947 100644 --- a/map/user_mark.cpp +++ b/map/user_mark.cpp @@ -86,4 +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"; } + 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 141507a8fd..1c8fe93757 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(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 706dda5c43..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,5 +34,6 @@ inline std::string DebugPrint(Banner::Type type) case Banner::Type::Mopub: return "Mopub"; case Banner::Type::Google: return "Google"; } + CHECK_SWITCH(); } } // namespace ads diff --git a/partners_api/taxi_places_loader.cpp b/partners_api/taxi_places_loader.cpp index 4c8288b40a..b430ff4529 100644 --- a/partners_api/taxi_places_loader.cpp +++ b/partners_api/taxi_places_loader.cpp @@ -55,6 +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 ""; } + CHECK_SWITCH(); } } // namespace places } // namespace taxi diff --git a/partners_api/taxi_provider.hpp b/partners_api/taxi_provider.hpp index 32a3019e7c..a5536d5c03 100644 --- a/partners_api/taxi_provider.hpp +++ b/partners_api/taxi_provider.hpp @@ -82,6 +82,7 @@ inline std::string DebugPrint(Provider::Type type) case Provider::Type::Maxim: return "Maxim"; case Provider::Type::Count: ASSERT(false, ()); return ""; } + CHECK_SWITCH(); } inline std::string DebugPrint(ErrorCode code) @@ -91,6 +92,7 @@ inline std::string DebugPrint(ErrorCode code) case ErrorCode::NoProducts: return "NoProducts"; case ErrorCode::RemoteError: return "RemoteError"; } + CHECK_SWITCH(); } inline std::string DebugPrint(ProviderError error) diff --git a/platform/country_defines.cpp b/platform/country_defines.cpp index d6ab946822..1533887524 100644 --- a/platform/country_defines.cpp +++ b/platform/country_defines.cpp @@ -38,4 +38,5 @@ string DebugPrint(MapOptions options) case MapOptions::Diff: return "Diff"; } + CHECK_SWITCH(); } 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/platform/local_country_file_utils.cpp b/platform/local_country_file_utils.cpp index c71990b408..2afaf2f204 100644 --- a/platform/local_country_file_utils.cpp +++ b/platform/local_country_file_utils.cpp @@ -467,5 +467,6 @@ string DebugPrint(CountryIndexes::Index index) case CountryIndexes::Index::Offsets: return "Offsets"; } + CHECK_SWITCH(); } } // namespace platform diff --git a/platform/measurement_utils.cpp b/platform/measurement_utils.cpp index f591e7aeb3..42ab2b5fc5 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,7 @@ bool FormatDistanceImpl(double m, string & res, bool FormatDistance(double m, string & res) { auto units = Units::Metric; - UNUSED_VALUE(Get(settings::kMeasurementUnits, units)); + TryGet(settings::kMeasurementUnits, units); /// @todo Put string units resources. switch (units) @@ -63,6 +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); } + CHECK_SWITCH(); } @@ -163,7 +165,7 @@ 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)); + TryGet(settings::kMeasurementUnits, units); ostringstream ss; ss << fixed << setprecision(0); @@ -180,7 +182,7 @@ string FormatAltitude(double altitudeInMeters) string FormatSpeedWithDeviceUnits(double metersPerSecond) { auto units = Units::Metric; - UNUSED_VALUE(Get(settings::kMeasurementUnits, units)); + TryGet(settings::kMeasurementUnits, units); return FormatSpeedWithUnits(metersPerSecond, units); } @@ -209,6 +211,7 @@ string FormatSpeedUnits(Units units) case Units::Imperial: return "mph"; case Units::Metric: return "km/h"; } + CHECK_SWITCH(); } bool OSMDistanceToMeters(string const & osmRawValue, double & outMeters) diff --git a/platform/measurement_utils.hpp b/platform/measurement_utils.hpp index 00a67a1754..d4251b509e 100644 --- a/platform/measurement_utils.hpp +++ b/platform/measurement_utils.hpp @@ -19,6 +19,7 @@ inline string DebugPrint(Units units) case Units::Imperial: return "Units::Imperial"; case Units::Metric: return "Units::Metric"; } + CHECK_SWITCH(); } inline double MetersToMiles(double m) { return m * 0.000621371192; } diff --git a/platform/mwm_traits.cpp b/platform/mwm_traits.cpp index 9ec21e7212..471effd226 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,7 @@ string DebugPrint(MwmTraits::SearchIndexFormat format) case MwmTraits::SearchIndexFormat::CompressedBitVector: return "CompressedBitVector"; } + CHECK_SWITCH(); } string DebugPrint(MwmTraits::HouseToStreetTableFormat format) @@ -50,5 +52,6 @@ string DebugPrint(MwmTraits::HouseToStreetTableFormat format) case MwmTraits::HouseToStreetTableFormat::Unknown: return "Unknown"; } + CHECK_SWITCH(); } } // namespace version diff --git a/platform/platform.cpp b/platform/platform.cpp index 39a9e86905..3f2edf3d36 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -306,6 +306,7 @@ string DebugPrint(Platform::EError err) case Platform::ERR_IO_ERROR: return "An I/O error occurred."; case Platform::ERR_UNKNOWN: return "Unknown"; } + CHECK_SWITCH(); } string DebugPrint(Platform::ChargingStatus status) @@ -316,4 +317,5 @@ string DebugPrint(Platform::ChargingStatus status) case Platform::ChargingStatus::Plugged: return "Plugged"; case Platform::ChargingStatus::Unplugged: return "Unplugged"; } + CHECK_SWITCH(); } diff --git a/platform/settings.cpp b/platform/settings.cpp index 7d9afacfd3..f26b39d2e4 100644 --- a/platform/settings.cpp +++ b/platform/settings.cpp @@ -280,6 +280,7 @@ string ToString(measurement_utils::Units const & v) case measurement_utils::Units::Imperial: return "Foot"; case measurement_utils::Units::Metric: return "Metric"; } + CHECK_SWITCH(); } template <> @@ -336,6 +337,7 @@ string ToString(Transliteration::Mode const & mode) case Transliteration::Mode::Enabled: return "Enabled"; case Transliteration::Mode::Disabled: return "Disabled"; } + 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 bad2b9c906..4a3b9c80a8 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -124,7 +124,8 @@ MainWindow::MainWindow(Framework & framework, bool apiOpenGLES3, QString const & #ifndef NO_DOWNLOADER // Show intro dialog if necessary bool bShow = true; - (void)settings::Get("ShowWelcome", bShow); + string const showWelcome = "ShowWelcome"; + settings::TryGet(showWelcome, bShow); if (bShow) { diff --git a/routing/bicycle_directions.cpp b/routing/bicycle_directions.cpp index 641d1e21ea..ff04e15bb4 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( + 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 f4de901e22..575c3467c8 100644 --- a/routing/cross_mwm_connector.cpp +++ b/routing/cross_mwm_connector.cpp @@ -13,6 +13,7 @@ std::string DebugPrint(WeightsLoadState state) case WeightsLoadState::NotExists: return "NotExists"; case WeightsLoadState::Loaded: return "Loaded"; } + CHECK_SWITCH(); } } // namespace connector } // namespace routing diff --git a/routing/cross_mwm_connector.hpp b/routing/cross_mwm_connector.hpp index cec680a002..deeeef2d6f 100644 --- a/routing/cross_mwm_connector.hpp +++ b/routing/cross_mwm_connector.hpp @@ -180,6 +180,7 @@ public: case connector::WeightsLoadState::NotExists: case connector::WeightsLoadState::Loaded: return true; } + CHECK_SWITCH(); } template diff --git a/routing/edge_estimator.cpp b/routing/edge_estimator.cpp index 58cb9013d1..6a45224845 100644 --- a/routing/edge_estimator.cpp +++ b/routing/edge_estimator.cpp @@ -214,6 +214,7 @@ shared_ptr EdgeEstimator::Create(VehicleType vehicleType, double CHECK(false, ("Can't create EdgeEstimator for", vehicleType)); return nullptr; } + CHECK_SWITCH(); } // static diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 472767b771..8c0a850542 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -98,6 +98,7 @@ shared_ptr CreateVehicleModelFactory( CHECK(false, ("Can't create VehicleModelFactoryInterface for", vehicleType)); return nullptr; } + CHECK_SWITCH(); } unique_ptr CreateDirectionsEngine(VehicleType vehicleType, @@ -115,6 +116,7 @@ unique_ptr CreateDirectionsEngine(VehicleType vehicleType, CHECK(false, ("Can't create DirectionsEngine for", vehicleType)); return nullptr; } + CHECK_SWITCH(); } shared_ptr CreateTrafficStash(VehicleType vehicleType, shared_ptr numMwmIds, @@ -761,7 +763,7 @@ 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 (size_t i = 0; i <= finishLeapStart; ++i) { @@ -780,7 +782,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(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 +809,7 @@ RouterResultCode IndexRouter::ProcessLeaps(vector const & input, else { ++i; - CHECK_LESS(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 41d7b04013..e7cd938d18 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -127,6 +127,7 @@ private: case AStarAlgorithm::Result::Cancelled: return RouterResultCode::Cancelled; case AStarAlgorithm::Result::OK: return RouterResultCode::NoError; } + CHECK_SWITCH(); } template diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp index f152dbfd9e..db342212c3 100644 --- a/routing/road_graph.cpp +++ b/routing/road_graph.cpp @@ -310,6 +310,7 @@ string DebugPrint(IRoadGraph::Mode mode) case IRoadGraph::Mode::ObeyOnewayTag: return "ObeyOnewayTag"; case IRoadGraph::Mode::IgnoreOnewayTag: return "IgnoreOnewayTag"; } + CHECK_SWITCH(); } IRoadGraph::RoadInfo MakeRoadInfoForTesting(bool bidirectional, double speedKMPH, diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index e8a26acd98..860519645c 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -802,5 +802,6 @@ string DebugPrint(RoutingSession::State state) case RoutingSession::RouteNoFollowing: return "RouteNoFollowing"; case RoutingSession::RouteRebuilding: return "RouteRebuilding"; } + CHECK_SWITCH(); } } // namespace routing diff --git a/routing/routing_settings.cpp b/routing/routing_settings.cpp index c3a26f9899..8a2994dab5 100644 --- a/routing/routing_settings.cpp +++ b/routing/routing_settings.cpp @@ -26,5 +26,6 @@ RoutingSettings GetRoutingSettings(VehicleType vehicleType) CHECK(false, ("Can't create GetRoutingSettings for", vehicleType)); return {}; } + CHECK_SWITCH(); } } // namespace routing diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index b4d6dbc045..daaeb92395 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()); @@ -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 bc7fbf47cc..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 7393f04410..41b5815d29 100644 --- a/routing/transit_info.hpp +++ b/routing/transit_info.hpp @@ -149,5 +149,6 @@ inline std::string DebugPrint(TransitInfo::Type type) case TransitInfo::Type::Edge: return "Edge"; case TransitInfo::Type::Transfer: return "Transfer"; } + CHECK_SWITCH(); } } // namespace routing diff --git a/routing/vehicle_mask.cpp b/routing/vehicle_mask.cpp index bf9a60cff1..d0f685deaf 100644 --- a/routing/vehicle_mask.cpp +++ b/routing/vehicle_mask.cpp @@ -19,6 +19,7 @@ string DebugPrint(VehicleType vehicleType) case VehicleType::Transit: return "Transit"; case VehicleType::Count: return "Count"; } + CHECK_SWITCH(); } string ToString(VehicleType vehicleType) { return DebugPrint(vehicleType); } diff --git a/search/features_layer_matcher.hpp b/search/features_layer_matcher.hpp index 22aea70380..835984ea7c 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; diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 7a0624d963..a7270d7608 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -1414,6 +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(); } + 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 50bc7025f6..21e42e235e 100644 --- a/search/geocoder_context.cpp +++ b/search/geocoder_context.cpp @@ -24,6 +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; } + CHECK_SWITCH(); } // static @@ -35,6 +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; } + CHECK_SWITCH(); } size_t BaseContext::SkipUsedTokens(size_t curToken) const @@ -97,5 +99,6 @@ string DebugPrint(BaseContext::TokenType type) case BaseContext::TOKEN_TYPE_POSTCODE: return "POSTCODE"; case BaseContext::TOKEN_TYPE_COUNT: return "COUNT"; } + CHECK_SWITCH(); } } // namespace search diff --git a/search/geocoder_locality.cpp b/search/geocoder_locality.cpp index 2cf619eff0..f92b233223 100644 --- a/search/geocoder_locality.cpp +++ b/search/geocoder_locality.cpp @@ -13,6 +13,7 @@ Model::Type Region::ToModelType(Type type) case Region::TYPE_COUNTRY: return Model::TYPE_COUNTRY; case Region::TYPE_COUNT: return Model::TYPE_COUNT; } + CHECK_SWITCH(); } std::string DebugPrint(Locality const & locality) diff --git a/search/house_numbers_matcher.cpp b/search/house_numbers_matcher.cpp index 06da74bf05..8ade89e197 100644 --- a/search/house_numbers_matcher.cpp +++ b/search/house_numbers_matcher.cpp @@ -166,6 +166,7 @@ public: case TStrings::Status::Prefix: return isPrefix; case TStrings::Status::Full: return true; } + CHECK_SWITCH(); } private: @@ -236,6 +237,7 @@ public: case TPatterns::Status::Prefix: return true; case TPatterns::Status::Full: return true; } + CHECK_SWITCH(); } private: @@ -250,6 +252,7 @@ private: case 'U': return Token::TYPE_BUILDING_PART_OR_LETTER; default: CHECK(false, ("Unexpected character:", c)); return Token::TYPE_SEPARATOR; } + 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 68d20980f0..4ebdb53ea6 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 (size_t 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/mwm_context.cpp b/search/mwm_context.cpp index 433200e225..81f49d95e1 100644 --- a/search/mwm_context.cpp +++ b/search/mwm_context.cpp @@ -37,6 +37,7 @@ bool MwmContext::GetFeature(uint32_t index, FeatureType & ft) const ft.SetID(FeatureID(GetId(), index)); return true; } + 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 d7d53ab67b..b0c4e054cf 100644 --- a/search/nested_rects_cache.cpp +++ b/search/nested_rects_cache.cpp @@ -82,6 +82,7 @@ double NestedRectsCache::GetRadiusMeters(RectScale scale) case RECT_SCALE_LARGE: return 2500.0; case RECT_SCALE_COUNT: return 5000.0; } + CHECK_SWITCH(); } void NestedRectsCache::Update() diff --git a/search/ranker.cpp b/search/ranker.cpp index 1931b9dbb1..4239d4f95d 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -145,6 +145,7 @@ ftypes::Type GetLocalityIndex(feature::TypesHolder const & types) case VILLAGE: return NONE; case LOCALITY_COUNT: return type; } + CHECK_SWITCH(); } // TODO: Format street and house number according to local country's rules. @@ -430,6 +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()))); + CHECK_SWITCH(); }; auto res = mk(rankerResult); diff --git a/search/result.cpp b/search/result.cpp index a6ee26ddeb..23f0c59ff7 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 const 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/retrieval.cpp b/search/retrieval.cpp index a94d292458..8206b35c44 100644 --- a/search/retrieval.cpp +++ b/search/retrieval.cpp @@ -367,14 +367,13 @@ 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; } + 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 822d839d2d..3cf0a7cc59 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,32 @@ 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 +210,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 +260,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 +275,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 +300,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 +401,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..3112fec91b 100644 --- a/search/search_tests/keyword_matcher_test.cpp +++ b/search/search_tests/keyword_matcher_test.cpp @@ -260,7 +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 <= 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 17e359bb5c..186e67e96e 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,7 @@ string DebugPrint(Status status) case Status::EOutOfMemFailed: return "OutOfMemFailed"s; } + CHECK_SWITCH(); } string DebugPrint(NodeStatus status) @@ -57,6 +60,7 @@ string DebugPrint(NodeStatus status) case NodeStatus::Partly: return "Partly"s; } + CHECK_SWITCH(); } string DebugPrint(NodeErrorCode status) @@ -72,6 +76,7 @@ string DebugPrint(NodeErrorCode status) case NodeErrorCode::NoInetConnection: return "NoInetConnection"s; } + CHECK_SWITCH(); } StatusAndError ParseStatus(Status innerStatus) @@ -99,6 +104,7 @@ StatusAndError ParseStatus(Status innerStatus) case Status::EOutOfMemFailed: return StatusAndError(NodeStatus::Error, NodeErrorCode::OutOfMemFailed); } + 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 cc4b727320..19b06122d4 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..e5f94f7814 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, 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, 1000 - country2Size, ()); + TEST_EQUAL(updateInfo.m_sizeDifference, 1000 - static_cast(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, + (1000 + 50) - static_cast((country1Size + country2Size)), ()); } #endif // defined(OMIM_OS_DESKTOP) diff --git a/traffic/speed_groups.cpp b/traffic/speed_groups.cpp index 926be45bfd..a136e5721d 100644 --- a/traffic/speed_groups.cpp +++ b/traffic/speed_groups.cpp @@ -34,5 +34,6 @@ string DebugPrint(SpeedGroup const & group) case SpeedGroup::Unknown: return "Unknown"; case SpeedGroup::Count: return "Count"; } + 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 bc14492eed..e3d5c21f45 100644 --- a/ugc/storage.hpp +++ b/ugc/storage.hpp @@ -59,6 +59,7 @@ inline std::string DebugPrint(Storage::SettingResult const & result) case Storage::SettingResult::InvalidUGC: return "Invalid UGC"; case Storage::SettingResult::WritingError: return "Writing Error"; } + CHECK_SWITCH(); } } // namespace ugc