Fixed svace issues
authorsaerome.kim <saerome.kim@samsung.com>
Tue, 24 Apr 2018 08:20:56 +0000 (17:20 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:50 +0000 (19:38 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
src/mdg-manager/src/mdgd_db.c
src/mdg-manager/src/mdgd_group.c
src/mdg-manager/src/mdgd_iot.cpp
src/mdg-manager/src/mdgd_mot_agent.c

index a2fc584..fc8ba5e 100644 (file)
@@ -125,7 +125,7 @@ static int __check_integrity()
                if (ret == SQLITE_ROW) {
                        const char *ret_val = (const char *)sqlite3_column_text(stmt, 0);
                        LOG_ERR("ret_val: %s", ret_val);
-                       if (ret_val && strcmp(ret_val, "ok") == 0) {
+                       if (ret_val && !strncmp(ret_val, "ok", strlen("ok"))) {
                                result = 0;
                        } else {
                                LOG_ERR("failed to check integrity");
index 1f1d663..bf3e014 100644 (file)
@@ -89,7 +89,7 @@ int mdgd_group_create(const char* name)
        for (l = list; l != NULL; l = l->next) {
                mdgd_grp_t *grp = (mdgd_grp_t *)l->data;
 
-               if (strcmp(grp->name, name) == 0) {
+               if (!strncmp(grp->name, name, strlen(grp->name))) {
                        LOG_ERR("already exists name in structure");
                        return MDGD_ERROR_UNKNOWN;
                }
@@ -626,7 +626,7 @@ int _is_pairwise_uuid(char *uuid)
        while (iter != NULL) {
                char *pairwise_uuid = (char *)iter->data;
 
-               if (strcmp(pairwise_uuid, uuid) == 0)
+               if (!strncmp(pairwise_uuid, uuid, strlen(uuid)))
                        return 0;
 
                iter = g_list_next(iter);
@@ -646,11 +646,11 @@ int mdgd_group_add_device_in_group(const char *group_name, const char *uuid)
        while (iter != NULL) {
                mdgd_grp_t *group = (mdgd_grp_t *)iter->data;
 
-               if (strcmp(group_name, group->name) == 0) {
+               if (!strncmp(group_name, group->name, strlen(group->name))) {
                        GList *device_iter = group->device_list;
                        while (device_iter != NULL) {
                                char *device_uuid = (char *)device_iter->data;
-                               if (strcmp(device_uuid, uuid) == 0)
+                               if (!strncmp(device_uuid, uuid, strlen(device_uuid)))
                                        return -1;
 
                                device_iter = g_list_next(device_iter);
@@ -742,7 +742,7 @@ int mdgd_group_remove_device_in_group(char *group_name, char *uuid)
        iter = mdgd_ctx->grp_list;
        while (iter != NULL) {
                mdgd_grp_t *group = (mdgd_grp_t *)iter->data;
-               if (strcmp(group_name, group->name) == 0) {
+               if (!strncmp(group_name, group->name, strlen(group_name))) {
                        GList *device_iter = group->device_list;
 
                        device_iter = g_list_remove_all(device_iter, uuid);
index 3cbf4ce..ed80b4b 100644 (file)
@@ -819,7 +819,7 @@ static bool _found_resource(std::shared_ptr<OCResource> resource,
                                        return TRUE;
                                }
 
-                               if (strcmp(cmd->arg1, "disc_mot_enb_devs_done") == 0)
+                               if (!strncmp(cmd->arg1, "disc_mot_enb_devs_done", strlen(cmd->arg1)))
                                        mowned = false;
                                else
                                        mowned = true;
@@ -900,7 +900,7 @@ static bool _found_resource(std::shared_ptr<OCResource> resource,
 
                                mdgd_check_null_ret_error("device", device, TRUE);
 
-                               if (strcmp(cmd->uuid, resource_device_id) != 0) {
+                               if (strncmp(cmd->uuid, resource_device_id, strlen(cmd->uuid))) {
                                        LOG_DEBUG("Get peer description from another device");
                                        /* Get Peer Description using "Get" operation */
                                        device->type = MDGD_GROUP_DEVICE_REMOTE;
@@ -942,7 +942,7 @@ static bool _found_resource(std::shared_ptr<OCResource> resource,
                                LOG_DEBUG("Resource Type %s", resource_type);
                                LOG_DEBUG("Command Device ID: %s", cmd ? cmd->uuid : "NULL");
 
-                               if (cmd != NULL && strcmp(cmd->uuid, resource_device_id) == 0) {
+                               if (cmd != NULL && !strncmp(cmd->uuid, resource_device_id, strlen(cmd->uuid))) {
                                        OCRepresentation rep;
 
                                        LOG_DEBUG("Request to Remote Device");
@@ -1024,7 +1024,7 @@ static gboolean _timeout_cb(gpointer data)
                if (cmd->command != MDGD_REQ_KEEP_ALIVE)
                        notify_send_data_finish("RESP_DATA", last_get_result);
        } else if (cmd->resource_type == MDGD_RESOURCE_TYPE_DEVICE) {
-               if (strcmp(cmd->arg1, "disc_mot_enb_devs_done") == 0) {
+               if (!strncmp(cmd->arg1, "disc_mot_enb_devs_done", strlen(cmd->arg1))) {
                        LOG_DEBUG("Device Find Done. notified");
                        mdgd_group_notify_mot_enable_device_done();
 
index aee73cf..347bc0d 100644 (file)
@@ -498,35 +498,6 @@ static gboolean __perform_remove_cred_at_local(gpointer data)
 }
 #endif
 
-static void _free_device_info(mdgd_mot_device_t *device)
-{
-       if (!device)
-               return;
-
-       if (device->device_id != NULL) {
-               g_free(device->device_id);
-               device->device_id = NULL;
-       }
-       if (device->addr != NULL) {
-               g_free(device->addr);
-               device->addr = NULL;
-       }
-       if (device->route_data != NULL) {
-               g_free(device->route_data);
-               device->route_data = NULL;
-       }
-       if (device->remote_id != NULL) {
-               g_free(device->remote_id);
-               device->remote_id = NULL;
-       }
-       if (device->sec_ver != NULL) {
-               g_free(device->sec_ver);
-               device->sec_ver = NULL;
-       }
-       g_free(device);
-       device = NULL;
-}
-
 static void _agent_signal_handler(GDBusConnection *connection,
                const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
                const gchar *signal_name, GVariant *parameters, gpointer userdata)