From: Konrad Lipinski Date: Thu, 29 Sep 2016 11:59:14 +0000 (+0200) Subject: -Wextra -Werror X-Git-Tag: accepted/tizen/common/20161010.145823^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F90343%2F3;p=platform%2Fcore%2Fsystem%2Flibdbuspolicy.git -Wextra -Werror Change-Id: I1b74a76cff3ecb38b646a3dd9a7327d25e5fa1d7 --- diff --git a/configure.ac b/configure.ac index 3a0e44f..9c5aa73 100644 --- a/configure.ac +++ b/configure.ac @@ -74,21 +74,15 @@ AC_CHECK_FUNCS([ \ my_CFLAGS="\ -Wall \ --Wchar-subscripts \ --Wformat-security \ --Wmissing-declarations \ --Wmissing-prototypes \ --Wnested-externs \ --Wpointer-arith \ --Wshadow \ --Wsign-compare \ --Wstrict-prototypes \ --Wtype-limits \ +-Wextra \ +-Werror \ " AC_SUBST([my_CFLAGS]) my_CXXFLAGS="\ -Wall \ +-Wextra \ +-Werror \ -std=c++11 \ " diff --git a/src/internal/cynara_mockup.cpp b/src/internal/cynara_mockup.cpp index 520761f..8b701cd 100644 --- a/src/internal/cynara_mockup.cpp +++ b/src/internal/cynara_mockup.cpp @@ -23,5 +23,8 @@ Cynara& Cynara::getInstance() { CynaraResult Cynara::check(const char* label, const char* privilege, const char* uid) { + (void)label; + (void)privilege; + (void)uid; return CynaraResult::ALLOW; } diff --git a/src/internal/naive_policy_checker.cpp b/src/internal/naive_policy_checker.cpp index 71ab8c1..f136fa4 100644 --- a/src/internal/naive_policy_checker.cpp +++ b/src/internal/naive_policy_checker.cpp @@ -13,14 +13,7 @@ static void __log_item(const MatchItemSR& item) { char tmp[MAX_LOG_LINE]; const char* i_str = item.toString(tmp); - std::cout << "checkpolicy for ownership: " << i_str <checkItemOwn(bus_type, uid, gid, label, name, ItemType::OWN); + return this->checkItemOwn(bus_type, uid, gid, label, name); } DecisionResult NaivePolicyChecker::check(bool bus_type, @@ -133,7 +126,7 @@ Decision NaivePolicyChecker::checkPolicyOwn(const NaivePolicyDb::PolicyOwn& poli assert(node); Decision ret = Decision::ANY; while ((name != NULL) && (*name != '\0')) { - childIndex = char_map[*name]; + childIndex = char_map[static_cast(*name)]; if (childIndex > 64) { /* name contains forbidden char */ if (tslog::verbose()) { @@ -164,25 +157,25 @@ Decision NaivePolicyChecker::checkPolicyOwn(const NaivePolicyDb::PolicyOwn& poli return node->__decisionItem.getDecision(); } -DecisionResult NaivePolicyChecker::checkItemOwn(bool bus_type, uid_t uid, gid_t gid, const char* label, const ItemOwn& item, const ItemType type) { +DecisionResult NaivePolicyChecker::checkItemOwn(bool bus_type, uid_t uid, gid_t gid, const char* label, const ItemOwn& item) { NaivePolicyDb& policy_db = getPolicyDb(bus_type); Decision ret = Decision::ANY; const char* privilege; const NaivePolicyDb::PolicyOwn* curr_policy = NULL; if (ret == Decision::ANY) { - if (policy_db.getPolicy(type, PolicyType::CONTEXT, PolicyTypeValue(ContextType::MANDATORY), curr_policy)) + if (policy_db.getPolicy(PolicyType::CONTEXT, PolicyTypeValue(ContextType::MANDATORY), curr_policy)) ret = checkPolicyOwn(*curr_policy, item, privilege); } if (ret == Decision::ANY) { - if (policy_db.getPolicy(type, PolicyType::USER, PolicyTypeValue(uid), curr_policy)) + if (policy_db.getPolicy(PolicyType::USER, PolicyTypeValue(uid), curr_policy)) ret = checkPolicyOwn(*curr_policy, item, privilege); } if (ret == Decision::ANY) { - if (policy_db.getPolicy(type, PolicyType::GROUP, PolicyTypeValue(gid), curr_policy)) + if (policy_db.getPolicy(PolicyType::GROUP, PolicyTypeValue(gid), curr_policy)) ret = checkPolicyOwn(*curr_policy, item, privilege); } if (ret == Decision::ANY) { - if (policy_db.getPolicy(type, PolicyType::CONTEXT, PolicyTypeValue(ContextType::DEFAULT), curr_policy)) + if (policy_db.getPolicy(PolicyType::CONTEXT, PolicyTypeValue(ContextType::DEFAULT), curr_policy)) ret = checkPolicyOwn(*curr_policy, item, privilege); } if (ret != Decision::ANY) { diff --git a/src/internal/naive_policy_checker.hpp b/src/internal/naive_policy_checker.hpp index b80c23f..8504a14 100644 --- a/src/internal/naive_policy_checker.hpp +++ b/src/internal/naive_policy_checker.hpp @@ -114,8 +114,7 @@ namespace ldp_xml_parser uid_t uid, gid_t gid, const char* label, - const ItemOwn& item, - const ItemType type); + const ItemOwn& item); public: ~NaivePolicyChecker(); diff --git a/src/internal/naive_policy_db.cpp b/src/internal/naive_policy_db.cpp index a796660..8a10c80 100644 --- a/src/internal/naive_policy_db.cpp +++ b/src/internal/naive_policy_db.cpp @@ -75,8 +75,7 @@ void NaivePolicyDb::addItem(const PolicyType policy_type, -bool NaivePolicyDb::getPolicy(const ItemType item_type, - const PolicyType policy_type, +bool NaivePolicyDb::getPolicy(const PolicyType policy_type, const PolicyTypeValue policy_type_value, const NaivePolicyDb::PolicyOwn*& policy) const { return this->getPolicyOwn(m_own_set, policy_type, policy_type_value, policy); @@ -194,7 +193,7 @@ void NaivePolicyDb::PolicyOwn::addItem(ItemOwn* item) { const char *tmp = name; while (tmp && *tmp != '\0') { - if (char_map[*tmp] > 64) { + if (char_map[static_cast(*tmp)] > 64) { /* Forbidden char */ return; } @@ -202,7 +201,7 @@ void NaivePolicyDb::PolicyOwn::addItem(ItemOwn* item) { } int childIndex = 0; while (name && *name != '\0') { - childIndex = char_map[*name]; + childIndex = char_map[static_cast(*name)]; if (node->children[childIndex] == NULL) { node->children[childIndex] = new struct TreeNode; node->children[childIndex]->__decisionItem = {Decision::ANY, NULL}; diff --git a/src/internal/naive_policy_db.hpp b/src/internal/naive_policy_db.hpp index 5efd301..161d24c 100644 --- a/src/internal/naive_policy_db.hpp +++ b/src/internal/naive_policy_db.hpp @@ -103,14 +103,12 @@ namespace ldp_xml_parser ~NaivePolicyDb(); /** Gets policy with ownership rules from DB - * \param[in] item_type Item Type * \param[in] policy_type Policy type * \param[in] policy_type_value Policy type value * \param[out] policy Received policy * \return True if there is such policy, false elsewhere */ - bool getPolicy(const ItemType item_type, - const PolicyType policy_type, + bool getPolicy(const PolicyType policy_type, const PolicyTypeValue policy_type_value, const PolicyOwn*& policy) const; diff --git a/src/internal/policy.cpp b/src/internal/policy.cpp index 9a0a99c..5089349 100644 --- a/src/internal/policy.cpp +++ b/src/internal/policy.cpp @@ -285,7 +285,7 @@ bool MatchItemSR::addNames(const char* name) { char c; int len; j = i; - if (tslog::verbose() && !(name[i] >= 'a'&& name[i] <= 'z') || (name[i] >= 'A'&& name[i] <= 'Z') || (name[i] >= '0'&& name[i] <= '9') || name[i] == ' ') { + if (tslog::verbose() && !((name[i] >= 'a'&& name[i] <= 'z') || (name[i] >= 'A'&& name[i] <= 'Z') || (name[i] >= '0'&& name[i] <= '9') || name[i] == ' ')) { std::cout<<"Wrong name("< incl_files; - err = parse(bus, true, filename, incl_files); + err = parse(bus, filename, incl_files); if (err.is_ok()) for (const auto& x : incl_files) { - err = parse(bus, false, x, incl_files); + err = parse(bus, x, incl_files); if (err.is_error()) break; } return err; } /** Parses given xml file and files included in it */ - ErrCode parse(bool bus, bool first, const std::string& filename, std::vector& included_files) { + ErrCode parse(bool bus, const std::string& filename, std::vector& included_files) { std::pair errparam; std::vector incl_dirs; if (tslog::verbose()) std::cout << "=== XML PARSING BEGIN === : " << filename << '\n'; errparam = parseXml(bus, filename, incl_dirs); - for (int i = 0; i < incl_dirs.size(); i++) { + for (unsigned i = 0; i < incl_dirs.size(); i++) { getIncludedFiles(filename, incl_dirs[i], included_files); } diff --git a/src/libdbuspolicy1.c b/src/libdbuspolicy1.c index b6c35a9..1721185 100644 --- a/src/libdbuspolicy1.c +++ b/src/libdbuspolicy1.c @@ -82,7 +82,7 @@ static int kdbus_hello(bool bus_type, uint64_t hello_flags, uint64_t attach_flag { struct kdbus_cmd_hello* cmd; struct kdbus_cmd_free cmd_free; - volatile struct kdbus_item* item; + struct kdbus_item* item; int fd = g_conn[bus_type].fd; int size = ALIGN8(sizeof(struct kdbus_cmd_hello)) + ALIGN8(offsetof(struct kdbus_item, data) + sizeof(CONNECTION_LABEL)); @@ -280,6 +280,7 @@ DBUSPOLICY1_EXPORT void dbuspolicy1_free(void* configuration) #ifdef LIBDBUSPOLICY_TESTS_API DBUSPOLICY1_EXPORT void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid,const char* label) { + (void)configuration; g_udesc.uid = uid; g_udesc.gid = gid; if (label) @@ -300,6 +301,10 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration, int reply_serial, int requested_reply) { + (void)error_name; + (void)reply_serial; + (void)requested_reply; + char const *label = NULL; const char* k_names[KDBUS_CONN_MAX_NAMES+1]; int k_i = 0; @@ -373,8 +378,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration, break; case KDBUS_ITEM_OWNED_NAME: empty_names = false; - if (r <= 0) - k_names[k_i++] = item->name.name; + k_names[k_i++] = item->name.name; break; } } @@ -413,6 +417,10 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_in(void* configuration, int reply_serial, int requested_reply) { + (void)error_name; + (void)reply_serial; + (void)requested_reply; + int r; bool bus_type = configuration_bus_type(configuration);