Cppcheck: add some consts

master
Tomasz Golinski 2022-09-01 17:23:29 +02:00
rodzic 6cbd0e6efa
commit fdce7bc17c
4 zmienionych plików z 11 dodań i 11 usunięć

Wyświetl plik

@ -89,7 +89,7 @@ int main(int argc, char** argv) {
std::cout << "</tr>\n";
short int n = 1;
for (auto& i : cc) {
for (const auto& i : cc) {
std::cout << "<tr><th>" << n << "</th> ";
std::cout << "<td>" << i.link_name() << "</td>";
std::cout << "<td>" << i.type << "</td>";

Wyświetl plik

@ -458,7 +458,7 @@ int main(int argc, char** argv) {
std::cout << "Number of caches that are now archived: <span class=\"value\">" << std::count_if(cc.begin(), cc.end(), [&](const auto& a) { return a.status == archived; }) << "</span><br>\n";
std::cout << "<details class=\"days\"><summary>Best caching day: <span class=\"value\">" << best_day->first << "</span>, found <span class=\"value\">" << best_day->second << "</span> caches</summary>\n";
std::cout << " <p>\n";
for (auto& i : dates)
for (const auto& i : dates)
std::cout << i.first << ", found " << i.second << " caches<br>\n";
std::cout << " </p>\n</details>\n";

Wyświetl plik

@ -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);

Wyświetl plik

@ -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;