]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- coding style 777/head
authorArvin Schnell <aschnell@suse.de>
Thu, 26 Jan 2023 12:48:56 +0000 (13:48 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 26 Jan 2023 12:48:56 +0000 (13:48 +0100)
zypp-plugin/forwarding-zypp-plugin.cc
zypp-plugin/snapper-zypp-plugin.cc
zypp-plugin/testsuite/Makefile.am

index bfba0c0488dd1556b548c11a0d881b8b92e8dd3d..8ae007f3108b7209c9e65d153cd1f16a6c41f1a6 100644 (file)
@@ -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);
 }
 
 
index 6fab74b04d1c3092a7f5f8167b736899423cb0da..aee4b80faf6b610fbc1d326ca6e8f04a452047e5 100644 (file)
@@ -52,15 +52,12 @@ using namespace snapper;
 ostream&
 operator<<(ostream& os, const set<string>& ss)
 {
-    bool seen_first = false;
     os << '{';
-    for (auto s : ss)
+    for (typename set<string>::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<string, string>
 SnapperZyppCommitPlugin::get_userdata(const Message& msg)
 {
     map<string, string> result;
+
     auto it = msg.headers.find("userdata");
     if (it != msg.headers.end())
     {
        const string& userdata_s = it->second;
        vector<string> 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<string>& solvables, bool& found, bool& important) const
 {
-    found = false;
-    important = false;
+    found = important = false;
 
     for (const string& solvable : solvables)
     {
index 7b52e132a511f54a9ae9363fc051eec98a4afd00..a7be31363cc107395d6b3ca4b8e8ecce5c6d63a0 100644 (file)
@@ -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