Fix coverity issues 75/152975/2 submit/tizen/20170927.120317 submit/tizen/20170927.234325
authorsaerome kim <saerome.kim@samsung.com>
Wed, 27 Sep 2017 11:52:31 +0000 (20:52 +0900)
committersaerome kim <saerome.kim@samsung.com>
Wed, 27 Sep 2017 11:53:40 +0000 (11:53 +0000)
- add missing g_variant_unref()

Change-Id: If81a4104a3891df655de280a90cfa9b7d5a410dc
Signed-off-by: saerome kim <saerome.kim@samsung.com>
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c

index 3327890..75cc3d3 100644 (file)
@@ -451,6 +451,9 @@ static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_int
                payload->result, v_eui64, payload->node_id,
                payload->pan_id, payload->channel, payload->radio_tx_power);
 
+       if (v_eui64)
+               g_variant_unref(v_eui64);
+
        g_free(cb_data);
 }
 
@@ -784,6 +787,9 @@ static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
        zigbee_service_complete_get_mac(service_object, invocation, payload->result,
                v_eui64);
 
+       if (v_eui64)
+               g_variant_unref(v_eui64);
+
        g_free(cb_data);
 }
 
@@ -884,6 +890,9 @@ static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_inte
        zigbee_service_complete_get_device_info(service_object, invocation,
                payload->result, variant);
 
+       if (variant)
+               g_variant_unref(variant);
+
        g_free(cb_data);
 }
 
@@ -963,6 +972,9 @@ static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_in
        zigbee_service_complete_get_endpoint_list(service_object, invocation,
                payload->result, v_endpoints);
 
+       if (v_endpoints)
+               g_variant_unref(v_endpoints);
+
        g_free(cb_data);
 }
 
@@ -1062,6 +1074,11 @@ static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_int
        zigbee_service_complete_get_cluster_list(service_object, invocation,
                payload->result, v_in_clusters, v_out_clusters);
 
+       if (v_in_clusters)
+               g_variant_unref(v_in_clusters);
+       if (v_out_clusters)
+               g_variant_unref(v_out_clusters);
+
        g_free(cb_data);
 }
 
@@ -1266,14 +1283,14 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *
                        child_t->endpoints, child_t->endpoint_count, TRUE, NULL, NULL);
                if (NULL == v_eui64 || NULL == v_endpoints) {
                        Z_LOGE("Failed to create variant!");
-                       if (v_eui64)
-                               g_object_unref(v_eui64);
-                       if (v_endpoints)
-                               g_object_unref(v_endpoints);
                } else {
                        zigbee_service_emit_child_joined(service_object,
                                v_eui64, child_t->endpoint_count, v_endpoints, child_t->node_id);
                }
+               if (v_eui64)
+                       g_variant_unref(v_eui64);
+               if (v_endpoints)
+                       g_variant_unref(v_endpoints);
        }
        break;
        case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
@@ -1299,6 +1316,7 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *
                else {
                        zigbee_service_emit_child_left(service_object,
                                v_eui64, child_left_t->status);
+                       g_variant_unref(v_eui64);
                }
        }
        break;
index 9c5a0e8..1478f0e 100644 (file)
@@ -1455,16 +1455,16 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                        TRUE, NULL, NULL);
                if (NULL == v_types || NULL == v_attrs) {
                        Z_LOGE("Failed to create variant!");
-                       if (v_types)
-                               g_variant_unref(v_types);
-                       if (v_attrs)
-                               g_variant_unref(v_attrs);
                } else {
                        Z_LOGD("Discover attribute resp");
                        zigbee_zcl_global_control_emit_discover_attribute_rsp(global_control_object,
                                attr_t->node_id, attr_t->src_ep, v_types, v_attrs,
                                attr_t->cluster_id, attr_t->record_length, attr_t->discovery_completed);
                }
+               if (v_types)
+                       g_variant_unref(v_types);
+               if (v_attrs)
+                       g_variant_unref(v_attrs);
        break;
        }
        case ZBLIB_ZCL_GLOBAL_NOTI_WRITE_ATTR_STRUCTURED_RSP: {
@@ -1518,6 +1518,12 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                        v_status, v_attrs, v_indicator, v_index,
                        attr_t->cluster_id, attr_t->record_length,
                        attr_t->node_id, attr_t->src_ep);
