Skip to content

Commit

Permalink
reduce compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Oct 8, 2024
1 parent d513c4c commit 649e1c1
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[geo]
[email protected]:motis-project/geo.git
branch=master
commit=b74f5797c7f1b693b2e8d28a14c0e7836456ff7e
commit=5d99aeb10674a41a82d7c78f850abfd9605bf6e1
[lmdb]
[email protected]:motis-project/lmdb.git
branch=master
Expand Down
10 changes: 5 additions & 5 deletions include/tiles/db/feature_pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct feature_packer {
void finish_header(size_t const feature_count) {
utl::verify(feature_count <= std::numeric_limits<uint32_t>::max(),
"packer.finish_header: to many features to serialize");
tiles::append<uint32_t>(buf_, feature_count);
tiles::append<uint32_t>(buf_, static_cast<uint32_t>(feature_count));
tiles::append<uint8_t>(buf_, static_cast<uint8_t>(segment_offsets_.size()));

for (auto& [id, offset] : segment_offsets_) {
Expand All @@ -84,7 +84,7 @@ struct feature_packer {

template <typename It>
uint32_t append_features(It begin, It end) {
uint32_t offset = buf_.size();
auto const offset = static_cast<uint32_t>(buf_.size());
for (auto it = begin; it != end; ++it) {
append_feature(*it);
}
Expand All @@ -104,7 +104,7 @@ struct feature_packer {
}

uint32_t append_packed(std::vector<uint32_t> const& vec) {
uint32_t offset = buf_.size();
auto const offset = static_cast<uint32_t>(buf_.size());
for (auto const& e : vec) {
protozero::write_varint(std::back_inserter(buf_), e);
}
Expand All @@ -113,7 +113,7 @@ struct feature_packer {

template <typename String>
uint32_t append(String const& string) {
uint32_t offset = buf_.size();
auto const offset = static_cast<uint32_t>(buf_.size());
buf_.append(string);
return offset;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ size_t unpack_features(std::string_view const& string, Fn&& fn) {
fn(std::string_view{ptr, size});
ptr += size;
}
return std::distance(string.data(), ptr);
return static_cast<size_t>(std::distance(string.data(), ptr));
}

template <typename Fn>
Expand Down
9 changes: 5 additions & 4 deletions include/tiles/db/quad_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ namespace tiles {
// additional information.

using quad_entry_t = uint32_t;
constexpr auto const kQuadEntryBits = sizeof(quad_entry_t) * 8;
constexpr auto const kQuadChildOffset = kQuadEntryBits - 4;
constexpr auto const kQuadEntryBits = sizeof(quad_entry_t) * 8U;
constexpr auto const kQuadChildOffset =
static_cast<unsigned>(kQuadEntryBits - 4U);
constexpr auto const kQuadOffsetMask =
(static_cast<quad_entry_t>(1) << (kQuadEntryBits - 4)) - 1;

Expand Down Expand Up @@ -102,7 +103,7 @@ void walk_quad_tree(char const* base, geo::tile const& root,
trace.push_back(root);
std::reverse(begin(trace), end(trace));

auto offset = 0;
auto offset = 0U;
for (auto it = begin(trace); it != end(trace); ++it) {
if (*it == query) {
// query tile found -> emit fill subtree and stop
Expand Down Expand Up @@ -131,7 +132,7 @@ void walk_quad_tree(char const* base, geo::tile const& root,
}

offset = curr & kQuadOffsetMask;
for (auto i = 0ULL; i < next_tile.quad_pos(); ++i) {
for (auto i = 0U; i < next_tile.quad_pos(); ++i) {
if (bit_set(curr, kQuadChildOffset + i)) {
offset += 4; // four entries/children per node
}
Expand Down
3 changes: 2 additions & 1 deletion include/tiles/db/shared_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ struct shared_metadata_builder {
auto old_size = counts_.size();
utl::concat(counts_, buf_counts);
std::inplace_merge(
begin(counts_), begin(counts_) + old_size, end(counts_),
begin(counts_), begin(counts_) + static_cast<long>(old_size),
end(counts_),
[](auto const& a, auto const& b) { return a.first < b.first; });

utl::equal_ranges_linear(
Expand Down
2 changes: 1 addition & 1 deletion include/tiles/db/tile_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct dbi_handle {
lmdb::dbi_flags flags = lmdb::dbi_flags::CREATE)
: env_{env},
dbi_opener_{
[dbiname{std::move(dbiname)}](
[dbiname = std::move(dbiname)](
lmdb::txn& txn, lmdb::dbi_flags flags = lmdb::dbi_flags::NONE) {
return txn.dbi_open(dbiname.c_str(), flags);
}},
Expand Down
8 changes: 4 additions & 4 deletions include/tiles/db/tile_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ inline geo::tile_range make_tile_range(fixed_box /*copy*/ box,
uint32_t z = kTileDefaultIndexZoomLvl) {
shift(box, z);

uint32_t const x_1 = box.min_corner().x() / kTileSize;
uint32_t const y_1 = box.min_corner().y() / kTileSize;
uint32_t const x_2 = box.max_corner().x() / kTileSize;
uint32_t const y_2 = box.max_corner().y() / kTileSize;
auto const x_1 = static_cast<uint32_t>(box.min_corner().x() / kTileSize);
auto const y_1 = static_cast<uint32_t>(box.min_corner().y() / kTileSize);
auto const x_2 = static_cast<uint32_t>(box.max_corner().x() / kTileSize);
auto const y_2 = static_cast<uint32_t>(box.max_corner().y() / kTileSize);

return geo::make_tile_range(x_1, y_1, x_2, y_2, z);
}
Expand Down
9 changes: 6 additions & 3 deletions include/tiles/feature/deserialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ inline std::optional<feature> deserialize_feature(
case tags::feature::packed_uint64_meta_pairs:
utl::verify(meta.empty(),
"meta_pairs must come before, meta keys/values!");
for (auto const id : msg.get_packed_uint64()) {
meta.push_back(metadata_decoder.decode(id));
for (auto const packed_id : msg.get_packed_uint64()) {
meta.push_back(metadata_decoder.decode(packed_id));
}
meta_fill = meta.size();
break;

case tags::feature::repeated_string_keys:
meta.emplace_back(msg.get_string(), std::string{});
break;

case tags::feature::repeated_string_values:
utl::verify(meta_fill < meta.size(), "meta data imbalance! (a)");
meta[meta_fill++].value_ = msg.get_string();
Expand All @@ -99,8 +101,8 @@ inline std::optional<feature> deserialize_feature(
case tags::feature::repeated_string_simplify_masks:
simplify_masks.emplace_back(msg.get_view());
break;
case tags::feature::required_fixed_geometry_geometry: {

case tags::feature::required_fixed_geometry_geometry: {
std::vector<std::string_view> simplify_masks_tmp;
std::swap(simplify_masks, simplify_masks_tmp);
if (zoom_level_hint != kInvalidZoomLevel &&
Expand All @@ -114,6 +116,7 @@ inline std::optional<feature> deserialize_feature(
geometry = deserialize(msg.get_view());
}
} break;

default: msg.skip();
}
}
Expand Down
4 changes: 3 additions & 1 deletion include/tiles/feature/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ enum class feature : protozero::pbf_tag_type {
repeated_string_values = 5,

repeated_string_simplify_masks = 6,
required_fixed_geometry_geometry = 7
required_fixed_geometry_geometry = 7,

other = 999
};

} // namespace tags
Expand Down
6 changes: 4 additions & 2 deletions include/tiles/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template <typename... Args>
inline void t_log(fmt::format_string<Args...> fmt_str, Args&&... args) {
using clock = std::chrono::system_clock;
auto const now = clock::to_time_t(clock::now());
struct tm tmp {};
struct tm tmp{};
#if _MSC_VER >= 1400
gmtime_s(&tmp, &now);
#else
Expand Down Expand Up @@ -60,7 +60,9 @@ struct scoped_timer final {
using namespace std::chrono;

auto const now = steady_clock::now();
double dur = duration_cast<microseconds>(now - start_).count() / 1000.0;
double dur =
static_cast<double>(duration_cast<microseconds>(now - start_).count()) /
1000.0;

std::clog << "|> done: " << label_ << " (";
if (dur < 1000) {
Expand Down

0 comments on commit 649e1c1

Please sign in to comment.