From: Martin Vidner Date: Tue, 17 Dec 2019 09:41:23 +0000 (+0100) Subject: Whitespace cleanup X-Git-Tag: v0.8.7^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d7779917a2e105ba15a261cb0a28f018db50d02;p=thirdparty%2Fsnapper.git Whitespace cleanup --- diff --git a/zypp-plugin/snapper_zypp_plugin.cc b/zypp-plugin/snapper_zypp_plugin.cc index b9bbb990..702ae68c 100644 --- a/zypp-plugin/snapper_zypp_plugin.cc +++ b/zypp-plugin/snapper_zypp_plugin.cc @@ -74,8 +74,8 @@ public: s = getenv("SNAPPER_ZYPP_PLUGIN_DBUS_SESSION"); if (s != nullptr) { - bus = DBUS_BUS_SESSION; - } + bus = DBUS_BUS_SESSION; + } } }; @@ -118,12 +118,12 @@ public: try { cerr << "INFO:" << "creating pre snapshot" << endl; pre_snapshot_num = command_create_pre_snapshot( - dbus_conn, snapper_cfg, - snapshot_description, cleanup_algorithm, userdata - ); + dbus_conn, snapper_cfg, + snapshot_description, cleanup_algorithm, userdata + ); cerr << "DEBUG:" << "created pre snapshot " << pre_snapshot_num << endl; } - catch (const DBus::ErrorException& ex) { + catch (const DBus::ErrorException& ex) { SN_CAUGHT(ex); cerr << "ERROR:" << error_description(ex) << endl; } @@ -156,9 +156,9 @@ public: modification_data.cleanup = cleanup_algorithm; modification_data.userdata = userdata; command_set_snapshot( - dbus_conn, snapper_cfg, - pre_snapshot_num, modification_data - ); + dbus_conn, snapper_cfg, + pre_snapshot_num, modification_data + ); } catch (const DBus::ErrorException& ex) { SN_CAUGHT(ex); @@ -170,9 +170,9 @@ public: try { cerr << "INFO:" << "creating post snapshot" << endl; unsigned int post_snapshot_num = command_create_post_snapshot( - dbus_conn, snapper_cfg, - pre_snapshot_num, "", cleanup_algorithm, userdata - ); + dbus_conn, snapper_cfg, + pre_snapshot_num, "", cleanup_algorithm, userdata + ); cerr << "DEBUG:" << "created post snapshot " << post_snapshot_num << endl; } catch (const DBus::ErrorException& ex) { @@ -233,7 +233,7 @@ map SnapperZyppPlugin::get_userdata(const Message& msg) { auto it = msg.headers.find("userdata"); if (it != msg.headers.end()) { const string& userdata_s = it->second; - vector key_values; + vector key_values; boost::split(key_values, userdata_s, boost::is_any_of(",")); for (auto kv: key_values) { static const snapper::Regex rx_keyval("^([^=]*)=(.+)$"); @@ -277,37 +277,37 @@ set SnapperZyppPlugin::get_solvables(const Message& msg, Phase phase) { // https://doc.opensuse.org/projects/libzypp/SLE12SP2/plugin-commit.html json_object * steps = object_get(zypp, "TransactionStepList"); if (!steps) - return result; + return result; if (json_object_get_type(steps) == json_type_array) { - size_t i, len = json_object_array_length(steps); - printf("steps: %zu\n", len); - for (i = 0; i < len; ++i) { - json_object * step = json_object_array_get_idx(steps, i); - bool have_type = json_object_object_get_ex(step, "type", NULL); - bool have_stage = json_object_object_get_ex(step, "stage", NULL); - if (have_type && (phase == Phase::BEFORE || have_stage)) { - json_object * solvable = object_get(step, "solvable"); - if (!solvable) { - cerr << "ERROR:" << "in item #" << i << endl; - continue; - } - json_object * name = object_get(solvable, "n"); - if (!name) { - cerr << "ERROR:" << "in item #" << i << endl; - continue; - } - if (json_object_get_type(name) != json_type_string) { - cerr << "ERROR:" << "\"n\" is not a string" << endl; - cerr << "ERROR:" << "in item #" << i << endl; - continue; - } - else { - const char * prize = json_object_get_string(name); + size_t i, len = json_object_array_length(steps); + printf("steps: %zu\n", len); + for (i = 0; i < len; ++i) { + json_object * step = json_object_array_get_idx(steps, i); + bool have_type = json_object_object_get_ex(step, "type", NULL); + bool have_stage = json_object_object_get_ex(step, "stage", NULL); + if (have_type && (phase == Phase::BEFORE || have_stage)) { + json_object * solvable = object_get(step, "solvable"); + if (!solvable) { + cerr << "ERROR:" << "in item #" << i << endl; + continue; + } + json_object * name = object_get(solvable, "n"); + if (!name) { + cerr << "ERROR:" << "in item #" << i << endl; + continue; + } + if (json_object_get_type(name) != json_type_string) { + cerr << "ERROR:" << "\"n\" is not a string" << endl; + cerr << "ERROR:" << "in item #" << i << endl; + continue; + } + else { + const char * prize = json_object_get_string(name); result.insert(prize); - } - } - } + } + } + } } return result; diff --git a/zypp-plugin/solvable_matcher.cc b/zypp-plugin/solvable_matcher.cc index 8bab2abc..fa77ef55 100644 --- a/zypp-plugin/solvable_matcher.cc +++ b/zypp-plugin/solvable_matcher.cc @@ -15,19 +15,19 @@ std::ostream& SolvableMatcher::log = std::cerr; bool SolvableMatcher::match(const string& solvable) const { log << "DEBUG:" - << "match? " << solvable - << " by " << ((kind == Kind::GLOB)? "GLOB '": "REGEX '") - << pattern << '\'' << endl; + << "match? " << solvable + << " by " << ((kind == Kind::GLOB)? "GLOB '": "REGEX '") + << pattern << '\'' << endl; bool res; if (kind == Kind::GLOB) { - static const int flags = 0; - res = fnmatch(pattern.c_str(), solvable.c_str(), flags) == 0; + static const int flags = 0; + res = fnmatch(pattern.c_str(), solvable.c_str(), flags) == 0; } else { - // POSIX Extended Regular Expression Syntax + // POSIX Extended Regular Expression Syntax // The original Python implementation allows "foo" to match "foo-devel" snapper::Regex rx_pattern("^" + pattern, REG_EXTENDED | REG_NOSUB); - res = rx_pattern.match(solvable); + res = rx_pattern.match(solvable); } log << "DEBUG:" << "-> " << res << endl; return res; @@ -42,27 +42,26 @@ vector SolvableMatcher::load_config(const string& cfg_filename) const xmlNode* solvables_n = getChildNode(root, "solvables"); const list solvables_l = getChildNodes(solvables_n, "solvable"); for (auto node: solvables_l) { - string pattern; - Kind kind; - bool important = false; + string pattern; + Kind kind; + bool important = false; - getAttributeValue(node, "important", important); - string kind_s; - getAttributeValue(node, "match", kind_s); - getValue(node, pattern); - if (kind_s == "w") { // w for wildcard - kind = Kind::GLOB; - } - else if (kind_s == "re") { // Regular Expression - kind = Kind::REGEX; - } - else { - log << "ERROR:" << "Unknown match attribute '" << kind_s << "', disregarding pattern '"<< pattern << "'" << endl; - continue; - } + getAttributeValue(node, "important", important); + string kind_s; + getAttributeValue(node, "match", kind_s); + getValue(node, pattern); + if (kind_s == "w") { // w for wildcard + kind = Kind::GLOB; + } + else if (kind_s == "re") { // Regular Expression + kind = Kind::REGEX; + } + else { + log << "ERROR:" << "Unknown match attribute '" << kind_s << "', disregarding pattern '"<< pattern << "'" << endl; + continue; + } - result.emplace_back(SolvableMatcher(pattern, kind, important)); + result.emplace_back(SolvableMatcher(pattern, kind, important)); } return result; } - diff --git a/zypp-plugin/zypp_plugin.h b/zypp-plugin/zypp_plugin.h index 7750e909..1cfa26b9 100644 --- a/zypp-plugin/zypp_plugin.h +++ b/zypp-plugin/zypp_plugin.h @@ -10,8 +10,8 @@ public: // https://doc.opensuse.org/projects/libzypp/SLE12SP2/zypp-plugins.html struct Message { std::string command; - std::map headers; - std::string body; + std::map headers; + std::string body; }; virtual int main();