+               if (v_status)
+                       g_variant_unref(v_status);
+               if (v_attrs)
+                       g_variant_unref(v_attrs);
+               if (v_indicator)
+                       g_variant_unref(v_indicator);
        break;
        }
        case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_RECEIVED_RSP: {
@@ -1536,6 +1542,8 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                                v_commands, attr_t->cluster_id, attr_t->list_count,
                                attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed);
                }
+               if (v_commands)
+                       g_variant_unref(v_commands);
        break;
        }
        case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_GENERATED_RSP: {
@@ -1554,6 +1562,8 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                                v_commands, attr_t->cluster_id, attr_t->list_count,
                                attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed);
                }
+               if (v_commands)
+                       g_variant_unref(v_commands);
        break;
        }
        case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_ATTR_EXT_RSP: {
@@ -1572,12 +1582,6 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                        attr_t->access_list, attr_t->list_count, TRUE, NULL, NULL);
                if (NULL == v_attrs_type || NULL == v_attrs || NULL == v_access) {
                        Z_LOGE("Failed to create variant!");
-                       if (v_attrs_type)
-                               g_variant_unref(v_attrs_type);
-                       if (v_attrs)
-                               g_variant_unref(v_attrs);
-                       if (v_access)
-                               g_variant_unref(v_access);
                } else {
                        Z_LOGD("Discover attributes extended resp");
                        zigbee_zcl_global_control_emit_discover_attributes_extended_rsp(
@@ -1586,6 +1590,12 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                                attr_t->cluster_id, attr_t->list_count,
                                attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed);
                }
+               if (v_attrs_type)
+                       g_variant_unref(v_attrs_type);
+               if (v_attrs)
+                       g_variant_unref(v_attrs);
+               if (v_access)
+                       g_variant_unref(v_access);
        break;
        }
        case ZBLIB_ZCL_GLOBAL_NOTI_DEFAULT_RSP: {
@@ -1612,12 +1622,14 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"),
                        attr_t->attribute_list, (sizeof(gushort) * attr_t->list_count),
                        TRUE, NULL, NULL);
+               if (NULL == v_attrs) {
+                       Z_LOGE("Failed to create variant!");
+                       break;
+               }
                v_data_type = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"),
                        attr_t->data_type_list, attr_t->list_count, TRUE, NULL, NULL);
-               if (NULL == v_data_type || NULL == v_attrs) {
+               if (NULL == v_data_type) {
                        Z_LOGE("Failed to create variant!");
-                       if (v_data_type)
-                               g_variant_unref(v_data_type);
                        if (v_attrs)
                                g_variant_unref(v_attrs);
                        break;
@@ -1626,8 +1638,10 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                values_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
                if (NULL == values_builder) {
                        Z_LOGE("Failed to create variant builder!");
-                       g_variant_unref(v_data_type);
-                       g_variant_unref(v_attrs);
+                       if (v_attrs)
+                               g_variant_unref(v_attrs);
+                       if (v_data_type)
+                               g_variant_unref(v_data_type);
                        break;
                }
                for (i = 0; i < attr_t->list_count; i++) {
@@ -1643,6 +1657,12 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                        attr_t->node_id, attr_t->src_ep, attr_t->cluster_id,
                        v_attrs, v_data_type, v_values,
                        attr_t->list_count);
+               if (v_attrs)
+                       g_variant_unref(v_attrs);
+               if (v_data_type)
+                       g_variant_unref(v_data_type);
+               if (v_values)
+                       g_variant_unref(v_values);
        break;
        }
        case ZBLIB_ZCL_GLOBAL_NOTI_READ_CONFIG_REPORT_RSP: {
@@ -1693,6 +1713,9 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService
                zigbee_zcl_global_control_emit_read_configure_reporting_rsp(
                        global_control_object, resp_t->node_id, resp_t->src_ep,
                        resp_t->cluster_id, resp_t->record_count, v_entries);
+
+               if (v_entries)
+                       g_variant_unref(v_entries);
        break;
        }
        default:
index 6012740..564dd10 100644 (file)
@@ -1591,16 +1591,16 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                        (sizeof(gushort) * nwk_addr_t->associated_count), TRUE, NULL, NULL);
                if (NULL == v_eui64 || NULL == v_associated) {
                        Z_LOGE("Failed to create variant!");
-                       if (v_eui64)
-                               g_variant_unref(v_eui64);
-                       if (v_associated)
-                               g_variant_unref(v_associated);
                } else {
                        Z_LOGD("nwk addr ext rsp : [0x%X]", nwk_addr_t->status);
                        zigbee_zdo_dev_control_emit_nwk_addr_ext_rsp(dev_control_object,
                                nwk_addr_t->status, v_eui64, nwk_addr_t->node_id,
                                nwk_addr_t->associated_count, nwk_addr_t->start_index, v_associated);
                }
