From: Mateusz Moscicki Date: Thu, 7 Mar 2019 08:17:29 +0000 (+0100) Subject: refactoring: remove unused parameters and "using namespace std" X-Git-Tag: accepted/tizen/unified/20190322.075526~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F30%2F201030%2F2;p=platform%2Fcore%2Fsystem%2Flibdbuspolicy.git refactoring: remove unused parameters and "using namespace std" Change-Id: I886c7dfd075fce52bfa5a8d1e7bf6d9aeb301ec9 --- diff --git a/src/internal/serializer.cpp b/src/internal/serializer.cpp index 1815d29..b75ecf3 100644 --- a/src/internal/serializer.cpp +++ b/src/internal/serializer.cpp @@ -8,25 +8,23 @@ #include "include/flatbuffers/flatbuffers.h" #include "include/fb_generated.h" -using namespace std; - namespace ldp_xml_parser { -map decisions_map { +std::map decisions_map { { Decision::ANY, FB::Decision_ANY }, { Decision::DENY, FB::Decision_DENY }, { Decision::ALLOW, FB::Decision_ALLOW }, { Decision::CHECK, FB::Decision_CHECK } }; -map bus_access_map { +std::map bus_access_map { { BusAccessType::USER, FB::BusAccessType_USER }, { BusAccessType::GROUP, FB::BusAccessType_GROUP }, { BusAccessType::ALL_USERS, FB::BusAccessType_ALL_USERS }, { BusAccessType::ALL_GROUPS, FB::BusAccessType_ALL_GROUPS }, }; -map message_type_map { +std::map message_type_map { { MessageType::ANY, FB::MessageType_ANY }, { MessageType::METHOD_CALL, FB::MessageType_METHOD_CALL }, { MessageType::METHOD_RETURN, FB::MessageType_METHOD_RETURN }, @@ -109,14 +107,14 @@ uint8_t* Serializer::serialize(const std::string config_path, size_t &size) { ldp_xml::StorageBackendXML xmlStorage; if (!xmlStorage.init(config_path.c_str())) { - cout << "internal_init error" << endl; + std::cout << "internal_init error" << std::endl; return nullptr; } return serialize(xmlStorage, size); } -void Serializer::serialize(const std::string config_path, ostream &output) { +void Serializer::serialize(const std::string config_path, std::ostream &output) { size_t size; uint8_t *buf = serialize(config_path, size); @@ -150,7 +148,7 @@ FbOff Serializer::serialize_tree(const OwnershipTree &tree) { return policy; } -FbOff Serializer::serialize_tree(const shared_ptr &node) { +FbOff Serializer::serialize_tree(const std::shared_ptr &node) { auto prefix_decision_item = serialize_decision(node->getOwnPrefixDecisionItem()); auto decision_item = serialize_decision(node->getOwnDecisionItem()); @@ -200,25 +198,13 @@ auto Serializer::serialize_item(const P &item) -> FbOff: } template -auto Serializer::serialize_policy(const T &policy, - const std::vector::item>> items) +auto Serializer::serialize_policy(const std::vector::item>> items) -> FbOff::policy> { - (void)policy; auto create_policy = get_create_policy(); return create_policy(m_builder, m_builder.CreateVector(items)); } template <> -auto Serializer::serialize_policy(const PolicyAccess &policy, - const std::vector> items) - -> FbOff { - (void)policy; - auto create_policy = get_create_policy(); - return create_policy(m_builder, - m_builder.CreateVector(items)); -} - -template <> auto Serializer::serialize_policy(const PolicyOwn &policy) -> FbOff { return serialize_tree(policy.getTree()); @@ -232,7 +218,7 @@ auto Serializer::serialize_policy(const T &policy) -> FbOff(item)); } - return serialize_policy(policy, items); + return serialize_policy(items); } template diff --git a/src/internal/serializer.hpp b/src/internal/serializer.hpp index f8a35c6..57f13b7 100644 --- a/src/internal/serializer.hpp +++ b/src/internal/serializer.hpp @@ -11,8 +11,6 @@ #include "storage_backend_xml.hpp" #include "policy_containers.hpp" -using namespace std; - namespace ldp_xml_parser { enum class SetType : uint8_t { @@ -43,7 +41,7 @@ namespace ldp_xml_parser auto get_create_item() -> decltype(type_helper::create_item); FbOff serialize_tree(const OwnershipTree &tree); - FbOff serialize_tree(const shared_ptr &node); + FbOff serialize_tree(const std::shared_ptr &node); FbOff serialize_decision(const DecisionItem &item); template @@ -53,8 +51,7 @@ namespace ldp_xml_parser auto serialize_policy(const T &policy) -> FbOff::policy>; template - auto serialize_policy(const T &policy, - const std::vector::item>> items) + auto serialize_policy(const std::vector::item>> items) -> FbOff::policy>; template @@ -71,7 +68,7 @@ namespace ldp_xml_parser public: uint8_t *serialize(const ldp_xml::StorageBackendXML &db, size_t &size); uint8_t *serialize(const std::string config_path, size_t &size); - void serialize(const std::string config_path, ostream &output); + void serialize(const std::string config_path, std::ostream &output); friend class SerializerTests; }; } diff --git a/src/stest_load_perf.cpp b/src/stest_load_perf.cpp index 70208ca..2794a15 100644 --- a/src/stest_load_perf.cpp +++ b/src/stest_load_perf.cpp @@ -59,29 +59,29 @@ bool run_fb(const char *conf_file) { void run_tests(const char *conf_file, const char *conf_bin, size_t c, Choice ch) { if (ch == Choice::ALL || ch == Choice::XML) { if (!measure([&conf_file, c]() { return run_xml(conf_file); }, c, "XML")) { - cout << "ERROR" << endl; + std::cout << "ERROR" << std::endl; } } if (ch == Choice::ALL || ch == Choice::FB) { if (!measure([&conf_bin, c]() { return run_fb(conf_bin); }, c, "FB")) { - cout << "ERROR" << endl; + std::cout << "ERROR" << std::endl; } } if (ch == Choice::ALL || ch == Choice::XMLplusFB) if (!measure([&conf_file, c]() { return run_xml_plus_fb(conf_file); }, c, "FB after XML")) { - cout << "ERROR" << endl; + std::cout << "ERROR" << std::endl; } } void print_help(const char *name) { - cout << endl; - cout << "usage: " << name << " {-f |-x|-d|-a } {--system|--session|-c } " << endl; - cout << endl; - cout << " -f - Flatbuffers" << endl; - cout << " -x - XML" << endl; - cout << " -d - FB after XML" << endl; - cout << " -a - All tests" << endl; - cout << endl; + std::cout << std::endl; + std::cout << "usage: " << name << " {-f |-x|-d|-a } {--system|--session|-c } " << std::endl; + std::cout << std::endl; + std::cout << " -f - Flatbuffers" << std::endl; + std::cout << " -x - XML" << std::endl; + std::cout << " -d - FB after XML" << std::endl; + std::cout << " -a - All tests" << std::endl; + std::cout << std::endl; } static const struct option options[] { @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) } if (optind < argc) { - count = stoi(argv[optind]); + count = std::stoi(argv[optind]); } else { print_help(argv[0]); return 1; diff --git a/src/stest_performance.cpp b/src/stest_performance.cpp index f37b7ad..a98f139 100644 --- a/src/stest_performance.cpp +++ b/src/stest_performance.cpp @@ -218,13 +218,13 @@ void run_tests(const char *conf_file, size_t c, Choice ch) { } void print_help(const char *name) { - cout << endl; - cout << "usage: " << name << " {-f|-x|-a} {--system|--session|-c } " << endl; - cout << endl; - cout << " -f - Flatbuffers" << endl; - cout << " -x - XML" << endl; - cout << " -a - Flatbuffers and XML" << endl; - cout << endl; + std::cout << std::endl; + std::cout << "usage: " << name << " {-f|-x|-a} {--system|--session|-c } " << std::endl; + std::cout << std::endl; + std::cout << " -f - Flatbuffers" << std::endl; + std::cout << " -x - XML" << std::endl; + std::cout << " -a - Flatbuffers and XML" << std::endl; + std::cout << std::endl; } static const struct option options[] { @@ -262,7 +262,7 @@ int main(int argc, char *argv[]) } if (optind < argc) { - count = stoi(argv[optind]); + count = std::stoi(argv[optind]); } else { print_help(argv[0]); return 1;