From: Arvin Schnell Date: Thu, 26 Jan 2023 12:48:56 +0000 (+0100) Subject: - coding style X-Git-Tag: v0.10.5~60^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=fd61a5e07921278acada97f3ef2e072fdd122006;p=thirdparty%2Fsnapper.git - coding style --- diff --git a/zypp-plugin/forwarding-zypp-plugin.cc b/zypp-plugin/forwarding-zypp-plugin.cc index bfba0c04..8ae007f3 100644 --- a/zypp-plugin/forwarding-zypp-plugin.cc +++ b/zypp-plugin/forwarding-zypp-plugin.cc @@ -77,8 +77,7 @@ ZyppPlugin::Message ForwardingZyppPlugin::dispatch(const Message& msg) { write_message(childs_in, msg); - Message reply = read_message(childs_out); - return reply; + return read_message(childs_out); } diff --git a/zypp-plugin/snapper-zypp-plugin.cc b/zypp-plugin/snapper-zypp-plugin.cc index 6fab74b0..aee4b80f 100644 --- a/zypp-plugin/snapper-zypp-plugin.cc +++ b/zypp-plugin/snapper-zypp-plugin.cc @@ -52,15 +52,12 @@ using namespace snapper; ostream& operator<<(ostream& os, const set& ss) { - bool seen_first = false; os << '{'; - for (auto s : ss) + for (typename set::const_iterator it = ss.begin(); it != ss.end(); ++it) { - if (seen_first) + if (it != ss.begin()) os << ", "; - - os << s; - seen_first = true; + os << *it; } os << '}'; return os; @@ -232,6 +229,7 @@ SnapperZyppCommitPlugin::commit_end(const Message& msg) } } } + return ack(); } @@ -239,17 +237,21 @@ SnapperZyppCommitPlugin::commit_end(const Message& msg) const string SnapperZyppCommitPlugin::cleanup_algorithm = "number"; +// The user can provide userdata e.g. using zypper ('zypper --userdata foo=bar install +// barrel'). + map SnapperZyppCommitPlugin::get_userdata(const Message& msg) { map result; + auto it = msg.headers.find("userdata"); if (it != msg.headers.end()) { const string& userdata_s = it->second; vector key_values; boost::split(key_values, userdata_s, boost::is_any_of(",")); - for (auto kv : key_values) + for (const string& kv : key_values) { static const regex rx_keyval("([^=]*)=(.+)", regex::extended); smatch match; @@ -266,6 +268,7 @@ SnapperZyppCommitPlugin::get_userdata(const Message& msg) } } } + return result; } @@ -273,7 +276,7 @@ SnapperZyppCommitPlugin::get_userdata(const Message& msg) static json_object* object_get(json_object* obj, const char* name) { - json_object * result; + json_object* result; if (!json_object_object_get_ex(obj, name, &result)) { y2err('"' << name << "\" not found"); @@ -361,7 +364,7 @@ SnapperZyppCommitPlugin::get_solvables(const Message& msg, Phase phase) const } else { - const char * prize = json_object_get_string(name); + const char* prize = json_object_get_string(name); result.insert(prize); } } @@ -375,8 +378,7 @@ SnapperZyppCommitPlugin::get_solvables(const Message& msg, Phase phase) const void SnapperZyppCommitPlugin::match_solvables(const set& solvables, bool& found, bool& important) const { - found = false; - important = false; + found = important = false; for (const string& solvable : solvables) { diff --git a/zypp-plugin/testsuite/Makefile.am b/zypp-plugin/testsuite/Makefile.am index 7b52e132..a7be3136 100644 --- a/zypp-plugin/testsuite/Makefile.am +++ b/zypp-plugin/testsuite/Makefile.am @@ -1,4 +1,5 @@ if HAVE_ZYPP + TEST_LOG_DRIVER = $(SHELL) tap-driver.sh check_SCRIPTS = 1-happy.test 2-malformed-xml.test 3-invalid-xml.test 4-badjson.test 99-shell.test @@ -11,4 +12,5 @@ noinst_DATA = \ TESTS = $(check_SCRIPTS) EXTRA_DIST = $(check_SCRIPTS) $(noinst_SCRIPTS) $(noinst_DATA) tap-driver.sh + endif