Skip to content

Commit b6938c7

Browse files
committed
Fix some misc code smells reported by clang-tidy
1 parent 7766666 commit b6938c7

8 files changed

Lines changed: 19 additions & 22 deletions

File tree

src/geom-boost-adaptor.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ BOOST_GEOMETRY_REGISTER_MULTI_POINT(geom::multipoint_t)
2929
BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(geom::multilinestring_t)
3030
BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(geom::multipolygon_t)
3131

32-
namespace boost {
33-
namespace geometry {
34-
namespace traits {
32+
namespace boost::geometry::traits {
3533
template <>
3634
struct point_order<::geom::ring_t>
3735
{
@@ -79,8 +77,6 @@ struct interior_rings<::geom::polygon_t>
7977
static auto get(::geom::polygon_t &p) { return p.inners(); }
8078
static auto get(::geom::polygon_t const &p) { return p.inners(); }
8179
};
82-
} // namespace traits
83-
} // namespace geometry
84-
} // namespace boost
80+
} // namespace boost::geometry::traits
8581

8682
#endif // OSM2PGSQL_GEOM_BOOST_ADAPTOR_HPP

src/geom.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ class multigeometry_t
194194
[[nodiscard]] GEOM &add_geometry() { return m_geometry.emplace_back(); }
195195

196196
[[nodiscard]] friend bool operator==(multigeometry_t const &a,
197-
multigeometry_t const &b) noexcept
197+
multigeometry_t const &b)
198198
{
199199
return a.m_geometry == b.m_geometry;
200200
}
201201

202202
[[nodiscard]] friend bool operator!=(multigeometry_t const &a,
203-
multigeometry_t const &b) noexcept
203+
multigeometry_t const &b)
204204
{
205205
return a.m_geometry != b.m_geometry;
206206
}
@@ -355,13 +355,13 @@ class geometry_t
355355
}
356356

357357
[[nodiscard]] friend bool operator==(geometry_t const &a,
358-
geometry_t const &b) noexcept
358+
geometry_t const &b)
359359
{
360360
return (a.srid() == b.srid()) && (a.m_geom == b.m_geom);
361361
}
362362

363363
[[nodiscard]] friend bool operator!=(geometry_t const &a,
364-
geometry_t const &b) noexcept
364+
geometry_t const &b)
365365
{
366366
return !(a == b);
367367
}

src/options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
454454
++next_char;
455455
// Second number must not be negative because zoom levels must be positive.
456456
if (next_char && *next_char != '-' && isdigit(*next_char)) {
457-
char *after_maxzoom;
457+
char *after_maxzoom = nullptr;
458458
expire_tiles_zoom = static_cast<uint32_t>(
459459
std::strtoul(next_char, &after_maxzoom, 10));
460460
if (expire_tiles_zoom == 0 || *after_maxzoom != '\0') {

src/output-flex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ int output_flex_t::app_define_table()
11991199
setup_id_columns(&new_table);
12001200
setup_flex_table_columns(&new_table);
12011201

1202+
// NOLINTNEXTLINE(performance-no-int-to-ptr)
12021203
lua_pushlightuserdata(lua_state(), (void *)(m_tables->size()));
12031204
luaL_getmetatable(lua_state(), osm2pgsql_table_name);
12041205
lua_setmetatable(lua_state(), -2);

src/output.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
#ifdef HAVE_LUA
1818
# include "output-flex.hpp"
19-
# define flex_backend "flex, "
19+
static constexpr char const *const flex_backend = "flex, ";
2020
#else
21-
# define flex_backend ""
21+
static constexpr char const *const flex_backend = "";
2222
#endif
2323

2424
#include <stdexcept>
@@ -57,8 +57,8 @@ output_t::create_output(std::shared_ptr<middle_query_t> const &mid,
5757

5858
throw std::runtime_error{
5959
"Output backend '{}' not recognised. Should be one "
60-
"of [pgsql, " flex_backend
61-
"gazetteer, null]."_format(options.output_backend)};
60+
"of [pgsql, {}gazetteer, null]."_format(options.output_backend,
61+
flex_backend)};
6262
}
6363

6464
output_t::output_t(std::shared_ptr<middle_query_t> mid,

src/pgsql.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class pg_result_t
3838
{
3939
public:
40-
pg_result_t() {}
40+
pg_result_t() = default;
4141

4242
explicit pg_result_t(PGresult *result) noexcept : m_result(result) {}
4343

@@ -100,7 +100,7 @@ class pg_result_t
100100
}
101101

102102
/// Return true if this holds an actual result.
103-
operator bool() { return m_result.get(); }
103+
explicit operator bool() { return m_result.get(); }
104104

105105
private:
106106
struct pg_result_deleter_t

src/tagtransform-c.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace {
2020

21-
static const struct
21+
const struct
2222
{
2323
char const *highway;
2424
int offset;
@@ -40,7 +40,9 @@ static const struct
4040
{"primary", 37, true}, {"trunk", 38, true},
4141
{"motorway", 39, true}};
4242

43-
void add_z_order(taglist_t *tags, bool *roads)
43+
} // anonymous namespace
44+
45+
static void add_z_order(taglist_t *tags, bool *roads)
4446
{
4547
std::string const *const layer = tags->get("layer");
4648
std::string const *const highway = tags->get("highway");
@@ -86,8 +88,6 @@ void add_z_order(taglist_t *tags, bool *roads)
8688
tags->add_tag("z_order", z.c_str());
8789
}
8890

89-
} // anonymous namespace
90-
9191
c_tagtransform_t::c_tagtransform_t(options_t const *options, export_list exlist)
9292
: m_options(options), m_export_list(std::move(exlist))
9393
{}

tests/test-options-parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static options_t opt(std::vector<char const *> opts)
2929
{
3030
opts.insert(opts.begin(), "osm2pgsql");
3131
opts.push_back(TEST_PBF);
32-
return options_t((int)opts.size(), (char **)opts.data());
32+
return {(int)opts.size(), (char **)opts.data()};
3333
}
3434

3535
TEST_CASE("Insufficient arguments", "[NoDB]")

0 commit comments

Comments
 (0)