Apply coding guide : remove goto, error message, .. 64/44664/3
authorSunggoo Kim <sung.goo.kim@samsung.com>
Tue, 12 May 2015 07:53:26 +0000 (16:53 +0900)
committerMyoungHoon Chae <mhoon.chae@samsung.com>
Mon, 27 Jul 2015 07:03:22 +0000 (16:03 +0900)
Change-Id: I52418c27d8350407a01a0d739a76f3c091583461
Signed-off-by: MyoungHoon Chae <mhoon.chae@samsung.com>
common/ctsvc_internal.h
common/ipc/ctsvc_ipc_marshal.c
native/ctsvc_localize_jp.c
native/ctsvc_normalize.c
server/ctsvc_server_sim.c
server/ctsvc_server_socket.c

index 2899b07..6af5d81 100644 (file)
 
 
 #define CONTACTS_FREE(ptr) \
- do { \
-  if (ptr) \
-    free(ptr); \
-  ptr = NULL; \
- } while (0)
+       do { \
+               free(ptr); \
+               ptr = NULL; \
+       } while (0)
 
 // Thread-local storage
 #ifdef _CONTACTS_IPC_SERVER
index 277ee36..bb005e2 100644 (file)
@@ -166,7 +166,6 @@ static void __ctsvc_ipc_unmarshal_composite_filter_free(ctsvc_composite_filter_s
 
 static int __ctsvc_ipc_unmarshal_composite_filter(const pims_ipc_data_h ipc_data, ctsvc_composite_filter_s* filter)
 {
-       int ret = CONTACTS_ERROR_NONE;
        unsigned int size = 0;
        char* str = NULL;
        int count =0, i=0;
@@ -180,63 +179,63 @@ static int __ctsvc_ipc_unmarshal_composite_filter(const pims_ipc_data_h ipc_data
        filter->view_uri = (char*)SAFE_STRDUP(str);
 
        // filters
-       if (ctsvc_ipc_unmarshal_int(ipc_data,&count) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data,&count)) {
+               CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
        for (i=0;i<count;i++) {
-               if (ctsvc_ipc_unmarshal_int(ipc_data,(int*)&filter_type) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                       ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data, (int*)&filter_type)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
+                       __ctsvc_ipc_unmarshal_composite_filter_free(filter);
+                       return CONTACTS_ERROR_IPC;
                }
                if (filter_type == CTSVC_FILTER_COMPOSITE) {
-                       ctsvc_composite_filter_scom_filter = NULL;
+                       ctsvc_composite_filter_s *com_filter = NULL;
                        com_filter = (ctsvc_composite_filter_s*)calloc(1,sizeof(ctsvc_composite_filter_s));
                        if (com_filter == NULL) {
-                               CTS_ERR("calloc fail");
-                               ret = CONTACTS_ERROR_OUT_OF_MEMORY;
-                               goto ERROR_RETURN;
+                               CTS_ERR("calloc() Fail");
+                               __ctsvc_ipc_unmarshal_composite_filter_free(filter);
+                               return CONTACTS_ERROR_OUT_OF_MEMORY;
                        }
-                       if (__ctsvc_ipc_unmarshal_composite_filter(ipc_data, com_filter) != CONTACTS_ERROR_NONE) {
-                               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                               ret = CONTACTS_ERROR_INVALID_PARAMETER;
+                       if (CONTACTS_ERROR_NONE != __ctsvc_ipc_unmarshal_composite_filter(ipc_data, com_filter)) {
+                               CTS_ERR("__ctsvc_ipc_unmarshal_composite_filter() Fail");
                                CONTACTS_FREE(com_filter);
-                               goto ERROR_RETURN;
+                               __ctsvc_ipc_unmarshal_composite_filter_free(filter);
+                               return CONTACTS_ERROR_IPC;
                        }
-                       filter->filters = g_slist_append(filter->filters,com_filter);
+                       filter->filters = g_slist_append(filter->filters, com_filter);
                }
                else {
-                       ctsvc_attribute_filter_sattr_filter = NULL;
+                       ctsvc_attribute_filter_s *attr_filter = NULL;
                        attr_filter = (ctsvc_attribute_filter_s*)calloc(1,sizeof(ctsvc_attribute_filter_s));
                        if (attr_filter == NULL) {
-                               CTS_ERR("calloc fail");
-                               ret = CONTACTS_ERROR_OUT_OF_MEMORY;
-                               goto ERROR_RETURN;
+                               CTS_ERR("calloc() Fail");
+                               __ctsvc_ipc_unmarshal_composite_filter_free(filter);
+                               return CONTACTS_ERROR_OUT_OF_MEMORY;
                        }
-                       if (__ctsvc_ipc_unmarshal_attribute_filter(ipc_data, filter_type, attr_filter) != CONTACTS_ERROR_NONE) {
-                               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                               ret =  CONTACTS_ERROR_INVALID_PARAMETER;
+                       if (CONTACTS_ERROR_NONE != __ctsvc_ipc_unmarshal_attribute_filter(ipc_data, filter_type, attr_filter)) {
+                               CTS_ERR("__ctsvc_ipc_unmarshal_attribute_filter() Fail");
                                CONTACTS_FREE(attr_filter);
-                               goto ERROR_RETURN;
+                               __ctsvc_ipc_unmarshal_composite_filter_free(filter);
+                               return CONTACTS_ERROR_IPC;
                        }
                        filter->filters = g_slist_append(filter->filters,attr_filter);
                }
        }
 
        // filters
-       if (ctsvc_ipc_unmarshal_int(ipc_data,&count) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               ret =  CONTACTS_ERROR_INVALID_PARAMETER;
-               goto ERROR_RETURN;
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data, &count)) {
+               CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
+               __ctsvc_ipc_unmarshal_composite_filter_free(filter);
+               return CONTACTS_ERROR_IPC;
        }
 
        for (i=0;i<count;i++) {
-               if (ctsvc_ipc_unmarshal_int(ipc_data,(int*)&op) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                       ret =  CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data, (int *)&op)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
+                       __ctsvc_ipc_unmarshal_composite_filter_free(filter);
+                       return CONTACTS_ERROR_IPC;
                }
                filter->filter_ops = g_slist_append(filter->filter_ops, (void*)op);
        }
@@ -245,23 +244,19 @@ static int __ctsvc_ipc_unmarshal_composite_filter(const pims_ipc_data_h ipc_data
        filter->properties = (property_info_s *)ctsvc_view_get_all_property_infos(filter->view_uri, &filter->property_count);
 
        return CONTACTS_ERROR_NONE;
-
-ERROR_RETURN:
-       __ctsvc_ipc_unmarshal_composite_filter_free(filter);
-       return ret;
 }
 
 static int __ctsvc_ipc_marshal_composite_filter(const ctsvc_composite_filter_s* filter, pims_ipc_data_h ipc_data)
 {
-       if (ctsvc_ipc_marshal_int((filter->filter_type),ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int((filter->filter_type),ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
        // view_uri
        int length = strlen(filter->view_uri);
        if (pims_ipc_data_put(ipc_data,(void*)filter->view_uri,length+1) < 0) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+               CTS_ERR("pims_ipc_data_put() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
        // filter->filters
@@ -270,22 +265,22 @@ static int __ctsvc_ipc_marshal_composite_filter(const ctsvc_composite_filter_s*
                GSList *cursor = filter->filters;
                ctsvc_filter_s* child_filter;
 
-               if (ctsvc_ipc_marshal_int(count,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(count,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                while (cursor) {
                        child_filter = (ctsvc_filter_s*)cursor->data;
 
                        if (child_filter->filter_type == CTSVC_FILTER_COMPOSITE) {
-                               if (__ctsvc_ipc_marshal_composite_filter((ctsvc_composite_filter_s*)child_filter, ipc_data) != CONTACTS_ERROR_NONE) {
-                                       CTS_ERR("__ctsvc_ipc_marshal_composite_filter fail");
+                               if (CONTACTS_ERROR_NONE != __ctsvc_ipc_marshal_composite_filter((ctsvc_composite_filter_s*)child_filter, ipc_data)) {
+                                       CTS_ERR("__ctsvc_ipc_marshal_composite_filter() Fail");
                                        return CONTACTS_ERROR_INVALID_PARAMETER;
                                }
                        }
                        else {
-                               if (__ctsvc_ipc_marshal_attribute_filter((ctsvc_attribute_filter_s*)child_filter, ipc_data) != CONTACTS_ERROR_NONE) {
-                                       CTS_ERR("__ctsvc_ipc_marshal_attribute_filter fail");
+                               if (CONTACTS_ERROR_NONE != __ctsvc_ipc_marshal_attribute_filter((ctsvc_attribute_filter_s*)child_filter, ipc_data)) {
+                                       CTS_ERR("__ctsvc_ipc_marshal_attribute_filter() Fail");
                                        return CONTACTS_ERROR_INVALID_PARAMETER;
                                }
                        }
@@ -293,8 +288,8 @@ static int __ctsvc_ipc_marshal_composite_filter(const ctsvc_composite_filter_s*
                }
        }
        else {
-               if (ctsvc_ipc_marshal_int(0,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(0,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
@@ -303,15 +298,15 @@ static int __ctsvc_ipc_marshal_composite_filter(const ctsvc_composite_filter_s*
                int count = g_slist_length(filter->filter_ops);
                GSList *cursor = filter->filter_ops;
 
-               if (ctsvc_ipc_marshal_int(count,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(count,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                while (cursor) {
                        contacts_filter_operator_e op = (contacts_filter_operator_e)cursor->data;
 
-                       if (ctsvc_ipc_marshal_int(op,ipc_data) != CONTACTS_ERROR_NONE) {
-                               CTS_ERR("_ctsvc_ipc_marshal fail");
+                       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(op,ipc_data)) {
+                               CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                                return CONTACTS_ERROR_INVALID_PARAMETER;
                        }
 
@@ -319,8 +314,8 @@ static int __ctsvc_ipc_marshal_composite_filter(const ctsvc_composite_filter_s*
                }
        }
        else {
-               if (ctsvc_ipc_marshal_int(0,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(0,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
@@ -333,42 +328,42 @@ static int __ctsvc_ipc_marshal_composite_filter(const ctsvc_composite_filter_s*
 static int __ctsvc_ipc_unmarshal_attribute_filter(const pims_ipc_data_h ipc_data, const ctsvc_filter_type_e filter_type, ctsvc_attribute_filter_s* filter)
 {
        filter->filter_type = filter_type;
-       if (ctsvc_ipc_unmarshal_int(ipc_data,&filter->property_id) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data,&filter->property_id)) {
+               CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
-       if (ctsvc_ipc_unmarshal_int(ipc_data,&filter->match) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data,&filter->match)) {
+               CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
        switch(filter->filter_type) {
        case CTSVC_FILTER_STR:
-               if (ctsvc_ipc_unmarshal_string(ipc_data,&filter->value.s) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_string(ipc_data,&filter->value.s)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_string() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_INT:
-               if (ctsvc_ipc_unmarshal_int(ipc_data,&filter->value.i) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data,&filter->value.i)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_BOOL:
-               if (ctsvc_ipc_unmarshal_bool(ipc_data,&filter->value.b) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_bool(ipc_data,&filter->value.b)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_bool() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_DOUBLE:
-               if (ctsvc_ipc_unmarshal_double(ipc_data,&filter->value.d) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_double(ipc_data,&filter->value.d)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_double() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_LLI:
-               if (ctsvc_ipc_unmarshal_lli(ipc_data,&filter->value.l) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_lli(ipc_data,&filter->value.l)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_lli() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
@@ -380,46 +375,46 @@ static int __ctsvc_ipc_unmarshal_attribute_filter(const pims_ipc_data_h ipc_data
 
 static int __ctsvc_ipc_marshal_attribute_filter(const ctsvc_attribute_filter_s* filter, pims_ipc_data_h ipc_data)
 {
-       if (ctsvc_ipc_marshal_int((filter->filter_type),ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int((filter->filter_type),ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
-       if (ctsvc_ipc_marshal_int((filter->property_id),ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int((filter->property_id),ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
-       if (ctsvc_ipc_marshal_int((filter->match),ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int((filter->match),ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
        switch(filter->filter_type) {
        case CTSVC_FILTER_STR:
-               if (ctsvc_ipc_marshal_string((filter->value.s),ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_string((filter->value.s),ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_string() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_INT:
-               if (ctsvc_ipc_marshal_int((filter->value.i),ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int((filter->value.i),ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_BOOL:
-               if (ctsvc_ipc_marshal_bool((filter->value.b),ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_bool((filter->value.b),ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_bool() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_DOUBLE:
-               if (ctsvc_ipc_marshal_double((filter->value.d),ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_double((filter->value.d),ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_double() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
        case CTSVC_FILTER_LLI:
-               if (ctsvc_ipc_marshal_lli((filter->value.l),ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_lli((filter->value.l),ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_lli() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
                break;
@@ -440,8 +435,8 @@ int ctsvc_ipc_unmarshal_record(const pims_ipc_data_h ipc_data, contacts_record_h
 
        RETVM_IF(NULL == precord || NULL == ipc_data, CONTACTS_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
-       if (ctsvc_ipc_unmarshal_record_common(ipc_data, &common) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("ctsvc_ipc_unmarshal_common fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_record_common(ipc_data, &common)) {
+               CTS_ERR("ctsvc_ipc_unmarshal_record_common() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -453,8 +448,8 @@ int ctsvc_ipc_unmarshal_record(const pims_ipc_data_h ipc_data, contacts_record_h
        }
 
        ret = contacts_record_create(common.view_uri, precord);
-       if (ret != CONTACTS_ERROR_NONE) {
-               CTS_ERR("create activity record fail");
+       if (CONTACTS_ERROR_NONE != ret) {
+               CTS_ERR("contacts_record_create() Fail");
                free(common.properties_flags);
                return ret;
        }
@@ -480,8 +475,8 @@ int ctsvc_ipc_marshal_record(const contacts_record_h record, pims_ipc_data_h ipc
 
        ctsvc_record_s *common = (ctsvc_record_s*)(record);
 
-       if (ctsvc_ipc_marshal_record_common(common, ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("ctsvc_ipc_marshal_common fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_record_common(common, ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_record_common() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -525,7 +520,7 @@ int ctsvc_ipc_unmarshal_string(const pims_ipc_data_h ipc_data, char** ppbufchar)
 
        tmp = pims_ipc_data_get(ipc_data,&size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get string fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
        length = *(int*)tmp;
@@ -553,7 +548,7 @@ int ctsvc_ipc_unmarshal_int(const pims_ipc_data_h data, int *pout)
        unsigned int size = 0;
        void *tmp = pims_ipc_data_get(data,&size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get int fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_NO_DATA;
        }
        else {
@@ -570,7 +565,7 @@ int ctsvc_ipc_unmarshal_unsigned_int(const pims_ipc_data_h data, unsigned int *p
        unsigned int size = 0;
        void *tmp = pims_ipc_data_get(data,&size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get unsigned int fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_NO_DATA;
        }
        else {
@@ -587,7 +582,7 @@ int ctsvc_ipc_unmarshal_bool(const pims_ipc_data_h data, bool *pout)
        unsigned int size = 0;
        void *tmp = pims_ipc_data_get(data,&size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get bool fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_NO_DATA;
        }
        else {
@@ -604,7 +599,7 @@ int ctsvc_ipc_unmarshal_lli(const pims_ipc_data_h data, long long int *pout)
        unsigned int size = 0;
        void *tmp = pims_ipc_data_get(data,&size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get lli fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_NO_DATA;
        }
        else {
@@ -621,7 +616,7 @@ int ctsvc_ipc_unmarshal_long(const pims_ipc_data_h data, long *pout)
        unsigned int size = 0;
        void *tmp = pims_ipc_data_get(data, &size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get long fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_NO_DATA;
        }
        else {
@@ -638,7 +633,7 @@ int ctsvc_ipc_unmarshal_double(const pims_ipc_data_h data, double *pout)
        unsigned int size = 0;
        void* tmp = pims_ipc_data_get(data,&size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get double fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_NO_DATA;
        }
        else {
@@ -656,7 +651,7 @@ int ctsvc_ipc_unmarshal_record_common(const pims_ipc_data_h ipc_data, ctsvc_reco
        RETV_IF(ipc_data==NULL,CONTACTS_ERROR_NO_DATA);
        tmp = pims_ipc_data_get(ipc_data,&size);
        if (tmp == NULL) {
-               CTS_ERR("pims_ipc_data_get fail");
+               CTS_ERR("pims_ipc_data_get() Fail");
                return CONTACTS_ERROR_NO_DATA;
        }
        else {
@@ -672,7 +667,7 @@ int ctsvc_ipc_unmarshal_record_common(const pims_ipc_data_h ipc_data, ctsvc_reco
                tmp_properties_flags = (unsigned char*)pims_ipc_data_get(ipc_data, &size);
                common->properties_flags  = calloc(common->property_max_count, sizeof(char));
                if (common->properties_flags == NULL) {
-                       CTS_ERR("calloc fail");
+                       CTS_ERR("calloc() Fail");
                        return CONTACTS_ERROR_OUT_OF_MEMORY;
                }
                memcpy(common->properties_flags, tmp_properties_flags, sizeof(char)*common->property_max_count);
@@ -782,7 +777,7 @@ int ctsvc_ipc_marshal_record_common(const ctsvc_record_s* common, pims_ipc_data_
 
        int length = strlen(common->view_uri);
        if (pims_ipc_data_put(ipc_data,(void*)common->view_uri,length+1) < 0) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+               CTS_ERR("pims_ipc_data_put() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -792,7 +787,7 @@ int ctsvc_ipc_marshal_record_common(const ctsvc_record_s* common, pims_ipc_data_
 
        if (0 < common->property_max_count) {
                if (pims_ipc_data_put(ipc_data,(void*)common->properties_flags,sizeof(unsigned char)*common->property_max_count) < 0) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+                       CTS_ERR("pims_ipc_data_put() Fail");
                        return CONTACTS_ERROR_NO_DATA;
                }
        }
@@ -803,113 +798,116 @@ int ctsvc_ipc_marshal_record_common(const ctsvc_record_s* common, pims_ipc_data_
        return CONTACTS_ERROR_NONE;
 }
 
-int ctsvc_ipc_unmarshal_query(const pims_ipc_data_h ipc_data, contacts_query_h *query)
+int ctsvc_ipc_unmarshal_query(const pims_ipc_data_h ipc_data, contacts_query_h *out_query)
 {
-       ctsvc_query_s *que = NULL;
+       ctsvc_query_s *query = NULL;
        unsigned int size = 0;
        char* str = NULL;
        unsigned int count = 0, i = 0;
        int ret = CONTACTS_ERROR_NONE;
 
-       RETV_IF(NULL == query, CONTACTS_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == out_query, CONTACTS_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == ipc_data, CONTACTS_ERROR_INVALID_PARAMETER);
 
        // view_uri
-       str = (char*)pims_ipc_data_get(ipc_data,&size);
+       str = (char*)pims_ipc_data_get(ipc_data, &size);
 
-       ret = contacts_query_create(str, query);
-       if (ret != CONTACTS_ERROR_NONE) {
-               CTS_ERR("contacts_query_create fail");
+       ret = contacts_query_create(str, out_query);
+       if (CONTACTS_ERROR_NONE != ret) {
+               CTS_ERR("contacts_query_create() Fail");
                return ret;
        }
+       query = (ctsvc_query_s *)*out_query;
 
-       que = (ctsvc_query_s *) *query;
-
-       if (ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&count) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               ret = CONTACTS_ERROR_INVALID_PARAMETER;
-               goto ERROR_RETURN;
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_unsigned_int(ipc_data, &count)) {
+               CTS_ERR("contacts_query_create() Fail");
+               contacts_query_destroy(*out_query);
+               *out_query = NULL;
+               return CONTACTS_ERROR_IPC;
        }
 
-       if (count == 0) {
-               que->filter = NULL;
+       if (0 == count) {
+               query->filter = NULL;
        }
        else {
                ctsvc_composite_filter_s *filter = NULL;
                filter = (ctsvc_composite_filter_s *)calloc(1, sizeof(ctsvc_composite_filter_s));
                if (NULL == filter) {
-                       CTS_ERR("calloc fail");
-                       ret = CONTACTS_ERROR_OUT_OF_MEMORY;
-                       goto ERROR_RETURN;
+                       CTS_ERR("calloc() Fail");
+                       contacts_query_destroy(*out_query);
+                       *out_query = NULL;
+                       return CONTACTS_ERROR_OUT_OF_MEMORY;
                }
                filter->filter_type = CTSVC_FILTER_COMPOSITE;
-               filter->properties = (property_info_s *)ctsvc_view_get_all_property_infos(que->view_uri, &filter->property_count);
-               que->filter = filter;
+               filter->properties = (property_info_s *)ctsvc_view_get_all_property_infos(query->view_uri, &filter->property_count);
+               query->filter = filter;
 
                // for filter_type
-               if (ctsvc_ipc_unmarshal_unsigned_int(ipc_data, &count) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                       ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_unsigned_int(ipc_data, &count)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_unsigned_int() Fail");
+                       contacts_query_destroy(*out_query);
+                       *out_query = NULL;
+                       return CONTACTS_ERROR_IPC;
                }
 
-               if (__ctsvc_ipc_unmarshal_composite_filter(ipc_data,que->filter) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                       ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != __ctsvc_ipc_unmarshal_composite_filter(ipc_data, query->filter)) {
+                       CTS_ERR("__ctsvc_ipc_unmarshal_composite_filter() Fail");
+                       contacts_query_destroy(*out_query);
+                       *out_query = NULL;
+                       return CONTACTS_ERROR_IPC;
                }
        }
 
-       if (ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&(que->projection_count)) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               ret = CONTACTS_ERROR_INVALID_PARAMETER;
-               goto ERROR_RETURN;
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_unsigned_int(ipc_data, &(query->projection_count))) {
+               CTS_ERR("ctsvc_ipc_unmarshal_unsigned_int() Fail");
+               contacts_query_destroy(*out_query);
+               *out_query = NULL;
+               return CONTACTS_ERROR_IPC;
        }
 
-       if (0 < que->projection_count) {
-               que->projection = (unsigned int*)malloc(sizeof(unsigned int)*que->projection_count);
-               if (que->projection == NULL) {
-                       CTS_ERR("malloc fail");
-                       ret = CONTACTS_ERROR_OUT_OF_MEMORY;
-                       goto ERROR_RETURN;
+       if (0 < query->projection_count) {
+               query->projection = (unsigned int*)malloc(sizeof(unsigned int)*query->projection_count);
+               if (query->projection == NULL) {
+                       CTS_ERR("malloc() Fail");
+                       contacts_query_destroy(*out_query);
+                       *out_query = NULL;
+                       return CONTACTS_ERROR_OUT_OF_MEMORY;
                }
-               for (i=0;i<que->projection_count;i++) {
-                       if (ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&(que->projection[i])) != CONTACTS_ERROR_NONE) {
-                               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                               ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                               goto ERROR_RETURN;
+               for (i=0;i<query->projection_count;i++) {
+                       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&(query->projection[i]))) {
+                               CTS_ERR("ctsvc_ipc_unmarshal_unsigned_int() Fail");
+                               contacts_query_destroy(*out_query);
+                               *out_query = NULL;
+                               return CONTACTS_ERROR_IPC;
                        }
                }
        }
        else {
-               que->projection = NULL;
+               query->projection = NULL;
        }
 
-       if (ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&(que->sort_property_id)) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               ret = CONTACTS_ERROR_INVALID_PARAMETER;
-               goto ERROR_RETURN;
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&(query->sort_property_id))) {
+               CTS_ERR("ctsvc_ipc_unmarshal_unsigned_int() Fail");
+               contacts_query_destroy(*out_query);
+               *out_query = NULL;
+               return CONTACTS_ERROR_IPC;
        }
 
-       if (ctsvc_ipc_unmarshal_bool(ipc_data,&(que->sort_asc)) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               ret = CONTACTS_ERROR_INVALID_PARAMETER;
-               goto ERROR_RETURN;
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_bool(ipc_data,&(query->sort_asc))) {
+               CTS_ERR("ctsvc_ipc_unmarshal_bool() Fail");
+               contacts_query_destroy(*out_query);
+               *out_query = NULL;
+               return CONTACTS_ERROR_IPC;
        }
 
-       if (ctsvc_ipc_unmarshal_bool(ipc_data,&(que->distinct)) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               ret = CONTACTS_ERROR_INVALID_PARAMETER;
-               goto ERROR_RETURN;
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_bool(ipc_data,&(query->distinct))) {
+               CTS_ERR("ctsvc_ipc_unmarshal_bool() Fail");
+               contacts_query_destroy(*out_query);
+               *out_query = NULL;
+               return CONTACTS_ERROR_IPC;
        }
 
        return CONTACTS_ERROR_NONE;
-
-ERROR_RETURN:
-       contacts_query_destroy(*query);
-       *query = NULL;
-
-       return ret;
 }
 
 int ctsvc_ipc_marshal_query(const contacts_query_h query, pims_ipc_data_h ipc_data)
@@ -925,51 +923,51 @@ int ctsvc_ipc_marshal_query(const contacts_query_h query, pims_ipc_data_h ipc_da
        //view_uri
        length = strlen(que->view_uri);
        if (pims_ipc_data_put(ipc_data,(void*)que->view_uri,length+1) < 0) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+               CTS_ERR("pims_ipc_data_put() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
        if (que->filter) {
-               if (ctsvc_ipc_marshal_int(1,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(1,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
 
-               if (__ctsvc_ipc_marshal_composite_filter(que->filter,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != __ctsvc_ipc_marshal_composite_filter(que->filter,ipc_data)) {
+                       CTS_ERR("__ctsvc_ipc_marshal_composite_filter() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
        else {
-               if (ctsvc_ipc_marshal_int(0,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(0,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
 
-       if (ctsvc_ipc_marshal_unsigned_int(que->projection_count,ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_unsigned_int(que->projection_count,ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_unsigned_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
        for (i=0;i<que->projection_count;i++) {
-               if (ctsvc_ipc_marshal_unsigned_int(que->projection[i],ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_unsigned_int(que->projection[i],ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_unsigned_int() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
 
-       if (ctsvc_ipc_marshal_unsigned_int(que->sort_property_id,ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_unsigned_int(que->sort_property_id,ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_unsigned_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (ctsvc_ipc_marshal_bool(que->sort_asc,ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_bool(que->sort_asc,ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_bool() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
-       if (ctsvc_ipc_marshal_bool(que->distinct,ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_bool(que->distinct,ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_bool() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -983,67 +981,64 @@ int ctsvc_ipc_unmarshal_list(const pims_ipc_data_h ipc_data, contacts_list_h* li
        int count = 0;
        unsigned int deleted_count = 0;
        contacts_record_h record;
-       int ret = CONTACTS_ERROR_NONE;
 
        RETV_IF(NULL == list, CONTACTS_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == ipc_data, CONTACTS_ERROR_INVALID_PARAMETER);
 
-       if (contacts_list_create(list) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("contacts_list_create fail");
+       if (CONTACTS_ERROR_NONE != contacts_list_create(list)) {
+               CTS_ERR("contacts_list_create() Fail");
                return CONTACTS_ERROR_OUT_OF_MEMORY;
        }
 
-       if (ctsvc_ipc_unmarshal_int(ipc_data,&(count)) != CONTACTS_ERROR_NONE) {
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data, &(count))) {
+               CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
                contacts_list_destroy(*list, true);
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               return CONTACTS_ERROR_INVALID_PARAMETER;
+               *list = NULL;
+               return CONTACTS_ERROR_IPC;
        }
 
        unsigned int i = 0;
        for (i=0;i<count;i++) {
-               if (ctsvc_ipc_unmarshal_record(ipc_data,&record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                       ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_record(ipc_data, &record)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_record() Fail");
+                       contacts_list_destroy(*list, true);
+                       *list = NULL;
+                       return CONTACTS_ERROR_IPC;
                }
 
-               if (contacts_list_add(*list,record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("contacts_list_add fail");
-                       ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != contacts_list_add(*list, record)) {
+                       CTS_ERR("contacts_list_add() Fail");
+                       contacts_list_destroy(*list, true);
+                       *list = NULL;
+                       return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
 
-       if (ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&deleted_count) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_unmarshal fail");
-               ret = CONTACTS_ERROR_INVALID_PARAMETER;
-               goto ERROR_RETURN;
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_unsigned_int(ipc_data, &deleted_count)) {
+               CTS_ERR("ctsvc_ipc_unmarshal_unsigned_int() Fail");
+               contacts_list_destroy(*list, true);
+               *list = NULL;
+               return CONTACTS_ERROR_IPC;
        }
 
        i = 0;
        for (i=0;i<deleted_count;i++) {
-               if (ctsvc_ipc_unmarshal_record(ipc_data,&record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_unmarshal fail");
-                       ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_record(ipc_data, &record)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_record() Fail");
+                       contacts_list_destroy(*list, true);
+                       *list = NULL;
+                       return CONTACTS_ERROR_IPC;
                }
 
-               if (ctsvc_list_append_deleted_record(*list,record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("contacts_list_add fail");
-                       ret = CONTACTS_ERROR_INVALID_PARAMETER;
-                       goto ERROR_RETURN;
+               if (CONTACTS_ERROR_NONE != ctsvc_list_append_deleted_record(*list, record)) {
+                       CTS_ERR("ctsvc_list_append_deleted_record() Fail");
+                       contacts_list_destroy(*list, true);
+                       *list = NULL;
+                       return CONTACTS_ERROR_IPC;
                }
        }
 
        return CONTACTS_ERROR_NONE;
-
-ERROR_RETURN:
-       if (*list) {
-               contacts_list_destroy(*list, true);
-               *list = NULL;
-       }
-
-       return ret;
 }
 
 int ctsvc_ipc_unmarshal_child_list(const pims_ipc_data_h ipc_data, contacts_list_h* list)
@@ -1056,37 +1051,37 @@ int ctsvc_ipc_unmarshal_child_list(const pims_ipc_data_h ipc_data, contacts_list
        RETV_IF(NULL == list, CONTACTS_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == ipc_data, CONTACTS_ERROR_INVALID_PARAMETER);
 
-       if (ctsvc_ipc_unmarshal_int(ipc_data,&(count)) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("ctsvc_ipc_unmarshal_int fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_int(ipc_data,&(count))) {
+               CTS_ERR("ctsvc_ipc_unmarshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
        for (i=0;i<count;i++) {
-               if (ctsvc_ipc_unmarshal_record(ipc_data,&record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("ctsvc_ipc_unmarshal_record fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_record(ipc_data,&record)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_record() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
 
-               if (contacts_list_add(*list,record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("contacts_list_add fail");
+               if (CONTACTS_ERROR_NONE != contacts_list_add(*list,record)) {
+                       CTS_ERR("contacts_list_add() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
 
-       if (ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&deleted_count) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("ctsvc_ipc_unmarshal_unsigned_int fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_unsigned_int(ipc_data,&deleted_count)) {
+               CTS_ERR("ctsvc_ipc_unmarshal_unsigned_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
        i = 0;
        for (i=0;i<deleted_count;i++) {
-               if (ctsvc_ipc_unmarshal_record(ipc_data,&record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("ctsvc_ipc_unmarshal_record fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_unmarshal_record(ipc_data,&record)) {
+                       CTS_ERR("ctsvc_ipc_unmarshal_record() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
 
-               if (ctsvc_list_append_deleted_record(*list,record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("ctsvc_list_append_deleted_record fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_list_append_deleted_record(*list,record)) {
+                       CTS_ERR("ctsvc_list_append_deleted_record() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
@@ -1104,12 +1099,12 @@ int ctsvc_ipc_marshal_list(const contacts_list_h list, pims_ipc_data_h ipc_data)
        RETV_IF(NULL == ipc_data, CONTACTS_ERROR_INVALID_PARAMETER);
 
        // count
-       if (contacts_list_get_count(list, &count) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("contacts_list_get_count fail");
+       if (CONTACTS_ERROR_NONE != contacts_list_get_count(list, &count)) {
+               CTS_ERR("contacts_list_get_count() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
-       if (ctsvc_ipc_marshal_int(count,ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(count,ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
@@ -1117,37 +1112,37 @@ int ctsvc_ipc_marshal_list(const contacts_list_h list, pims_ipc_data_h ipc_data)
 
        unsigned int i = 0;
        for (i=0;i<count;i++) {
-               if (contacts_list_get_current_record_p(list,&record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("contacts_list_get_count fail");
+               if (CONTACTS_ERROR_NONE != contacts_list_get_current_record_p(list,&record)) {
+                       CTS_ERR("contacts_list_get_current_record_p() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
-               if (ctsvc_ipc_marshal_record(record,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_record(record,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_record() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
-               if (contacts_list_next(list) == CONTACTS_ERROR_NO_DATA) {
+               if (CONTACTS_ERROR_NO_DATA == contacts_list_next(list)) {
                        break;
                }
        }
 
        // count
-       if (ctsvc_list_get_deleted_count(list, &deleted_count) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("contacts_list_get_count fail");
+       if (ctsvc_list_get_deleted_count(list, &deleted_count)) {
+               CTS_ERR("ctsvc_list_get_deleted_count() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
-       if (ctsvc_ipc_marshal_int(deleted_count,ipc_data) != CONTACTS_ERROR_NONE) {
-               CTS_ERR("_ctsvc_ipc_marshal fail");
+       if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_int(deleted_count,ipc_data)) {
+               CTS_ERR("ctsvc_ipc_marshal_int() Fail");
                return CONTACTS_ERROR_INVALID_PARAMETER;
        }
 
        i = 0;
        for (i=0;i<deleted_count;i++) {
-               if (ctsvc_list_get_deleted_nth_record_p(list, i, &record) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("contacts_list_get_count fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_list_get_deleted_nth_record_p(list, i, &record)) {
+                       CTS_ERR("ctsvc_list_get_deleted_nth_record_p() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
-               if (ctsvc_ipc_marshal_record(record,ipc_data) != CONTACTS_ERROR_NONE) {
-                       CTS_ERR("_ctsvc_ipc_marshal fail");
+               if (CONTACTS_ERROR_NONE != ctsvc_ipc_marshal_record(record,ipc_data)) {
+                       CTS_ERR("ctsvc_ipc_marshal_record() Fail");
                        return CONTACTS_ERROR_INVALID_PARAMETER;
                }
        }
index 2ff18f1..a66f399 100644 (file)
@@ -142,7 +142,6 @@ int ctsvc_convert_japanese_to_hiragana_unicode(UChar *src, UChar *dest, int dest
 
 int ctsvc_convert_japanese_to_hiragana(const char *src, char **dest)
 {
-       int ret = CONTACTS_ERROR_NONE;
        UChar *tmp_result = NULL;
        UChar *result = NULL;
        UErrorCode status = 0;
@@ -151,44 +150,60 @@ int ctsvc_convert_japanese_to_hiragana(const char *src, char **dest)
        u_strFromUTF8(NULL, 0, &size, src, strlen(src), &status);
        if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) {
                CTS_ERR("u_strFromUTF8 to get the dest length Failed(%s)", u_errorName(status));
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto DATA_FREE;
+               return CONTACTS_ERROR_SYSTEM;
        }
        status = U_ZERO_ERROR;
        tmp_result = calloc(1, sizeof(UChar) * (size + 1));
+       if (NULL == tmp_result) {
+               CTS_ERR("calloc Fail");
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
+
        u_strFromUTF8(tmp_result, size + 1, NULL, src, -1, &status);
        if (U_FAILURE(status)) {
                CTS_ERR("u_strFromUTF8 Failed(%s)", u_errorName(status));
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto DATA_FREE;
+               free(tmp_result);
+               return CONTACTS_ERROR_SYSTEM;
        }
 
        result = calloc(1, sizeof(UChar) * (size + 1));
+       if (NULL == tmp_result) {
+               CTS_ERR("calloc() Fail");
+               free(tmp_result);
+               free(result);
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
 
        ctsvc_convert_japanese_to_hiragana_unicode(tmp_result, result, size + 1);
-
        u_strToUTF8(NULL, 0, &size, result, -1, &status);
        if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) {
                CTS_ERR("u_strToUTF8 to get the dest length Failed(%s)", u_errorName(status));
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto DATA_FREE;
+               free(tmp_result);
+               free(result);
+               return CONTACTS_ERROR_SYSTEM;
        }
 
        status = U_ZERO_ERROR;
        *dest = calloc(1, sizeof(char)*(size+1));
+       if (NULL == *dest) {
+               CTS_ERR("calloc() Fail");
+               free(tmp_result);
+               free(result);
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
 
        u_strToUTF8(*dest, size + 1, &size, result, -1, &status);
-
        if (U_FAILURE(status)) {
                CTS_ERR("u_strToUTF8 Failed(%s)", u_errorName(status));
-               ret =  CONTACTS_ERROR_SYSTEM;
-               goto DATA_FREE;
+               free(tmp_result);
+               free(result);
+               free(*dest);
+               *dest = NULL;
+               return CONTACTS_ERROR_SYSTEM;
        }
 
-DATA_FREE:
        free(tmp_result);
        free(result);
-
-       return ret;
+       return CONTACTS_ERROR_NONE;
 }
 
index e37116f..0d01f5e 100644 (file)
@@ -154,7 +154,6 @@ int ctsvc_collation_str(char *src, char **dest)
 
 static int __ctsvc_normalize_str(const char *src, char **dest)
 {
-       int ret = CONTACTS_ERROR_NONE;
        int32_t tmp_size = 100;
        int32_t upper_size;
        int32_t size = 100;
@@ -164,71 +163,119 @@ static int __ctsvc_normalize_str(const char *src, char **dest)
        UChar *result = NULL;
 
        tmp_result = calloc(1, sizeof(UChar)*(tmp_size+1));
-       u_strFromUTF8(tmp_result, tmp_size + 1, &tmp_size, src, -1, &status);
+       if (NULL == tmp_result) {
+               CTS_ERR("calloc() Fail");
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
 
+       u_strFromUTF8(tmp_result, tmp_size + 1, &tmp_size, src, -1, &status);
        if (status == U_BUFFER_OVERFLOW_ERROR) {
                status = U_ZERO_ERROR;
                free(tmp_result);
                tmp_result = calloc(1, sizeof(UChar) * (tmp_size + 1));
+               if (NULL == tmp_result) {
+                       CTS_ERR("calloc() Fail");
+                       return CONTACTS_ERROR_OUT_OF_MEMORY;
+               }
+
                u_strFromUTF8(tmp_result, tmp_size + 1, NULL, src, -1, &status);
                if (U_FAILURE(status)) {
                        CTS_ERR("u_strFromUTF8()Fail(%s)", u_errorName(status));
-                       ret = CONTACTS_ERROR_SYSTEM;
-                       goto DATA_FREE;
+                       free(tmp_result);
+                       return CONTACTS_ERROR_SYSTEM;
                }
        }
        else if (U_FAILURE(status)) {
                CTS_ERR("u_strFromUTF8() Fail(%s)", u_errorName(status));
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto DATA_FREE;
+               free(tmp_result);
+               return CONTACTS_ERROR_SYSTEM;
        }
 
        tmp_upper = calloc(1, sizeof(UChar)*(tmp_size+1));
+       if (NULL == tmp_upper) {
+               CTS_ERR("calloc() Fail");
+               free(tmp_result);
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
+
        upper_size = u_strToUpper(tmp_upper, tmp_size+1, tmp_result, -1, NULL, &status);
        if (status == U_BUFFER_OVERFLOW_ERROR) {
                status = U_ZERO_ERROR;
                free(tmp_upper);
                tmp_upper = calloc(1, sizeof(UChar) * (upper_size + 1));
+               if (NULL == tmp_upper) {
+                       CTS_ERR("calloc() Fail");
+                       free(tmp_result);
+                       return CONTACTS_ERROR_OUT_OF_MEMORY;
+               }
+
                u_strFromUTF8(tmp_upper, upper_size + 1, NULL, src, -1, &status);
                if (U_FAILURE(status)) {
                        CTS_ERR("u_strFromUTF8()Fail(%s)", u_errorName(status));
-                       ret = CONTACTS_ERROR_SYSTEM;
-                       goto DATA_FREE;
+                       free(tmp_result);
+                       free(tmp_upper);
+                       return CONTACTS_ERROR_SYSTEM;
                }
        }
        else if (U_FAILURE(status)) {
                CTS_ERR("u_strToUpper() Fail(%s)", u_errorName(status));
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto DATA_FREE;
+               free(tmp_result);
+               free(tmp_upper);
+               return CONTACTS_ERROR_SYSTEM;
        }
 
        result = calloc(1, sizeof(UChar)*(size+1));
-       size = unorm_normalize(tmp_upper, -1, UNORM_NFD, 0,
-                       result, size+1, &status);
+       if (NULL == result) {
+               CTS_ERR("calloc() Fail");
+               free(tmp_result);
+               free(tmp_upper);
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
+
+       size = unorm_normalize(tmp_upper, -1, UNORM_NFD, 0, result, size+1, &status);
        if (status == U_BUFFER_OVERFLOW_ERROR) {
                status = U_ZERO_ERROR;
                free(result);
                result = calloc(1, sizeof(UChar)*(size + 1));
+               if (NULL == result) {
+                       CTS_ERR("calloc() Fail");
+                       free(tmp_result);
+                       free(tmp_upper);
+                       return CONTACTS_ERROR_OUT_OF_MEMORY;
+               }
+
                unorm_normalize(tmp_upper, -1, UNORM_NFD, 0, result, size+1, &status);
                if (U_FAILURE(status)) {
                        CTS_ERR("unorm_normalize() Fail(%s)", u_errorName(status));
-                       ret = CONTACTS_ERROR_SYSTEM;
-                       goto DATA_FREE;
+                       free(tmp_result);
+                       free(tmp_upper);
+                       free(result);
+                       return CONTACTS_ERROR_SYSTEM;
                }
        }
        else if (U_FAILURE(status)) {
                CTS_ERR("unorm_normalize() Fail(%s)", u_errorName(status));
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto DATA_FREE;
+               free(tmp_result);
+               free(tmp_upper);
+               free(result);
+               return CONTACTS_ERROR_SYSTEM;
        }
 
-       ret = ctsvc_check_language(result);
+       ctsvc_check_language(result);
        ctsvc_extra_normalize(result, size);
 
        // remove diacritical : U+3000 ~ U+034F
        int i, j;
        UChar *temp_result = NULL;
        temp_result = calloc(1, sizeof(UChar)*(size+1));
+       if (NULL == temp_result) {
+               CTS_ERR("calloc() Fail");
+               free(tmp_result);
+               free(tmp_upper);
+               free(result);
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
+
        bool replaced = false;
        for (i=0,j=0; i<size;i++) {
                if (CTSVC_COMPARE_BETWEEN((UChar)CTSVC_COMBINING_DIACRITICAL_MARKS_START,
@@ -250,21 +297,28 @@ static int __ctsvc_normalize_str(const char *src, char **dest)
        u_strToUTF8(NULL, 0, &size, result, -1, &status);
        status = U_ZERO_ERROR;
        *dest = calloc(1, sizeof(char) * (size+1));
+       if (NULL == *dest) {
+               CTS_ERR("calloc() Fail");
+               free(tmp_result);
+               free(tmp_upper);
+               free(result);
+               return CONTACTS_ERROR_OUT_OF_MEMORY;
+       }
 
        u_strToUTF8(*dest, size+1, NULL, result, -1, &status);
        if (U_FAILURE(status)) {
                CTS_ERR("u_strToUTF8() Fail(%s)", u_errorName(status));
-               ret = CONTACTS_ERROR_SYSTEM;
                free(*dest);
                *dest = NULL;
-               goto DATA_FREE;
+               free(tmp_result);
+               free(tmp_upper);
+               free(result);
+               return CONTACTS_ERROR_SYSTEM;
        }
-
-DATA_FREE:
        free(tmp_result);
        free(tmp_upper);
        free(result);
-       return ret;
+       return CONTACTS_ERROR_NONE;
 }
 
 static int __ctsvc_convert_halfwidth_ascii_and_symbol(const char *src, UChar *dest, int dest_size, int* str_size)
@@ -335,7 +389,7 @@ int ctsvc_get_halfwidth_string(const char *src, char** dest, int* dest_size)
        UChar unicodes[LARGE_BUFFER_SIZE+1];
        int ustr_size = 0;
 
-       if (__ctsvc_convert_halfwidth_ascii_and_symbol(src, unicodes, LARGE_BUFFER_SIZE, &ustr_size) != CONTACTS_ERROR_NONE) {
+       if (CONTACTS_ERROR_NONE != __ctsvc_convert_halfwidth_ascii_and_symbol(src, unicodes, LARGE_BUFFER_SIZE, &ustr_size)) {
                CTS_ERR("convert to halfwidth Fail! %s ", src);
 
                return CONTACTS_ERROR_SYSTEM;
@@ -416,7 +470,8 @@ int ctsvc_normalize_index(const char *src, char **dest)
 
        if (first_str[0] == '\0' || __ctsvc_check_range_out_index(first_str)) {
                length = ctsvc_check_utf8(src[0]);
-               RETVM_IF(length <= 0, CONTACTS_ERROR_INTERNAL, "check_utf8 is Fail");
+
+               RETVM_IF(length <= 0, CONTACTS_ERROR_INTERNAL, "check_utf8() Fail");
                memset(first_str,0x00, sizeof(first_str));
                strncpy(first_str, src, length);
                if (length != strlen(first_str)) {
@@ -425,7 +480,8 @@ int ctsvc_normalize_index(const char *src, char **dest)
                }
        }
        ret = __ctsvc_normalize_str(first_str, dest);
-       RETVM_IF(dest == NULL, ret, "__ctsvc_normalize_str is Fail");
+
+       RETVM_IF(dest == NULL, ret, "__ctsvc_normalize_str() Fail");
 
        if ((*dest)[0] != '\0') {
                length = ctsvc_check_utf8((*dest)[0]);
index 8b93c6d..4ff837c 100644 (file)
@@ -393,15 +393,19 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result,
 
        if (NULL == sim_info) {
                CTS_ERR("sim_info is NULL, result = %d", access_rt);
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto ERROR_RETURN;
+               ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+               WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+               __ctsvc_server_sim_set_return_data(NULL);
+               return;
        }
 
        info = __ctsvc_server_sim_get_handle_by_tapi_handle(handle);
        if (info == NULL) {
-               CTS_ERR("__ctsvc_server_sim_get_handle_by_tapi_handle fail");
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto ERROR_RETURN;
+               CTS_ERR("__ctsvc_server_sim_get_handle_by_tapi_handle() Fail");
+               ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+               WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+               __ctsvc_server_sim_set_return_data(NULL);
+               return;
        }
 
        if (access_rt == TAPI_SIM_PB_INVALID_INDEX) {
@@ -413,22 +417,28 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result,
                if (info->file_record[TAPI_PB_3G_NAME].index_max < start_index) {
                        CTS_ERR("start_index is invalid start_index = %d, total = %d", start_index,
                                                info->file_record[TAPI_PB_3G_NAME].index_max);
-                       ret = CONTACTS_ERROR_SYSTEM;
-                       goto ERROR_RETURN;
+                       ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+                       WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+                       __ctsvc_server_sim_set_return_data(NULL);
+                       return;
                }
                ret = tel_read_sim_pb_record(handle, info->sim_type, start_index,
                                        __ctsvc_server_sim_import_contact_cb, (void*)start_index);
                if (ret != TAPI_API_SUCCESS) {
                        CTS_ERR("SIM phonebook access Fail(%d) start_indext(%d)", access_rt,start_index);
-                       ret = CONTACTS_ERROR_SYSTEM;
-                       goto ERROR_RETURN;
+                       ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+                       WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+                       __ctsvc_server_sim_set_return_data(NULL);
+                       return;
                }
        }
 
        if (TAPI_SIM_PB_SUCCESS != access_rt) {
                CTS_ERR("SIM phonebook access Fail(%d)", access_rt);
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto ERROR_RETURN;
+               ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+               WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+               __ctsvc_server_sim_set_return_data(NULL);
+               return;
        }
 
        switch (sim_info->phonebook_type) {
@@ -441,8 +451,10 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result,
        case TAPI_SIM_PB_SDN:
        default:
                CTS_ERR("Unknown storage type(%d)", sim_info->phonebook_type);
-               ret = CONTACTS_ERROR_SYSTEM;
-               goto ERROR_RETURN;
+               ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+               WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+               __ctsvc_server_sim_set_return_data(NULL);
+               return;
        }
 
        if (sim_info->next_index && CTSVC_TAPI_SIM_PB_MAX != sim_info->next_index) {
@@ -451,28 +463,23 @@ static void __ctsvc_server_sim_import_contact_cb(TapiHandle *handle, int result,
                                sim_info->next_index, __ctsvc_server_sim_import_contact_cb, NULL);
                if (TAPI_API_SUCCESS != ret) {
                        CTS_ERR("tel_read_sim_pb_record() Fail(%d)", ret);
-                       ret = CONTACTS_ERROR_SYSTEM;
-                       goto ERROR_RETURN;
+                       ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+                       WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+                       __ctsvc_server_sim_set_return_data(NULL);
+                       return;
                }
        }
        else {
                // insert imported contact to DB
                __ctsvc_server_sim_insert_records_to_db(info);
-               if (__ctsvc_server_sim_get_return_data()) {
-                       ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), CONTACTS_ERROR_NONE, 0, NULL);
-                       WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
-                       __ctsvc_server_sim_set_return_data(NULL);
-               }
-       }
-       return;
-
-ERROR_RETURN:
-       if (__ctsvc_server_sim_get_return_data()) {
                ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
                WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
                __ctsvc_server_sim_set_return_data(NULL);
        }
-       return;
+
+       ret = ctsvc_server_socket_return(__ctsvc_server_sim_get_return_data(), ret, 0, NULL);
+       WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_socket_return() Fail(%d)", ret);
+       __ctsvc_server_sim_set_return_data(NULL);
 }
 
 int ctsvc_server_sim_import_contact(void* data, int sim_slot_no)
@@ -536,7 +543,8 @@ static void __ctsvc_server_sim_sdn_read_cb(TapiHandle *handle, int result, void
                        RETM_IF(ret != TAPI_API_SUCCESS,  "tel_read_sim_pb_record() Fail(%d)", ret);
                }
                CTS_ERR("SIM phonebook access Fail(%d)", sec_rt);
-               goto ERROR_RETURN;
+               ctsvc_server_trim_memory();
+               return;
        }
 
        switch (sim_info->phonebook_type) {
@@ -549,7 +557,8 @@ static void __ctsvc_server_sim_sdn_read_cb(TapiHandle *handle, int result, void
        case TAPI_SIM_PB_FDN:
        default:
                CTS_ERR("Not SDN type(%d)", sim_info->phonebook_type);
-               goto ERROR_RETURN;
+               ctsvc_server_trim_memory();
+               return;
        }
 
        if (sim_info->next_index && CTSVC_TAPI_SIM_PB_MAX != sim_info->next_index) {
@@ -558,15 +567,13 @@ static void __ctsvc_server_sim_sdn_read_cb(TapiHandle *handle, int result, void
                                __ctsvc_server_sim_sdn_read_cb, info);
                if (TAPI_API_SUCCESS != ret) {
                        CTS_ERR("tel_read_sim_pb_record() Fail(%d)", ret);
-                       goto ERROR_RETURN;
+                       ctsvc_server_trim_memory();
+                       return;
                }
        }
        else {
                ctsvc_server_trim_memory();
        }
-       return;
-ERROR_RETURN:
-       ctsvc_server_trim_memory();
 }
 
 static void __ctsvc_server_sim_sdn_meta_info_cb(TapiHandle *handle, int result, void *data, void *user_data)
@@ -584,13 +591,13 @@ static void __ctsvc_server_sim_sdn_meta_info_cb(TapiHandle *handle, int result,
                ret = tel_read_sim_pb_record(info->handle, TAPI_SIM_PB_SDN, 1, __ctsvc_server_sim_sdn_read_cb, info);
                if (TAPI_API_SUCCESS != ret) {
                        CTS_ERR("tel_read_sim_pb_record() Fail(%d)", ret);
-                       goto ERROR_RETURN;
+                       ctsvc_server_trim_memory();
+                       return;
                }
        }
-       else
+       else {
                CTS_ERR("pe->PbUsedCount : 0 no sdn!!!!", ret);
-
-ERROR_RETURN:
+       }
        ctsvc_server_trim_memory();
 }
 
@@ -608,7 +615,8 @@ static int __ctsvc_server_sim_sdn_read(ctsvc_sim_info_s* info)
        if (TAPI_API_SUCCESS != ret) {
                CTS_ERR("tel_get_sim_init_info() Fail(%d)", ret);
                CTS_DBG("sim_status = %d, card_changed = %d", sim_status, card_changed);
-               goto ERROR_RETURN;
+               ctsvc_server_trim_memory();
+               return CONTACTS_ERROR_SYSTEM;
        }
 
        if (TAPI_SIM_STATUS_CARD_NOT_PRESENT == sim_status ||
@@ -616,29 +624,30 @@ static int __ctsvc_server_sim_sdn_read(ctsvc_sim_info_s* info)
                ret = ctsvc_server_delete_sdn_contact(info->sim_slot_no);
                if (CONTACTS_ERROR_NONE != ret) {
                        CTS_ERR("ctsvc_server_delete_sdn_contact() Fail(%d)", ret);
-                       goto ERROR_RETURN;
+                       ctsvc_server_trim_memory();
+                       return ret;
                }
        }
        else if (TAPI_SIM_STATUS_SIM_INIT_COMPLETED == sim_status) {
                ret = ctsvc_server_delete_sdn_contact(info->sim_slot_no);
                if (CONTACTS_ERROR_NONE != ret) {
                        CTS_ERR("ctsvc_server_delete_sdn_contact() Fail(%d)", ret);
-                       goto ERROR_RETURN;
+                       ctsvc_server_trim_memory();
+                       return ret;
                }
 
                ret = tel_get_sim_pb_meta_info(info->handle, TAPI_SIM_PB_SDN, __ctsvc_server_sim_sdn_meta_info_cb, info);
                if (TAPI_API_SUCCESS != ret) {
                        CTS_ERR("tel_get_sim_pb_meta_info() Fail(%d)", ret);
-                       goto ERROR_RETURN;
+                       ctsvc_server_trim_memory();
+                       return CONTACTS_ERROR_SYSTEM;
                }
        }
-       else
+       else {
                CTS_ERR("sim_status Fail(%d)", sim_status);
-       return CONTACTS_ERROR_NONE;
+       }
 
-ERROR_RETURN:
-       ctsvc_server_trim_memory();
-       return ret;
+       return CONTACTS_ERROR_NONE;
 }
 
 static void __ctsvc_server_sim_get_meta_info_cb(TapiHandle *handle, int result, void *data, void *user_data)
@@ -745,7 +754,7 @@ static int __ctsvc_server_sim_init_meta_info(ctsvc_sim_info_s *info)
        }
 
        RETVM_IF(ret != TAPI_API_SUCCESS, CONTACTS_ERROR_SYSTEM,
-                               "tel_get_sim_(usim)_meta_info(type:%d) fail (%d)", info->sim_type, ret);
+                               "tel_get_sim_(usim)_meta_info(type:%d) Fail(%d)", info->sim_type, ret);
 
        return CONTACTS_ERROR_NONE;
 }
@@ -840,7 +849,7 @@ static int __ctsvc_server_sim_info_init()
        g_type_init();
 #endif
        cp_name = tel_get_cp_name_list();
-       RETVM_IF(cp_name == NULL, CONTACTS_ERROR_SYSTEM, "tel_get_cp_name_list fail (cp_name is NULL)");
+       RETVM_IF(cp_name == NULL, CONTACTS_ERROR_SYSTEM, "tel_get_cp_name_list() Fail(cp_name is NULL)");
 
        ret = ctsvc_server_delete_sdn_contact(-1);
        WARN_IF(CONTACTS_ERROR_NONE != ret, "ctsvc_server_delete_sdn_contact() Fail(%d)", ret);
@@ -887,7 +896,7 @@ static int __ctsvc_server_sim_info_init()
                        WARN_IF(TAPI_API_SUCCESS != ret, "tel_register_noti_event() Fail(%d)", ret);
                }
                else {
-                       CTS_ERR("tel_init fail");
+                       CTS_ERR("tel_init() Fail");
                }
 
                __ctsvc_sim_info = g_slist_append(__ctsvc_sim_info, (void*)info);
index 422c1cc..f028e3a 100644 (file)
@@ -102,6 +102,7 @@ int ctsvc_server_socket_return(GIOChannel *src, int value, int attach_num, int *
        CTS_FN_CALL;
        int ret;
        ctsvc_socket_msg_s msg = {0};
+       RETVM_IF(NULL == src, CONTACTS_ERROR_INVALID_PARAMETER, "src is NULL");
 
        //      RETVM_IF(CONTACTS_ERROR_SYSTEM == value, value, "Socket has problems");
        RETVM_IF(CTSVC_SOCKET_MSG_REQUEST_MAX_ATTACH < attach_num, CONTACTS_ERROR_INTERNAL,