From: Arvin Schnell Date: Mon, 4 Aug 2025 16:21:03 +0000 (+0200) Subject: - coding style X-Git-Tag: v0.13.0~13^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=478536be87ababe7ce000093569a64e628132212;p=thirdparty%2Fsnapper.git - coding style --- diff --git a/examples/c++-lib/ListAll.cc b/examples/c++-lib/ListAll.cc index c320c26e..8ee8fdad 100644 --- a/examples/c++-lib/ListAll.cc +++ b/examples/c++-lib/ListAll.cc @@ -10,11 +10,11 @@ using namespace std; int main(int argc, char** argv) { - list c = Snapper::getConfigs("/"); + list config_infos = Snapper::getConfigs("/"); list sh; - for (list::const_iterator it = c.begin(); it != c.end(); ++it) + for (list::const_iterator it = config_infos.begin(); it != config_infos.end(); ++it) sh.push_back(new Snapper(it->get_config_name(), "/")); for (list::const_iterator it = sh.begin(); it != sh.end(); ++it) diff --git a/server/Client.cc b/server/Client.cc index 749fc503..9b9ddb29 100644 --- a/server/Client.cc +++ b/server/Client.cc @@ -1796,43 +1796,43 @@ Client::debug(DBus::Connection& conn, DBus::Message& msg) } marshaller << "clients:"; - for (Clients::const_iterator it = clients.begin(); it != clients.end(); ++it) + for (const Client& client : clients) { std::ostringstream s; - s << " name:'" << it->name << "', uid:" << it->uid; - if (&*it == this) + s << " name:'" << client.name << "', uid:" << client.uid; + if (&client == this) s << ", myself"; - if (it->zombie) + if (client.zombie) s << ", zombie"; - if (!it->locks.empty()) - s << ", locks " << it->locks.size(); - if (!it->comparisons.empty()) - s << ", comparisons " << it->comparisons.size(); + if (!client.locks.empty()) + s << ", locks " << client.locks.size(); + if (!client.comparisons.empty()) + s << ", comparisons " << client.comparisons.size(); marshaller << s.str(); } marshaller << "backgrounds:"; - for (Backgrounds::const_iterator it = clients.backgrounds().begin(); it != clients.backgrounds().end(); ++it) + for (const Backgrounds::Task& task : clients.backgrounds()) { std::ostringstream s; - s << " name:'" << it->meta_snapper->configName() << "'"; + s << " name:'" << task.meta_snapper->configName() << "'"; marshaller << s.str(); } marshaller << "meta-snappers:"; - for (MetaSnappers::const_iterator it = meta_snappers.begin(); it != meta_snappers.end(); ++it) + for (const MetaSnapper& meta_snapper : meta_snappers) { std::ostringstream s; - s << " name:'" << it->configName() << "'"; - if (it->is_loaded()) + s << " name:'" << meta_snapper.configName() << "'"; + if (meta_snapper.is_loaded()) { s << ", loaded"; - if (it->is_locked(clients)) + if (meta_snapper.is_locked(clients)) s << ", locked"; - if (it->use_count() == 0) - s << ", unused for " << duration_cast(it->unused_for()).count() << "ms"; + if (meta_snapper.use_count() == 0) + s << ", unused for " << duration_cast(meta_snapper.unused_for()).count() << "ms"; else - s << ", use count " << it->use_count(); + s << ", use count " << meta_snapper.use_count(); } marshaller << s.str(); } diff --git a/server/Types.cc b/server/Types.cc index db72afcf..802c1577 100644 --- a/server/Types.cc +++ b/server/Types.cc @@ -78,8 +78,8 @@ namespace DBus operator<<(Marshaller& marshaller, const Snapshots& data) { marshaller.open_array(TypeInfo::signature); - for (Snapshots::const_iterator it = data.begin(); it != data.end(); ++it) - marshaller << *it; + for (const Snapshot& snapshot : data) + marshaller << snapshot; marshaller.close_array(); return marshaller; } @@ -119,8 +119,8 @@ namespace DBus operator<<(Marshaller& marshaller, const Files& data) { marshaller.open_array(TypeInfo::signature); - for (Files::const_iterator it = data.begin(); it != data.end(); ++it) - marshaller << *it; + for (const File& file : data) + marshaller << file; marshaller.close_array(); return marshaller; } diff --git a/snapper/Snapper.cc b/snapper/Snapper.cc index 61b974cb..706afbc2 100644 --- a/snapper/Snapper.cc +++ b/snapper/Snapper.cc @@ -112,11 +112,11 @@ namespace snapper { y2mil("Snapper destructor '" << config_name << "'"); - for (Snapshots::iterator it = snapshots.begin(); it != snapshots.end(); ++it) + for (const Snapshot& snapshot : snapshots) { try { - it->handleUmountFilesystemSnapshot(); + snapshot.handleUmountFilesystemSnapshot(); } catch (const UmountSnapshotFailedException& e) { @@ -317,10 +317,10 @@ namespace snapper SN_THROW(CreateConfigFailedException("illegal subvolume")); } - list configs = getConfigs(root_prefix); - for (list::const_iterator it = configs.begin(); it != configs.end(); ++it) + list config_infos = getConfigs(root_prefix); + for (const ConfigInfo& config_info : config_infos) { - if (it->get_subvolume() == subvolume) + if (config_info.get_subvolume() == subvolume) { SN_THROW(CreateConfigFailedException("subvolume already covered")); }