From 62bb5ac77e33b0432fbbf7da820e94dfe0c530bc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 26 Jul 2025 13:53:47 +0100 Subject: Fix warnings in update.cpp --- gentoobrowse-api/util/update.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/gentoobrowse-api/util/update.cpp b/gentoobrowse-api/util/update.cpp index f00cd0b..7f67ada 100644 --- a/gentoobrowse-api/util/update.cpp +++ b/gentoobrowse-api/util/update.cpp @@ -9,17 +9,16 @@ #include #include #include -#include #include #include namespace po = boost::program_options; int -main(int c, char ** v) +main(int argc, char ** argv) { std::string endpoint; - bool background, tree, bugs, sendNotifications, pull; + bool background {}, tree {}, bugs {}, sendNotifications {}, pull {}; { po::options_description opts("Gentoo Browse Util::Update options"); opts.add_options()("endpoint", po::value(&endpoint)->default_value("tcp -p 9001"), "Service endpoint")( @@ -29,48 +28,48 @@ main(int c, char ** v) "pull", po::value(&pull)->default_value(true), "Perform a git pull on repositories")("notifications", po::value(&sendNotifications)->default_value(true), "Send notification emails")("help,h", "Show help"); - po::variables_map vm; - po::store(po::command_line_parser(c, v).options(opts).run(), vm); - po::notify(vm); + po::variables_map varmap; + po::store(po::command_line_parser(argc, argv).options(opts).run(), varmap); + po::notify(varmap); - if (vm.count("help")) { - std::cerr << opts << std::endl; - exit(1); + if (varmap.contains("help")) { + std::cerr << opts << '\n'; + exit(EXIT_FAILURE); } } - auto ic = Ice::initialize(c, v); - auto m = Ice::checkedCast(ic->stringToProxy("maintenance:" + endpoint)); - m->ice_ping(); + auto ice = Ice::initialize(argc, argv); + auto maintPrx = Ice::checkedCast(ice->stringToProxy("maintenance:" + endpoint)); + maintPrx->ice_ping(); std::vector> jobs; if (bugs) { - jobs.push_back(m->refreshBugsAsync()); + jobs.push_back(maintPrx->refreshBugsAsync()); } if (pull) { - m->updateRepositories(); + maintPrx->updateRepositories(); } if (tree) { - jobs.push_back(m->refreshPackageTreeAsync()); + jobs.push_back(maintPrx->refreshPackageTreeAsync()); } int failures = 0; if (!background) { - std::for_each(jobs.begin(), jobs.end(), [&failures](auto & f) { + std::ranges::for_each(jobs, [&failures](auto & future) { try { - f.get(); + future.get(); } catch (const std::exception & ex) { failures += 1; - std::cerr << ex.what() << std::endl; + std::cerr << ex.what() << '\n'; } }); if (sendNotifications) { - m->sendNotifications(); + maintPrx->sendNotifications(); } } jobs.clear(); - ic->destroy(); + ice->destroy(); return failures; } -- cgit v1.2.3