Skip to content

Commit e3c92e3

Browse files
committed
Clean up warnings and error on warning
1 parent 384a14a commit e3c92e3

7 files changed

Lines changed: 28 additions & 20 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ endif()
6868

6969
add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_FILES})
7070

71+
target_compile_options(${PROJECT_NAME} PRIVATE
72+
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
73+
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Werror>
74+
)
75+
7176
target_link_libraries(${PROJECT_NAME} PRIVATE
7277
Boost::system
7378
yaml-cpp::yaml-cpp

src/account_manager.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ bool ff::username_is_stored(const limhamn::http::server::request& request) {
1010
}
1111

1212
bool ff::ensure_admin_account_exists(database& database) {
13-
for (auto& it : database.query("SELECT * FROM users WHERE user_type = ?;", static_cast<int>(UserType::Administrator))) {
13+
for (auto& it: database.query("SELECT * FROM users WHERE user_type = ?;", static_cast<int>(UserType::Administrator))) {
14+
static_cast<void>(it);
1415
return true;
1516
}
1617

@@ -203,10 +204,11 @@ std::pair<ff::LoginStatus, std::string> ff::try_login(database& database, const
203204
response.session["key"] = key;
204205

205206
response.cookies.push_back({"username", base_username, .path = "/",
207+
.http_only = true,
206208
#ifndef FF_DEBUG
207209
.secure = true,
208210
#endif
209-
.http_only = true, .same_site = "Strict"});
211+
.same_site = "Strict"});
210212

211213
limhamn::http::server::cookie c;
212214

@@ -219,10 +221,11 @@ std::pair<ff::LoginStatus, std::string> ff::try_login(database& database, const
219221

220222
response.cookies.push_back({"user_type", std::to_string(user_type),
221223
.path = "/",
224+
.http_only = true,
222225
#ifndef FF_DEBUG
223226
.secure = true,
224227
#endif
225-
.http_only = true, .same_site = "Strict"
228+
.same_site = "Strict"
226229
});
227230

228231
return {ff::LoginStatus::Success, key};

src/database.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <nlohmann/json.hpp>
44

55
// implement changes made to the database schema
6-
void ff::update_to_latest(database& database) {
6+
void ff::update_to_latest(database&) {
77
// none as of now
88
}
99

@@ -157,7 +157,7 @@ std::string ff::upload_file(database& db, const ff::FileConstruct& c) {
157157
json["path"] = dir;
158158
json["size"] = std::filesystem::file_size(dir);
159159

160-
if (std::filesystem::file_size(dir) <= ff::settings.max_file_size_hash) {
160+
if (file_size(dir) <= static_cast<uintmax_t>(settings.max_file_size_hash)) {
161161
json["sha256"] = scrypto::sha256hash_file(dir);
162162
}
163163

src/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ int main(int argc, char** argv) {
99

1010
limhamn::argument_manager::argument_manager arg{argc, argv};
1111

12-
arg.push_back("-h|--help|/h|/help|help", [](const limhamn::argument_manager::collection& c) {ff::print_help(); std::exit(EXIT_SUCCESS);});
13-
arg.push_back("-v|--version|/v|/version|version", [](const limhamn::argument_manager::collection& c) {ff::print_version(); std::exit(EXIT_SUCCESS);});
12+
arg.push_back("-h|--help|/h|/help|help", [](const limhamn::argument_manager::collection&) {ff::print_help(); std::exit(EXIT_SUCCESS);});
13+
arg.push_back("-v|--version|/v|/version|version", [](const limhamn::argument_manager::collection&) {ff::print_version(); std::exit(EXIT_SUCCESS);});
1414
arg.push_back("-c|--config-file|/c|/config-file", [&](limhamn::argument_manager::collection& c) {
1515
if (c.arguments.size() <= 1) {
1616
std::cerr << "The -c/--config flag requires a file to be specified.\n";
@@ -19,7 +19,7 @@ int main(int argc, char** argv) {
1919

2020
config_file = c.arguments.at(++c.index);
2121
});
22-
arg.push_back("-gc|--generate-config|/gc|/generate-config", [&](const limhamn::argument_manager::collection& c) {std::cout << ff::generate_default_config(); std::exit(EXIT_SUCCESS);});
22+
arg.push_back("-gc|--generate-config|/gc|/generate-config", [&](const limhamn::argument_manager::collection&) {std::cout << ff::generate_default_config(); std::exit(EXIT_SUCCESS);});
2323
arg.execute([](const std::string&) {});
2424

2525
ff::settings = ff::load_settings(config_file);
@@ -34,8 +34,8 @@ int main(int argc, char** argv) {
3434

3535
ff::settings.port = std::stoi(c.arguments.at(++c.index));
3636
});
37-
arg.push_back("-he|--halt-on-error|/he|/halt-on-error", [&](const limhamn::argument_manager::collection& c) {ff::settings.halt_on_error = true;});
38-
arg.push_back("-nhe|--no-halt-on-error|/nhe|/no-halt-on-error", [&](const limhamn::argument_manager::collection& c) {ff::settings.halt_on_error = false;});
37+
arg.push_back("-he|--halt-on-error|/he|/halt-on-error", [&](const limhamn::argument_manager::collection&) {ff::settings.halt_on_error = true;});
38+
arg.push_back("-nhe|--no-halt-on-error|/nhe|/no-halt-on-error", [&](const limhamn::argument_manager::collection&) {ff::settings.halt_on_error = false;});
3939
arg.push_back("-c|--config-file|/c|/config-file", [&](limhamn::argument_manager::collection& c) {
4040
++c.index;
4141
});

src/path_handlers.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <nlohmann/json.hpp>
66
#include <maddy/parser.h>
77

8-
limhamn::http::server::response ff::handle_root_endpoint(const limhamn::http::server::request& request, database& db) {
8+
limhamn::http::server::response ff::handle_root_endpoint(const limhamn::http::server::request&, database&) {
99
limhamn::http::server::response response{};
1010

1111
const auto prepare_file = [](const std::string& path) -> std::string {
@@ -273,7 +273,7 @@ limhamn::http::server::response ff::handle_try_setup_endpoint(const limhamn::htt
273273
}
274274
}
275275

276-
limhamn::http::server::response ff::handle_virtual_favicon_endpoint(const limhamn::http::server::request& request, database& db) {
276+
limhamn::http::server::response ff::handle_virtual_favicon_endpoint(const limhamn::http::server::request&, database&) {
277277
limhamn::http::server::response response{};
278278

279279
response.content_type = "image/svg+xml";
@@ -290,7 +290,7 @@ limhamn::http::server::response ff::handle_virtual_favicon_endpoint(const limham
290290
return response;
291291
}
292292

293-
limhamn::http::server::response ff::handle_virtual_stylesheet_endpoint(const limhamn::http::server::request& request, database& db) {
293+
limhamn::http::server::response ff::handle_virtual_stylesheet_endpoint(const limhamn::http::server::request&, database&) {
294294
limhamn::http::server::response response{};
295295

296296
response.content_type = "text/css";
@@ -307,7 +307,7 @@ limhamn::http::server::response ff::handle_virtual_stylesheet_endpoint(const lim
307307
return response;
308308
}
309309

310-
limhamn::http::server::response ff::handle_virtual_script_endpoint(const limhamn::http::server::request& request, database& db) {
310+
limhamn::http::server::response ff::handle_virtual_script_endpoint(const limhamn::http::server::request&, database&) {
311311
limhamn::http::server::response response;
312312

313313
response.content_type = "text/javascript";
@@ -1745,7 +1745,7 @@ limhamn::http::server::response ff::handle_api_create_announcement(const limhamn
17451745
return response;
17461746
}
17471747

1748-
limhamn::http::server::response ff::handle_api_get_announcements(const limhamn::http::server::request& request, database& db) {
1748+
limhamn::http::server::response ff::handle_api_get_announcements(const limhamn::http::server::request&, database& db) {
17491749
limhamn::http::server::response response{};
17501750

17511751
const auto query = db.query("SELECT * FROM general WHERE id=1;");
@@ -3315,7 +3315,7 @@ limhamn::http::server::response ff::handle_api_delete_forwarder_endpoint(const l
33153315
return response;
33163316
}
33173317

3318-
limhamn::http::server::response ff::handle_api_stay_logged_in(const limhamn::http::server::request& request, database& db) {
3318+
limhamn::http::server::response ff::handle_api_stay_logged_in(const limhamn::http::server::request& request, database&) {
33193319
limhamn::http::server::response response{};
33203320

33213321
if (request.session_id.empty()) {
@@ -3366,7 +3366,7 @@ limhamn::http::server::response ff::handle_api_stay_logged_in(const limhamn::htt
33663366
return response;
33673367
}
33683368

3369-
limhamn::http::server::response ff::handle_api_try_logout_endpoint(const limhamn::http::server::request& request, database& db) {
3369+
limhamn::http::server::response ff::handle_api_try_logout_endpoint(const limhamn::http::server::request&, database&) {
33703370
limhamn::http::server::response response{};
33713371

33723372
response.content_type = "application/json";
@@ -4801,7 +4801,7 @@ limhamn::http::server::response ff::handle_api_delete_comment_post(const limhamn
48014801
auto& comments = db_json["comments"];
48024802
bool found = false;
48034803
for (size_t i = 0; i < comments.size(); ++i) {
4804-
if (i == comment_id &&
4804+
if (i == static_cast<size_t>(comment_id) &&
48054805
((comments[i].contains("created_by") && comments[i].at("created_by").get<std::string>() == username)
48064806
|| get_user_type(db, username) == ff::UserType::Administrator)) {
48074807
found = true;

src/wadinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ff::WADInfo ff::get_info_from_wad(const std::string& wad_path) {
1212
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe.get()) != nullptr) {
1313
result += buffer.data();
1414
}
15-
return std::move(result);
15+
return result;
1616
};
1717

1818
const auto extract_value = [](const std::string& output, const std::string& name) -> std::string {

0 commit comments

Comments
 (0)