-Wextra -Werror 43/90343/3 accepted/tizen/common/20161010.145823 accepted/tizen/ivi/20161010.083129 accepted/tizen/mobile/20161010.083040 accepted/tizen/tv/20161010.083052 accepted/tizen/wearable/20161010.083113 submit/tizen/20161010.033741
authorKonrad Lipinski <konrad.l@samsung.com>
Thu, 29 Sep 2016 11:59:14 +0000 (13:59 +0200)
committerKonrad Lipinski <konrad.l@samsung.com>
Fri, 30 Sep 2016 08:37:03 +0000 (10:37 +0200)
Change-Id: I1b74a76cff3ecb38b646a3dd9a7327d25e5fa1d7

configure.ac
src/internal/cynara_mockup.cpp
src/internal/naive_policy_checker.cpp
src/internal/naive_policy_checker.hpp
src/internal/naive_policy_db.cpp
src/internal/naive_policy_db.hpp
src/internal/policy.cpp
src/internal/policy.hpp
src/internal/xml_parser.hpp
src/libdbuspolicy1.c

index 3a0e44f..9c5aa73 100644 (file)
@@ -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 \
 "
 
index 520761f..8b701cd 100644 (file)
@@ -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;
 }
index 71ab8c1..f136fa4 100644 (file)
@@ -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  <<std::endl;
-}
-
-static void __log_item(const ItemOwn& item)
-{
-       char tmp[MAX_LOG_LINE];
-       const char* i_str = item.toString(tmp);
-       std::cout << "checkpolicy for: " << i_str <<std::endl;
+       std::cout << "checkpolicy for: " << i_str  <<std::endl;
 }
 
 DbAdapter& NaivePolicyChecker::generateAdapter() {
@@ -79,7 +72,7 @@ DecisionResult NaivePolicyChecker::check(bool bus_type,
                                                           gid_t gid,
                                                           const char* const label,
                                                           const char* const name) {
-       return this->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<unsigned>(*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) {
index b80c23f..8504a14 100644 (file)
@@ -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();
 
index a796660..8a10c80 100644 (file)
@@ -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<unsigned>(*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<unsigned>(*name)];
                if (node->children[childIndex] == NULL) {
                        node->children[childIndex] = new struct TreeNode;
                        node->children[childIndex]->__decisionItem = {Decision::ANY, NULL};
index 5efd301..161d24c 100644 (file)
@@ -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;
 
index 9a0a99c..5089349 100644 (file)
@@ -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("<<i<<"): "<<name<<std::endl;
                        }
                        while ((c = name[i++]) && ' ' != c);
@@ -308,9 +308,7 @@ ItemSendReceive::ItemSendReceive(const char* name,
                                                                 const char* member,
                                                                 const char* path,
                                                                 MessageType type,
-                                                                MessageDirection direction,
-                                                                Decision decision,
-                                                                const char* privilege)
+                                                                MessageDirection direction)
        :       __name(NameSR(name, name?std::strlen(name):0)),
                __interface(interface),
                __member(member),
index 4e17722..de8619a 100644 (file)
 namespace ldp_xml_parser
 {
        /** Char map used in ownership policy. Single character from given name is mapped to index of tree node child*/
-       const char char_map[128] {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+       const char char_map[256] {65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
                                65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
                                65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 10, 12, 65,
                                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 65, 65, 65, 65, 65, 65,
                                65, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
                                54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 65, 65, 65, 11,
                                65, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
-                               28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 65, 65, 65, 65, 65};
+                               28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 65, 65, 65, 65, 65,
+
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+                               65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65};
        /** Type of sent message*/
        enum class MessageType : uint8_t {
                ANY = 0,
@@ -190,9 +199,7 @@ namespace ldp_xml_parser
                                                const char* member = NULL,
                                                const char* path = NULL,
                                                MessageType type = MessageType::ANY,
-                                               MessageDirection direction = MessageDirection::ANY,
-                                               Decision decision = Decision::ANY,
-                                               const char* privilege = NULL);
+                                               MessageDirection direction = MessageDirection::ANY);
                ~ItemSendReceive();
                bool match(const MatchItemSR& item) const;
                MessageDirection getDirection() const;
index 4e417b1..6582479 100644 (file)
@@ -60,23 +60,23 @@ namespace ldp_xml_parser
                 ErrCode err;
                 std::vector<std::string> 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<std::string>& included_files) {
+            ErrCode parse(bool bus, const std::string& filename, std::vector<std::string>& included_files) {
                 std::pair<ErrCode, std::string> errparam;
                                std::vector<std::string> 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);
                                }
 
index b6c35a9..1721185 100644 (file)
@@ -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);