+               if (v_eui64)
+                       g_variant_unref(v_eui64);
+               if (v_associated)
+                       g_variant_unref(v_associated);
        break;
        }
        case ZBLIB_ZDO_DEV_CONTROL_NOTI_ACTIVE_EP_RSP: {
@@ -1617,6 +1617,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                                active_t->status, active_t->node_id,
                                v_ep_list, active_t->endpoint_count);
                }
+               if (v_ep_list)
+                       g_variant_unref(v_ep_list);
        break;
        }
        case ZBLIB_ZDO_DEV_CONTROL_NOTI_SIMPLE_DESC_RSP: {
@@ -1633,10 +1635,6 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                        TRUE, NULL, NULL);
                if (NULL == v_in_cluster || NULL == v_out_cluster) {
                        Z_LOGE("Failed to create variant!");
-                       if (v_in_cluster)
-                               g_variant_unref(v_in_cluster);
-                       if (v_out_cluster)
-                               g_variant_unref(v_out_cluster);
                } else {
                        Z_LOGD("Simple descriptor rsp");
                        zigbee_zdo_dev_control_emit_simple_desc_rsp(dev_control_object,
@@ -1645,6 +1643,10 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                                desc_t->in_cluster_count, desc_t->out_cluster_count,
                                v_in_cluster, v_out_cluster);
                }
+               if (v_in_cluster)
+                       g_variant_unref(v_in_cluster);
+               if (v_out_cluster)
+                       g_variant_unref(v_out_cluster);
        break;
        }
        case ZBLIB_ZDO_DEV_CONTROL_NOTI_MATCHED_DESC_RSP: {
@@ -1660,6 +1662,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                        zigbee_zdo_dev_control_emit_matched_descriptor_rsp(dev_control_object,
                                desc_t->status, desc_t->node_id, desc_t->list_count, v_match_list);
                }
+               if (v_match_list)
+                       g_variant_unref(v_match_list);
        break;
        }
        case ZBLIB_ZDO_DEV_CONTROL_NOTI_MGMT_BIND_RSP: {
@@ -1718,6 +1722,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                        desc_t->status, desc_t->table_entries,
                        desc_t->start_index, desc_t->table_list_count,
                        v_entries);
+               if (v_entries)
+                       g_variant_unref(v_entries);
        break;
        }
        case ZBLIB_ZDO_DEV_CONTROL_NOTI_MGMT_LQI_RSP: {
@@ -1873,6 +1879,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                        nwk_disc_t->status, nwk_disc_t->network_count,
                        nwk_disc_t->start_index, nwk_disc_t->table_list_count,
                        v_entries);
+               if (v_entries)
+                       g_variant_unref(v_entries);
        break;
        }
        case ZBLIB_ZDO_DEV_CONTROL_NOTI_NODE_DESC_RSP: {
@@ -1932,6 +1940,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt
                        zigbee_zdo_dev_control_emit_user_desc_rsp(dev_control_object,
                                desc_t->status, desc_t->node_id, desc_t->list_count, v_desc_list);
                }
+               if (v_desc_list)
+                       g_variant_unref(v_desc_list);
        break;
        }
        case ZBLIB_ZDO_DEV_CONTROL_NOTI_USER_DESC_CONFIRM: {