Skip to content

Commit 93c3583

Browse files
authored
Merge pull request #2024 from joto/various-code-cleanups
Fix various small issues found by clang-tidy
2 parents 78547ae + b17b14d commit 93c3583

File tree

8 files changed

+18
-17
lines changed

8 files changed

+18
-17
lines changed

src/expire-output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ std::size_t expire_output_t::output_tiles_to_file(
3434
{
3535
FILE *outfile = std::fopen(m_filename.data(), "a");
3636
if (outfile == nullptr) {
37-
std::system_error error{errno, std::generic_category()};
37+
std::system_error const error{errno, std::generic_category()};
3838
log_warn("Failed to open expired tiles file ({}). Tile expiry "
3939
"list will not be written!",
4040
error.code().message());

src/middle-pgsql.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* emit the final geometry-enabled output formats
1616
*/
1717

18+
#include <array>
1819
#include <cassert>
1920
#include <cstdint>
2021
#include <cstdlib>
@@ -120,6 +121,7 @@ static std::vector<std::string>
120121
build_sql(options_t const &options, std::vector<std::string> const &templs)
121122
{
122123
std::vector<std::string> out;
124+
out.reserve(templs.size());
123125

124126
for (auto const &templ : templs) {
125127
out.push_back(build_sql(options, templ));
@@ -1071,10 +1073,10 @@ void middle_pgsql_t::way_delete(osmid_t osm_id)
10711073
void middle_pgsql_t::relation_set_format1(osmium::Relation const &rel)
10721074
{
10731075
// Sort relation members by their type.
1074-
idlist_t parts[3];
1076+
std::array<idlist_t, 3> parts;
10751077

10761078
for (auto const &m : rel.members()) {
1077-
parts[osmium::item_type_to_nwr_index(m.type())].push_back(m.ref());
1079+
parts.at(osmium::item_type_to_nwr_index(m.type())).push_back(m.ref());
10781080
}
10791081

10801082
m_db_copy.new_line(m_tables.relations().copy_target());

src/options.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct options_t
136136

137137
int cache = 800; ///< Memory usable for cache in MB
138138

139-
unsigned int num_procs;
139+
unsigned int num_procs = 1;
140140

141141
/**
142142
* How many bits should the node id be shifted for the way node index?

src/osm2pgsql.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ static file_info run(options_t const &options)
7272

7373
// Processing: In this phase the input file(s) are read and parsed,
7474
// populating some of the tables.
75-
auto const finfo = process_files(files, &osmdata, options.append,
76-
get_logger().show_progress());
75+
auto finfo = process_files(files, &osmdata, options.append,
76+
get_logger().show_progress());
7777

7878
show_memory_usage();
7979

src/properties.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
static constexpr char const *const properties_table = "osm2pgsql_properties";
1919

20-
properties_t::properties_t(std::string const &conninfo,
21-
std::string const &schema)
22-
: m_conninfo(conninfo), m_schema(schema),
20+
properties_t::properties_t(std::string conninfo, std::string schema)
21+
: m_conninfo(std::move(conninfo)), m_schema(std::move(schema)),
2322
m_has_properties_table(
24-
has_table(schema.empty() ? "public" : schema, properties_table))
23+
has_table(m_schema.empty() ? "public" : m_schema, properties_table))
2524
{
2625
log_debug("Found properties table '{}': {}.", properties_table,
2726
m_has_properties_table);

src/properties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class properties_t
3535
*
3636
* \pre You must have called init_database_capabilities() before this.
3737
*/
38-
properties_t(std::string const &conninfo, std::string const &schema);
38+
properties_t(std::string conninfo, std::string schema);
3939

4040
std::string get_string(std::string const &property,
4141
std::string const &default_value) const;

tests/test-properties.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ TEST_CASE("Store and retrieve properties (memory only)")
2626

2727
REQUIRE(properties.get_string("foo", "baz") == "bar");
2828
REQUIRE(properties.get_string("something", "baz") == "baz");
29-
REQUIRE(properties.get_string("empty", "baz") == "");
29+
REQUIRE(properties.get_string("empty", "baz").empty());
3030
REQUIRE_THROWS(properties.get_int("foo", 1));
3131
REQUIRE_THROWS(properties.get_bool("foo", true));
3232

@@ -45,7 +45,7 @@ TEST_CASE("Store and retrieve properties (memory only)")
4545
TEST_CASE("Store and retrieve properties (with database)")
4646
{
4747
for (std::string const schema : {"", "middleschema"}) {
48-
testing::pg::tempdb_t db;
48+
testing::pg::tempdb_t const db;
4949
auto conn = db.connect();
5050
if (!schema.empty()) {
5151
conn.exec("CREATE SCHEMA IF NOT EXISTS {};", schema);
@@ -82,7 +82,7 @@ TEST_CASE("Store and retrieve properties (with database)")
8282

8383
REQUIRE(properties.get_string("foo", "baz") == "bar");
8484
REQUIRE(properties.get_string("something", "baz") == "baz");
85-
REQUIRE(properties.get_string("empty", "baz") == "");
85+
REQUIRE(properties.get_string("empty", "baz").empty());
8686
REQUIRE_THROWS(properties.get_int("foo", 1));
8787
REQUIRE_THROWS(properties.get_bool("foo", true));
8888

@@ -102,7 +102,7 @@ TEST_CASE("Store and retrieve properties (with database)")
102102

103103
TEST_CASE("Update existing properties in database")
104104
{
105-
testing::pg::tempdb_t db;
105+
testing::pg::tempdb_t const db;
106106
auto conn = db.connect();
107107

108108
{
@@ -146,7 +146,7 @@ TEST_CASE("Update existing properties in database")
146146

147147
TEST_CASE("Load returns false if there are no properties in database")
148148
{
149-
testing::pg::tempdb_t db;
149+
testing::pg::tempdb_t const db;
150150
auto conn = db.connect();
151151
init_database_capabilities(conn);
152152

tests/test-util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ TEST_CASE("find_by_name()", "[NoDB]")
6565
t.emplace_back("baz");
6666

6767
REQUIRE(util::find_by_name(t, "") == nullptr);
68-
REQUIRE(util::find_by_name(t, "foo") == &t[0]);
68+
REQUIRE(util::find_by_name(t, "foo") == t.data());
6969
REQUIRE(util::find_by_name(t, "bar") == &t[1]);
7070
REQUIRE(util::find_by_name(t, "baz") == &t[2]);
7171
REQUIRE(util::find_by_name(t, "nothing") == nullptr);

0 commit comments

Comments
 (0)