modify some bugs of functions
authorMinchul Lee <slotus.lee@samsung.com>
Tue, 23 Jun 2015 06:29:04 +0000 (15:29 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:06:25 +0000 (20:06 +0900)
Change-Id: Icd79fbad4546569650bce50b0855df570f623e7c
Signed-off-by: Minchul Lee <slotus.lee@samsung.com>
lib/icl-repr-list.c
lib/icl-repr-obj.c
lib/icl-repr.c
lib/include/iotcon-representation.h
test/repr-test-client.c

index 06b2145..a1ff4d5 100644 (file)
@@ -82,8 +82,8 @@ API int iotcon_list_insert_int(iotcon_list_h list, int val, int pos)
        iotcon_value_h value;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_PARAMETER,
-                       "Invalid Type(%d)", list->type);
+       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
+                       list->type);
 
        value = icl_value_new_int(val);
        if (NULL == value) {
@@ -100,7 +100,7 @@ API int iotcon_list_insert_bool(iotcon_list_h list, bool val, int pos)
        iotcon_value_h value;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
 
        value = icl_value_new_bool(val);
@@ -118,7 +118,7 @@ API int iotcon_list_insert_double(iotcon_list_h list, double val, int pos)
        iotcon_value_h value;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
 
        value = icl_value_new_double(val);
@@ -137,7 +137,7 @@ API int iotcon_list_insert_str(iotcon_list_h list, char *val, int pos)
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
 
        value = icl_value_new_str(val);
@@ -156,7 +156,7 @@ API int iotcon_list_insert_list(iotcon_list_h list, iotcon_list_h val, int pos)
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
 
        value = icl_value_new_list(val);
@@ -177,7 +177,7 @@ API int iotcon_list_insert_repr(iotcon_list_h list, iotcon_repr_h val, int pos)
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
 
        value = icl_value_new_repr(val);
@@ -364,8 +364,8 @@ static int _icl_list_del_nth_value(iotcon_list_h list, int pos, iotcon_types_e v
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(value_type != list->type, IOTCON_ERROR_INVALID_PARAMETER,
-                       "IOTCON_ERROR_PARAMETER(%d)", list->type);
+       RETVM_IF(value_type != list->type, IOTCON_ERROR_INVALID_TYPE,
+                       "Type Mismatching(list:%d, value:%d)", list->type, value_type);
 
        value = g_list_nth_data(list->list, pos);
        if (NULL == value) {
@@ -508,8 +508,8 @@ API int iotcon_list_foreach_int(iotcon_list_h list, iotcon_list_int_fn fn,
        ic_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_PARAMETER,
-                       "Invalid Type(%d)", list->type);
+       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
+                       list->type);
        RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        cur = list->list;
@@ -533,7 +533,7 @@ API int iotcon_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_fn fn,
        ic_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
        RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -558,7 +558,7 @@ API int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_fn fn,
        ic_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
        RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -583,8 +583,8 @@ API int iotcon_list_foreach_str(iotcon_list_h list, iotcon_list_str_fn fn,
        ic_basic_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
-                       "Invalid Type(%d)", list->type);
+       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_TYPE, "Invalid Type(%d)",
+                       list->type);
        RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        cur = list->list;
@@ -608,7 +608,7 @@ API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_fn fn,
        ic_val_list_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
        RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
@@ -632,7 +632,7 @@ API int iotcon_list_foreach_repr(iotcon_list_h list, iotcon_list_repr_fn fn, voi
        ic_val_repr_s *real = NULL;
 
        RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_INVALID_TYPE,
                        "Invalid Type(%d)", list->type);
        RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);;
 
index ce6d835..f3ea1ac 100644 (file)
@@ -42,7 +42,7 @@ int icl_obj_del_value(iotcon_repr_h repr, const char *key,
 
        if (value_type != value->type) {
                ERR("Type matching Fail(input:%d, saved:%d)", value_type, value->type);
-               return IOTCON_ERROR_INVALID_PARAMETER;
+               return IOTCON_ERROR_INVALID_TYPE;
        }
 
        ret = g_hash_table_remove(repr->hash_table, key);
@@ -559,7 +559,7 @@ static inline int _icl_obj_to_json(const char *key, iotcon_value_h value,
 JsonObject* icl_obj_to_json(iotcon_repr_h repr)
 {
        int ret;
-       int key_count;
+       unsigned int key_count;
        JsonObject *json_obj = NULL;
        JsonObject *parent_obj = NULL;
 
index f0d8b21..0a8ac34 100644 (file)
@@ -216,10 +216,10 @@ API int iotcon_repr_foreach_keys(iotcon_repr_h repr, iotcon_repr_key_fn fn,
        return IOTCON_ERROR_NONE;
 }
 
-API int iotcon_repr_get_keys_count(iotcon_repr_h repr)
+API unsigned int iotcon_repr_get_keys_count(iotcon_repr_h repr)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == repr->hash_table, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, 0);
+       RETV_IF(NULL == repr->hash_table, 0);
 
        return g_hash_table_size(repr->hash_table);
 }
index 2317aca..73bd17c 100644 (file)
@@ -110,7 +110,7 @@ int iotcon_repr_get_nth_child(iotcon_repr_h parent, int pos, iotcon_repr_h *chil
 
 typedef int (*iotcon_repr_key_fn)(iotcon_repr_h repr, const char *key, void *user_data);
 int iotcon_repr_foreach_keys(iotcon_repr_h repr, iotcon_repr_key_fn fn, void *user_data);
-int iotcon_repr_get_keys_count(iotcon_repr_h repr);
+unsigned int iotcon_repr_get_keys_count(iotcon_repr_h repr);
 
 char* iotcon_repr_generate_json(iotcon_repr_h repr);
 
index a9f474e..e89b7e1 100644 (file)
@@ -33,8 +33,7 @@ static int _get_int_list_fn(int pos, const int value, void *user_data)
 static void _on_get(iotcon_repr_h recv_repr, int response_result)
 {
        int i, ret;
-       int key_count;
-       unsigned int children_count;
+       unsigned int key_count, children_count;
        const char *uri;
        iotcon_repr_h child_repr;
        iotcon_list_h list;