From fdce7bc17c9451cc3ff2b13ca854a38f44431cfd Mon Sep 17 00:00:00 2001 From: Tomasz Golinski Date: Thu, 1 Sep 2022 17:23:29 +0200 Subject: [PATCH] Cppcheck: add some consts --- geolist.cpp | 2 +- geostat.cpp | 2 +- ocdb.cpp | 16 ++++++++-------- okapi.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/geolist.cpp b/geolist.cpp index 968f1d4..8630b54 100644 --- a/geolist.cpp +++ b/geolist.cpp @@ -89,7 +89,7 @@ int main(int argc, char** argv) { std::cout << "\n"; short int n = 1; - for (auto& i : cc) { + for (const auto& i : cc) { std::cout << "" << n << " "; std::cout << "" << i.link_name() << ""; std::cout << "" << i.type << ""; diff --git a/geostat.cpp b/geostat.cpp index adbf678..92c8ee2 100644 --- a/geostat.cpp +++ b/geostat.cpp @@ -458,7 +458,7 @@ int main(int argc, char** argv) { std::cout << "Number of caches that are now archived: " << std::count_if(cc.begin(), cc.end(), [&](const auto& a) { return a.status == archived; }) << "
\n"; std::cout << "
Best caching day: " << best_day->first << ", found " << best_day->second << " caches\n"; std::cout << "

\n"; - for (auto& i : dates) + for (const auto& i : dates) std::cout << i.first << ", found " << i.second << " caches
\n"; std::cout << "

\n
\n"; diff --git a/ocdb.cpp b/ocdb.cpp index 1b496f3..2d8d0d3 100644 --- a/ocdb.cpp +++ b/ocdb.cpp @@ -190,21 +190,21 @@ bool OCdb::update_cache(const json& j) { return 1; sql = "INSERT INTO caches (code,"; - for (auto& i : fields) + for (const auto& i : fields) sql += i.first + ','; - for (auto& i : fields2) + for (const auto& i : fields2) sql += i.first + ','; sql.pop_back(); sql += ") VALUES ('" + code + "',"; - for (__attribute__((unused)) auto& i : fields) + for (__attribute__((unused)) const auto& i : fields) sql += "?,"; - for (__attribute__((unused)) auto& i : fields2) + for (__attribute__((unused)) const auto& i : fields2) sql += "?,"; sql.pop_back(); sql += ") ON CONFLICT(code) DO UPDATE SET "; - for (auto& i : fields) + for (const auto& i : fields) sql += i.first + "=excluded." + i.first + ','; - for (auto& i : fields2) + for (const auto& i : fields2) sql += i.first + "=excluded." + i.first + ','; sql.pop_back(); sql += ';'; @@ -216,10 +216,10 @@ bool OCdb::update_cache(const json& j) { return 0; } int n = 1; - for (auto& i : fields) { + for (const auto& i : fields) { sqlite3_bind_text(stmt, n++, i.second.c_str(), -1, nullptr); } - for (auto& i : fields2) { + for (const auto& i : fields2) { sqlite3_bind_int(stmt, n++, i.second); } res = sqlite3_step(stmt); diff --git a/okapi.cpp b/okapi.cpp index c83f2e0..a688584 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -248,7 +248,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const { mcc.insert({ i.code, i }); // introduce extra data from the logs to Caches - for (auto& el : tmp_data) { + for (const auto& el : tmp_data) { auto& it = mcc.at(el.first); it.set_date(el.second.date); it.recommended = el.second.was_recommended;