Skip to content

Commit

Permalink
Fix some clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Dec 17, 2024
1 parent 062a5a0 commit 113b5b2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/osmium/area/detail/basic_assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace osmium {
}
}

for (const osmium::Way* way : ways_in_multiple_rings) {
for (const osmium::Way* way : ways_in_multiple_rings) { // NOLINT(bugprone-nondeterministic-pointer-iteration-order)
++m_stats.ways_in_multiple_rings;
if (debug()) {
std::cerr << " Way " << way->id() << " is in multiple rings\n";
Expand Down
2 changes: 1 addition & 1 deletion include/osmium/experimental/flex_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace osmium {
}

void close() {
return m_reader.close();
m_reader.close();
}

bool eof() const {
Expand Down
2 changes: 1 addition & 1 deletion include/osmium/geom/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace osmium {
namespace detail {

template <typename T>
inline constexpr const T& clamp(const T& value, const T& min, const T& max) {
inline constexpr const T clamp(const T value, const T min, const T max) {
return value < min ? min : (max < value ? max : value);
}

Expand Down
2 changes: 1 addition & 1 deletion include/osmium/io/reader_with_progress_bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace osmium {
}

inline InputIterator<ReaderWithProgressBar> end(ReaderWithProgressBar& /*reader*/) {
return InputIterator<ReaderWithProgressBar>();
return {};
}

} // namespace io
Expand Down
4 changes: 4 additions & 0 deletions test/data-tests/testdata-multipolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct less_charptr {

using tagmap_type = std::map<const char*, const char*, less_charptr>;

namespace {

tagmap_type create_map(const osmium::TagList& taglist) {
tagmap_type map;

Expand All @@ -41,6 +43,8 @@ tagmap_type create_map(const osmium::TagList& taglist) {
return map;
}

} // anonymous namespace

class TestHandler : public osmium::handler::Handler {

gdalcpp::Layer m_layer_point;
Expand Down
18 changes: 11 additions & 7 deletions test/data-tests/testdata-xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
#include <iterator>
#include <string>

static std::string S_(const char* s) {
namespace {

std::string S_(const char* s) {
return std::string{s};
}

// From C++20 we need to handle unicode literals differently
#ifdef __cpp_char8_t
static std::string S_(const char8_t* s) {
std::string S_(const char8_t* s) {
return std::string{reinterpret_cast<const char*>(s)};
}
#endif

static std::string filename(const char* test_id, const char* suffix = "osm") {
std::string filename(const char* test_id, const char* suffix = "osm") {
const char* testdir = getenv("TESTDIR");
if (!testdir) {
throw std::runtime_error{"You have to set TESTDIR environment variable before running testdata-xml"};
Expand Down Expand Up @@ -56,7 +58,7 @@ struct header_buffer_type {
// operations, because they make certain assumptions, for instance that
// file contents fit into small buffers.

static std::string read_file(const char* test_id) {
std::string read_file(const char* test_id) {
const int fd = osmium::io::detail::open_for_reading(filename(test_id));
assert(fd >= 0);

Expand All @@ -70,7 +72,7 @@ static std::string read_file(const char* test_id) {
return input;
}

static std::string read_gz_file(const char* test_id, const char* suffix) {
std::string read_gz_file(const char* test_id, const char* suffix) {
const int fd = osmium::io::detail::open_for_reading(filename(test_id, suffix));
assert(fd >= 0);

Expand All @@ -81,7 +83,7 @@ static std::string read_gz_file(const char* test_id, const char* suffix) {
return input;
}

static header_buffer_type parse_xml(std::string input) {
header_buffer_type parse_xml(std::string input) {
osmium::thread::Pool pool;
osmium::io::detail::future_string_queue_type input_queue;
osmium::io::detail::future_buffer_queue_type output_queue;
Expand Down Expand Up @@ -123,7 +125,7 @@ static header_buffer_type parse_xml(std::string input) {
return result;
}

static header_buffer_type read_xml(const char* test_id) {
header_buffer_type read_xml(const char* test_id) {
const std::string input = read_file(test_id);
return parse_xml(input);
}
Expand All @@ -141,6 +143,8 @@ void test_fail(const char* xml_file_name, const char* errmsg) {
}(), TException);
}

} // anonymous namespace

// =============================================

TEST_CASE("Reading OSM XML 100: Direct") {
Expand Down
2 changes: 1 addition & 1 deletion test/t/geom/test_factory_with_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>

TEST_CASE("Projection using MercatorProjection class to WKT") {
osmium::geom::WKTFactory<osmium::geom::MercatorProjection> factory{2};
const osmium::geom::WKTFactory<osmium::geom::MercatorProjection> factory{2};

const std::string wkt{factory.create_point(osmium::Location{3.2, 4.2})};
REQUIRE(wkt == "POINT(356222.37 467961.14)");
Expand Down

0 comments on commit 113b5b2

Please sign in to comment.