Add error handling of state array & Fix return type of icl_ioty_unset_device_info_cha... 32/62732/3 accepted/tizen/common/20160318.150159 accepted/tizen/ivi/20160321.113535 accepted/tizen/mobile/20160321.113449 accepted/tizen/tv/20160321.113458 accepted/tizen/wearable/20160321.113509 submit/tizen/20160318.081135 submit/tizen/20160321.021645
authoryoungman <yman.jung@samsung.com>
Thu, 17 Mar 2016 23:28:44 +0000 (08:28 +0900)
committeryoungman <yman.jung@samsung.com>
Fri, 18 Mar 2016 00:00:58 +0000 (09:00 +0900)
Change-Id: I2feb38fa706b28bf607c518cfa2b256addc053e1
Signed-off-by: youngman <yman.jung@samsung.com>
lib/icl-ioty-types.c
lib/icl-ioty.c
lib/icl-ioty.h

index b2a9bded396832b3f414301a2231101aa1be5dc7..3c70006e3d9f384ba1d2946f201417cd3b1b7cb4 100644 (file)
@@ -729,7 +729,7 @@ int icl_ioty_parse_oic_rep_payload(OCRepPayload *payload, bool is_parent,
 static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload,
                const char *key, struct icl_state_list_s *list)
 {
-       int i, len, ret;
+       int i, j, len, ret;
        bool *b_arr;
        double *d_arr;
        char **str_arr;
@@ -811,10 +811,18 @@ static int _icl_ioty_fill_oic_rep_payload_value_array(OCRepPayload *payload,
                }
                for (node = list->list, i = 0; node; node = node->next, i++) {
                        state_arr[i] = OCRepPayloadCreate();
+                       if (NULL == state_arr[i]) {
+                               ERR("OCRepPayloadCreate() Fail");
+                               free(state_arr);
+                               return ret;
+                       }
                        ret = _icl_ioty_fill_oic_rep_payload_value(state_arr[i],
                                        ((icl_val_state_s*)node->data)->state);
                        if (IOTCON_ERROR_NONE != ret) {
                                ERR("_icl_ioty_fill_oic_rep_payload_value() Fail(%d)", ret);
+                               for (j = 0; j <= i; j++)
+                                       OCRepPayloadDestroy(state_arr[j]);
+                               free(state_arr);
                                return ret;
                        }
                }
index 003bc9fc26bd94fa5b095c7f2ec12f785921cef3..5a1aade9c88d5f7a39cb089972609a6548ce2b9d 100644 (file)
@@ -365,11 +365,13 @@ static void _icl_ioty_on_device_name_changed_cb(system_settings_key_e key,
        }
 }
 
-int icl_ioty_unset_device_info_changed_cb()
+void icl_ioty_unset_device_info_changed_cb()
 {
        int ret;
+
        ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_DEVICE_NAME);
-       WARN_IF(SYSTEM_SETTINGS_ERROR_NONE != ret, "system_settings_unset_changed_cb() Fail(%d)", ret);
+       WARN_IF(SYSTEM_SETTINGS_ERROR_NONE != ret,
+                       "system_settings_unset_changed_cb() Fail(%d)", ret);
 }
 
 int icl_ioty_set_device_info()
index 87a31314ac1b9c6f9f41d13e7e4b20b32cf17513..d0f59bd5f25e116e8949190a078f256cdaed575f 100644 (file)
@@ -46,7 +46,7 @@ int icl_ioty_init(GThread **out_thread);
 
 int icl_ioty_set_device_info();
 int icl_ioty_set_platform_info();
-int icl_ioty_unset_device_info_changed_cb();
+void icl_ioty_unset_device_info_changed_cb();
 
 /* client APIs */
 int icl_ioty_find_resource(const char *host_address,