Fix internal logic
authorsung.goo.kim <sung.goo.kim@samsung.com>
Fri, 20 Nov 2015 02:30:14 +0000 (11:30 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Fri, 20 Nov 2015 06:13:51 +0000 (15:13 +0900)
Change-Id: I88803b42fb56e45d663048e646cf0f0a0822d717

daemon/icd-payload.c
lib/icl-list.c
lib/icl-representation.c
lib/icl-state.c
lib/icl-state.h

index bdc2f06..e12d697 100644 (file)
@@ -464,7 +464,6 @@ static void _icd_state_list_from_gvariant(GVariant *var,
                                        g_variant_iter_init(&state_iter, value);
                                        _icd_state_value_from_gvariant(repr, &state_iter);
                                        value_list->list = g_list_append(value_list->list, repr);
-                                       g_variant_iter_free(&state_iter);
                                } while (g_variant_iter_loop(&iter, "v", &value));
 
                        } else if (g_variant_is_of_type(value, G_VARIANT_TYPE_ARRAY)) {
index 6e8ef1e..0ece1f5 100644 (file)
@@ -34,18 +34,14 @@ void icl_list_inc_ref_count(iotcon_list_h val)
 
 static bool _icl_list_dec_ref_count(iotcon_list_h val)
 {
-       bool ret;
-
        RETV_IF(NULL == val, false);
        RETVM_IF(val->ref_count <= 0, false, "Invalid Count(%d)", val->ref_count);
 
        val->ref_count--;
        if (0 == val->ref_count)
-               ret = true;
-       else
-               ret = false;
+               return true;
 
-       return ret;
+       return false;
 }
 
 static int _icl_list_create(iotcon_type_e type, iotcon_list_h *ret_list)
index a3c0d8d..eeba7ee 100644 (file)
@@ -43,18 +43,14 @@ void icl_representation_inc_ref_count(iotcon_representation_h val)
 
 static bool _icl_representation_dec_ref_count(iotcon_representation_h val)
 {
-       bool ret;
-
-       RETV_IF(NULL == val, -1);
+       RETV_IF(NULL == val, false);
        RETVM_IF(val->ref_count <= 0, false, "Invalid Count(%d)", val->ref_count);
 
        val->ref_count--;
        if (0 == val->ref_count)
-               ret = true;
-       else
-               ret = false;
+               return true;
 
-       return ret;
+       return false;
 }
 
 
@@ -118,13 +114,9 @@ API int iotcon_representation_set_uri_path(iotcon_representation_h repr,
                const char *uri_path)
 {
        RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
 
        free(repr->uri_path);
-       repr->uri_path = NULL;
-
-       if (NULL == uri_path)
-               return IOTCON_ERROR_INVALID_PARAMETER;
-
        repr->uri_path = strdup(uri_path);
        if (NULL == repr->uri_path) {
                ERR("strdup() Fail");
index 7618bd8..fce11e7 100644 (file)
@@ -33,14 +33,16 @@ void icl_state_inc_ref_count(iotcon_state_h val)
 }
 
 
-int icl_state_dec_ref_count(iotcon_state_h val)
+static bool _icl_state_dec_ref_count(iotcon_state_h val)
 {
-       RETV_IF(NULL == val, -1);
-       RETVM_IF(val->ref_count <= 0, 0, "Invalid Count(%d)", val->ref_count);
+       RETV_IF(NULL == val, false);
+       RETVM_IF(val->ref_count <= 0, false, "Invalid Count(%d)", val->ref_count);
 
        val->ref_count--;
+       if (0 == val->ref_count)
+               return true;
 
-       return val->ref_count;
+       return false;
 }
 
 
@@ -71,10 +73,11 @@ API void iotcon_state_destroy(iotcon_state_h state)
 {
        RET_IF(NULL == state);
 
-       if (0 == icl_state_dec_ref_count(state)) {
-               g_hash_table_destroy(state->hash_table);
-               free(state);
-       }
+       if (false == _icl_state_dec_ref_count(state))
+               return;
+
+       g_hash_table_destroy(state->hash_table);
+       free(state);
 }
 
 API int iotcon_state_clone(iotcon_state_h state, iotcon_state_h *state_clone)
index 0cfa0c1..6e2aad5 100644 (file)
@@ -20,7 +20,6 @@
 #include "icl-representation.h"
 
 void icl_state_inc_ref_count(iotcon_state_h val);
-int icl_state_dec_ref_count(iotcon_state_h val);
 
 int icl_state_del_value(iotcon_state_h state, const char *key);