Skip to content

Commit 17ddb99

Browse files
authored
Merge pull request #1497 from joto/fix-sign-conversions
Fix some implicit signed-unsigned conversions
2 parents c0c391a + ff3ec86 commit 17ddb99

File tree

8 files changed

+24
-17
lines changed

8 files changed

+24
-17
lines changed

src/db-copy-mgr.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,10 @@ class db_copy_mgr_t
250250
{
251251
char const *const lookup_hex = "0123456789ABCDEF";
252252

253-
for (char c : wkb) {
254-
m_current->buffer += lookup_hex[(c >> 4U) & 0xfU];
255-
m_current->buffer += lookup_hex[c & 0xfU];
253+
for (auto c : wkb) {
254+
auto const num = static_cast<unsigned int>(c);
255+
m_current->buffer += lookup_hex[(num >> 4U) & 0xfU];
256+
m_current->buffer += lookup_hex[num & 0xfU];
256257
}
257258
m_current->buffer += '\t';
258259
}

src/middle-pgsql.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ middle_query_pgsql_t::rel_members_get(osmium::Relation const &rel,
458458
continue;
459459
}
460460
for (int j = 0; j < res.num_tuples(); ++j) {
461-
if (m.ref() == wayidspg[j]) {
461+
if (m.ref() == wayidspg[static_cast<std::size_t>(j)]) {
462462
{
463463
osmium::builder::WayBuilder builder{*buffer};
464464
builder.set_id(m.ref());

src/middle-ram.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void middle_ram_t::node(osmium::Node const &node)
152152
assert(node.visible());
153153

154154
if (m_store_options.locations) {
155-
m_node_locations.set(node.positive_id(), node.location());
155+
m_node_locations.set(node.id(), node.location());
156156
}
157157

158158
if (m_store_options.nodes &&
@@ -193,7 +193,7 @@ std::size_t middle_ram_t::nodes_get_list(osmium::WayNodeList *nodes) const
193193

194194
if (m_store_options.locations) {
195195
for (auto &nr : *nodes) {
196-
nr.set_location(m_node_locations.get(nr.positive_ref()));
196+
nr.set_location(m_node_locations.get(nr.ref()));
197197
if (nr.location().valid()) {
198198
++count;
199199
}

src/progress-display.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,29 @@ uint64_t progress_display_t::nodes_time(std::time_t now) const noexcept
8888
if (m_node.count == 0) {
8989
return 0;
9090
}
91-
return (m_way.start > 0 ? m_way.start : now) - m_node.start;
91+
return static_cast<uint64_t>((m_way.start > 0 ? m_way.start : now) -
92+
m_node.start);
9293
}
9394

9495
uint64_t progress_display_t::ways_time(std::time_t now) const noexcept
9596
{
9697
if (m_way.count == 0) {
9798
return 0;
9899
}
99-
return (m_rel.start > 0 ? m_rel.start : now) - m_way.start;
100+
return static_cast<uint64_t>((m_rel.start > 0 ? m_rel.start : now) -
101+
m_way.start);
100102
}
101103

102104
uint64_t progress_display_t::rels_time(std::time_t now) const noexcept
103105
{
104106
if (m_rel.count == 0) {
105107
return 0;
106108
}
107-
return now - m_rel.start;
109+
return static_cast<uint64_t>(now - m_rel.start);
108110
}
109111

110112
uint64_t progress_display_t::overall_time(std::time_t now) const noexcept
111113
{
112-
return now - m_node.start;
114+
return static_cast<uint64_t>(now - m_node.start);
113115
}
114116

src/tagtransform-c.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ std::unique_ptr<tagtransform_t> c_tagtransform_t::clone() const
100100
}
101101

102102
bool c_tagtransform_t::check_key(std::vector<taginfo> const &infos,
103-
char const *k, bool *filter, int *flags)
103+
char const *k, bool *filter,
104+
unsigned int *flags)
104105
{
105106
//go through the actual tags found on the item and keep the ones in the export list
106107
for (auto const &info : infos) {
@@ -150,7 +151,7 @@ bool c_tagtransform_t::filter_tags(osmium::OSMObject const &o, bool *polygon,
150151
//assume we dont like this set of tags
151152
bool filter = true;
152153

153-
int flags = 0;
154+
unsigned int flags = 0;
154155
int add_area_tag = 0;
155156

156157
auto export_type = o.type();

src/tagtransform-c.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class c_tagtransform_t : public tagtransform_t
3131

3232
private:
3333
bool check_key(std::vector<taginfo> const &infos, char const *k,
34-
bool *filter, int *flags);
34+
bool *filter, unsigned int *flags);
3535

3636
options_t const *m_options;
3737
export_list m_export_list;

src/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ std::string human_readable_duration(uint64_t seconds)
4040

4141
std::string human_readable_duration(std::chrono::milliseconds ms)
4242
{
43-
return human_readable_duration(
44-
std::chrono::duration_cast<std::chrono::seconds>(ms).count());
43+
return human_readable_duration(static_cast<uint64_t>(
44+
std::chrono::duration_cast<std::chrono::seconds>(ms).count()));
4545
}
4646

4747
} // namespace util

src/util.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ class timer_t
9393
uint64_t stop() noexcept
9494
{
9595
m_stop = std::time(nullptr);
96-
return m_stop - m_start;
96+
return static_cast<uint64_t>(m_stop - m_start);
9797
}
9898

9999
/// Return elapsed time
100-
uint64_t elapsed() const noexcept { return m_stop - m_start; }
100+
uint64_t elapsed() const noexcept
101+
{
102+
return static_cast<uint64_t>(m_stop - m_start);
103+
}
101104

102105
/**
103106
* Calculate ratio: value divided by elapsed time.

0 commit comments

Comments
 (0)