Skip to content

Commit a00a8e2

Browse files
committed
More small cleanups found by clang-tidy
1 parent 2b50e06 commit a00a8e2

File tree

10 files changed

+34
-32
lines changed

10 files changed

+34
-32
lines changed

src/expire-tiles.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ void expire_tiles::coords_to_tile(double lon, double lat, double *tilex,
141141
void expire_tiles::from_line(double lon_a, double lat_a, double lon_b,
142142
double lat_b)
143143
{
144-
double tile_x_a;
145-
double tile_y_a;
146-
double tile_x_b;
147-
double tile_y_b;
144+
double tile_x_a = NAN;
145+
double tile_y_a = NAN;
146+
double tile_x_b = NAN;
147+
double tile_y_b = NAN;
148148

149149
coords_to_tile(lon_a, lat_a, &tile_x_a, &tile_y_a);
150150
coords_to_tile(lon_b, lat_b, &tile_x_b, &tile_y_b);
@@ -237,8 +237,8 @@ int expire_tiles::from_bbox(double min_lon, double min_lat, double max_lon,
237237
}
238238

239239
/* Convert the box's Mercator coordinates into tile coordinates */
240-
double tmp_x;
241-
double tmp_y;
240+
double tmp_x = NAN;
241+
double tmp_y = NAN;
242242
coords_to_tile(min_lon, max_lat, &tmp_x, &tmp_y);
243243
int min_tile_x = tmp_x - TILE_EXPIRY_LEEWAY;
244244
int min_tile_y = tmp_y - TILE_EXPIRY_LEEWAY;

src/gazetteer-style.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@
2121
#include "pgsql.hpp"
2222
#include "wkb.hpp"
2323

24-
namespace {
25-
26-
enum : int
27-
{
28-
MAX_ADMINLEVEL = 15
29-
};
30-
31-
} // anonymous namespace
32-
3324
namespace pt = boost::property_tree;
3425

3526
void db_deleter_place_t::delete_rows(std::string const &table,

src/gazetteer-style.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class gazetteer_copy_mgr_t : public db_copy_mgr_t<db_deleter_place_t>
9494
std::shared_ptr<db_target_descr_t> m_table;
9595
};
9696

97+
enum : int
98+
{
99+
MAX_ADMINLEVEL = 15
100+
};
101+
97102
class gazetteer_style_t
98103
{
99104
using flag_t = uint16_t;
@@ -179,7 +184,7 @@ class gazetteer_style_t
179184
/// value of operator tag
180185
char const *m_operator = nullptr;
181186
/// admin level
182-
int m_admin_level;
187+
int m_admin_level = MAX_ADMINLEVEL;
183188

184189
/// which metadata fields of the OSM objects should be written to the output
185190
osmium::metadata_options m_metadata_fields{"none"};

src/options.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ options_t::options_t()
294294

295295
static osmium::Box parse_bbox(char const *bbox)
296296
{
297-
double minx;
298-
double maxx;
299-
double miny;
300-
double maxy;
297+
double minx = NAN;
298+
double maxx = NAN;
299+
double miny = NAN;
300+
double maxy = NAN;
301301

302302
int const n = sscanf(bbox, "%lf,%lf,%lf,%lf", &minx, &miny, &maxx, &maxy);
303303
if (n != 4) {
@@ -349,7 +349,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
349349

350350
bool help_verbose = false; // Will be set when -v/--verbose is set
351351

352-
int c;
352+
int c = 0;
353353

354354
//keep going while there are args left to handle
355355
// note: optind would seem to need to be set to 1, but that gives valgrind

src/table.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ void table_t::escape_type(std::string const &value, ColumnType flags)
386386
switch (flags) {
387387
case ColumnType::INT: {
388388
// For integers we take the first number, or the average if it's a-b
389-
long long from, to;
389+
long long from = 0;
390+
long long to = 0;
390391
// limit number of digits parsed to avoid undefined behaviour in sscanf
391392
int const items =
392393
std::sscanf(value.c_str(), "%18lld-%18lld", &from, &to);
@@ -420,7 +421,8 @@ void table_t::escape_type(std::string const &value, ColumnType flags)
420421
std::string escaped{value};
421422
std::replace(escaped.begin(), escaped.end(), ',', '.');
422423

423-
double from, to;
424+
double from = NAN;
425+
double to = NAN;
424426
int const items =
425427
std::sscanf(escaped.c_str(), "%lf-%lf", &from, &to);
426428
if (items == 1) {

src/tagtransform-lua.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ class lua_tagtransform_t : public tagtransform_t
4343
void open_style();
4444
void check_lua_function_exists(std::string const &func_name);
4545

46-
lua_State *L;
47-
std::string m_node_func, m_way_func, m_rel_func, m_rel_mem_func;
46+
lua_State *L = nullptr;
47+
std::string m_node_func;
48+
std::string m_way_func;
49+
std::string m_rel_func;
50+
std::string m_rel_mem_func;
4851
std::string m_lua_file;
4952
bool m_extra_attributes;
5053
};

src/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ std::string get_password()
6363
GetConsoleMode(handle_stdin, &mode);
6464
SetConsoleMode(handle_stdin, mode & (~ENABLE_ECHO_INPUT));
6565
#elif defined(HAVE_TERMIOS_H)
66-
termios orig_flags;
66+
termios orig_flags{};
6767
tcgetattr(STDIN_FILENO, &orig_flags);
6868
termios flags = orig_flags;
6969
flags.c_lflag &= ~static_cast<unsigned int>(ECHO);

src/util.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class integer_to_buffer
4040
char const *c_str() const noexcept { return m_buffer.data(); }
4141

4242
private:
43-
std::array<char, buffer_size> m_buffer;
43+
std::array<char, buffer_size> m_buffer{};
4444
};
4545

4646
class double_to_buffer
@@ -59,7 +59,7 @@ class double_to_buffer
5959
char const *c_str() const noexcept { return m_buffer.data(); }
6060

6161
private:
62-
std::array<char, buffer_size> m_buffer;
62+
std::array<char, buffer_size> m_buffer{};
6363
};
6464

6565
/**

tests/test-expire-tiles.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ struct tile_output_set
8383
void expire_centroids(expire_tiles &et)
8484
{
8585
for (auto const &t : tiles) {
86-
double x0, y0;
86+
double x0 = NAN;
87+
double y0 = NAN;
8788
t.to_centroid(x0, y0);
8889
et.from_bbox(x0, y0, x0, y0);
8990
}

tests/test-output-gazetteer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class node_opl_t
4343
return ret;
4444
}
4545

46-
char type() const noexcept { return 'N'; }
46+
static char type() noexcept { return 'N'; }
4747

4848
private:
4949
fmt::memory_buffer m_opl;
@@ -76,7 +76,7 @@ class way_opl_t
7676
return final_opl;
7777
}
7878

79-
char type() const noexcept { return 'W'; }
79+
static char type() noexcept { return 'W'; }
8080

8181
private:
8282
osmid_t make_nodes()
@@ -145,7 +145,7 @@ class relation_opl_t
145145
return final_opl;
146146
}
147147

148-
char type() const noexcept { return 'R'; }
148+
static char type() noexcept { return 'R'; }
149149

150150
private:
151151
osmid_t make_nodes()

0 commit comments

Comments
 (0)