revise logging and coding style
authorJi-hoon Jung <jh8801.jung@samsung.com>
Tue, 12 Nov 2013 11:25:33 +0000 (20:25 +0900)
committerJi-hoon Jung <jh8801.jung@samsung.com>
Thu, 14 Nov 2013 07:22:47 +0000 (16:22 +0900)
Change-Id: I77ceea42d16d02828eb4e6368f960a83ebc27e4d
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
33 files changed:
client/net_nfc_client_sign_record.c
client/net_nfc_client_tag_felica.c
client/net_nfc_client_tag_jewel.c
client/net_nfc_client_tag_mifare.c
client/net_nfc_client_target_info.c
client/net_nfc_client_transceive.c
common/net_nfc_util.c
common/net_nfc_util_gdbus.c
common/net_nfc_util_handover.c
common/net_nfc_util_ndef_message.c
common/net_nfc_util_ndef_record.c
common/net_nfc_util_openssl.c
common/net_nfc_util_sign_record.c
daemon/net_nfc_server.c
daemon/net_nfc_server_common.c
daemon/net_nfc_server_context.c
daemon/net_nfc_server_controller.c
daemon/net_nfc_server_handover.c
daemon/net_nfc_server_handover_bss.c
daemon/net_nfc_server_handover_bt.c
daemon/net_nfc_server_llcp.c
daemon/net_nfc_server_manager.c
daemon/net_nfc_server_ndef.c
daemon/net_nfc_server_p2p.c
daemon/net_nfc_server_process_handover.c
daemon/net_nfc_server_process_npp.c
daemon/net_nfc_server_se.c
daemon/net_nfc_server_snep.c
daemon/net_nfc_server_system_handler.c
daemon/net_nfc_server_tag.c
daemon/net_nfc_server_transceive.c
daemon/net_nfc_server_util.c
daemon/net_nfc_server_vconf.c

index 3b6a457..8abbd57 100644 (file)
@@ -19,7 +19,8 @@
 API net_nfc_error_e net_nfc_sign_records(ndef_message_s *msg, int begin_index,
                int end_index, char *cert_file, char *password)
 {
-       return net_nfc_util_sign_records((ndef_message_s *)msg, begin_index, end_index, cert_file, password);
+       return net_nfc_util_sign_records((ndef_message_s *)msg,
+                       begin_index, end_index, cert_file, password);
 }
 
 API net_nfc_error_e net_nfc_sign_ndef_message(ndef_message_s *msg,
index 6de6a75..e51543a 100644 (file)
@@ -39,20 +39,15 @@ API net_nfc_error_e net_nfc_client_felica_poll(net_nfc_target_handle_s *handle,
                nfc_transceive_data_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s* target_info = NULL;
-
        data_s rawdata;
-
        uint8_t send_buffer[6] = { 0x00, };
+       net_nfc_target_info_s* target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if (target_info->devType != NET_NFC_FELICA_PICC)
@@ -77,10 +72,7 @@ API net_nfc_error_e net_nfc_client_felica_poll(net_nfc_target_handle_s *handle,
        rawdata.buffer = send_buffer;
        rawdata.length = 6;
 
-       return net_nfc_client_transceive_data(handle,
-                       &rawdata,
-                       callback,
-                       user_data);
+       return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
 }
 
 API net_nfc_error_e net_nfc_client_felica_request_service(
@@ -91,26 +83,20 @@ API net_nfc_error_e net_nfc_client_felica_request_service(
                nfc_transceive_data_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s* target_info = NULL;
-
+       int i;
        data_s rawdata;
-
        data_s *IDm = NULL;
-
-       uint32_t send_buffer_length;
-       uint8_t* send_buffer = NULL;
        uint8_t* temp = NULL;
+       uint8_t* send_buffer = NULL;
+       uint32_t send_buffer_length;
+       net_nfc_target_info_s* target_info = NULL;
 
-       int i;
-
-       if (handle == NULL || area_service_list == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == area_service_list, NET_NFC_NULL_PARAMETER);
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if (target_info->devType != NET_NFC_FELICA_PICC)
@@ -120,9 +106,7 @@ API net_nfc_error_e net_nfc_client_felica_request_service(
        }
 
        if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if (IDm->length != 8)
                return NET_NFC_OUT_OF_BOUND;
@@ -134,7 +118,7 @@ API net_nfc_error_e net_nfc_client_felica_request_service(
        send_buffer_length = 1 + 1 + 8 + 1 + (2 * number_of_services);
 
        _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
-       if (send_buffer == NULL)
+       if (NULL == send_buffer)
                return NET_NFC_ALLOC_FAIL;
 
        temp = send_buffer;
@@ -167,10 +151,7 @@ API net_nfc_error_e net_nfc_client_felica_request_service(
        rawdata.length = send_buffer_length;
 
        net_nfc_error_e result = NET_NFC_OK;
-       result = net_nfc_client_transceive_data(handle,
-                       &rawdata,
-                       callback,
-                       user_data);
+       result = net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
 
        if (temp != NULL)
                _net_nfc_util_free_mem(temp);
@@ -183,22 +164,16 @@ API net_nfc_error_e net_nfc_client_felica_request_response(
                nfc_transceive_data_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s* target_info = NULL;
-
        data_s rawdata;
-
        data_s *IDm = NULL;
-
        uint8_t send_buffer[10] = { 0x00, };
+       net_nfc_target_info_s* target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if (target_info->devType != NET_NFC_FELICA_PICC)
@@ -208,9 +183,7 @@ API net_nfc_error_e net_nfc_client_felica_request_response(
        }
 
        if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if (IDm->length != 8)
                return NET_NFC_OUT_OF_BOUND;
@@ -225,10 +198,7 @@ API net_nfc_error_e net_nfc_client_felica_request_response(
        rawdata.buffer = send_buffer;
        rawdata.length = 10;
 
-       return net_nfc_client_transceive_data(handle,
-                       &rawdata,
-                       callback,
-                       user_data);
+       return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
 }
 
 API net_nfc_error_e net_nfc_client_felica_read_without_encryption(
@@ -240,26 +210,22 @@ API net_nfc_error_e net_nfc_client_felica_read_without_encryption(
                nfc_transceive_data_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s* target_info = NULL;
-
+       int i;
        data_s rawdata;
-
        data_s *IDm = NULL;
-
-       uint32_t send_buffer_length;
-       uint8_t* send_buffer = NULL;
        uint8_t* temp = NULL;
+       uint8_t* send_buffer = NULL;
+       uint32_t send_buffer_length;
+       net_nfc_target_info_s* target_info = NULL;
 
-       int i;
-
-       if (handle == NULL || service_list == NULL || block_list == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == service_list, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == block_list, NET_NFC_NULL_PARAMETER);
 
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if (target_info->devType != NET_NFC_FELICA_PICC)
@@ -269,9 +235,7 @@ API net_nfc_error_e net_nfc_client_felica_read_without_encryption(
        }
 
        if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if (IDm->length != 8)
                return NET_NFC_OUT_OF_BOUND;
@@ -279,11 +243,10 @@ API net_nfc_error_e net_nfc_client_felica_read_without_encryption(
        if (number_of_services > 16)
                return NET_NFC_OUT_OF_BOUND;
 
-       send_buffer_length = 1 + 1 + 8 + 1 + (2 * number_of_services)
-               + 1 + number_of_blocks;
+       send_buffer_length = 1 + 1 + 8 + 1 + (2 * number_of_services) + 1 + number_of_blocks;
+
+       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
 
-       _net_nfc_util_alloc_mem(send_buffer,
-                       send_buffer_length * sizeof(uint8_t));
        if (send_buffer == NULL)
                return NET_NFC_ALLOC_FAIL;
 
@@ -322,10 +285,7 @@ API net_nfc_error_e net_nfc_client_felica_read_without_encryption(
        rawdata.length = send_buffer_length;
 
        net_nfc_error_e result = NET_NFC_OK;
-       result = net_nfc_client_transceive_data(handle,
-                       &rawdata,
-                       callback,
-                       user_data);
+       result = net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
 
        if (temp != NULL)
                _net_nfc_util_free_mem(temp);
@@ -343,28 +303,23 @@ API net_nfc_error_e net_nfc_client_felica_write_without_encryption(
                nfc_transceive_data_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s* target_info = NULL;
-
+       int i;
        data_s rawdata;
-
        data_s *IDm = NULL;
-
-       uint32_t send_buffer_length;
-       uint8_t* send_buffer = NULL;
        uint8_t* temp = NULL;
+       uint8_t* send_buffer = NULL;
+       uint32_t send_buffer_length;
+       net_nfc_target_info_s* target_info = NULL;
 
-       int i;
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == block_list, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == service_list, NET_NFC_NULL_PARAMETER);
 
-       if (handle == NULL || service_list == NULL ||
-                       block_list == NULL || data == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if (target_info->devType != NET_NFC_FELICA_PICC)
@@ -374,9 +329,7 @@ API net_nfc_error_e net_nfc_client_felica_write_without_encryption(
        }
 
        if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if (IDm->length != 8)
                return NET_NFC_OUT_OF_BOUND;
@@ -391,7 +344,7 @@ API net_nfc_error_e net_nfc_client_felica_write_without_encryption(
                + 1 + number_of_blocks + data->length;
 
        _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
-       if (send_buffer == NULL)
+       if (NULL == send_buffer)
                return NET_NFC_ALLOC_FAIL;
 
        temp = send_buffer;
@@ -432,10 +385,7 @@ API net_nfc_error_e net_nfc_client_felica_write_without_encryption(
 
        net_nfc_error_e result = NET_NFC_OK;
 
-       result = net_nfc_client_transceive_data(handle,
-                       &rawdata,
-                       callback,
-                       user_data);
+       result = net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
 
        if (temp != NULL)
                _net_nfc_util_free_mem(temp);
@@ -448,22 +398,16 @@ API net_nfc_error_e net_nfc_client_felica_request_system_code(
                nfc_transceive_data_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s* target_info = NULL;
-
        data_s rawdata;
-
        data_s *IDm = NULL;
-
        uint8_t send_buffer[10] = { 0x00, };
+       net_nfc_target_info_s* target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if (target_info->devType != NET_NFC_FELICA_PICC)
@@ -473,9 +417,7 @@ API net_nfc_error_e net_nfc_client_felica_request_system_code(
        }
 
        if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if (IDm->length != 8)
                return NET_NFC_OUT_OF_BOUND;
@@ -490,8 +432,5 @@ API net_nfc_error_e net_nfc_client_felica_request_system_code(
        rawdata.buffer = send_buffer;
        rawdata.length = 10;
 
-       return net_nfc_client_transceive_data(handle,
-                       &rawdata,
-                       callback,
-                       user_data);
+       return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
 }
index 16680d7..e9026f3 100644 (file)
 API net_nfc_error_e net_nfc_client_jewel_read_id(net_nfc_target_handle_s *handle,
                nfc_transceive_data_callback callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
-
        data_s rawdata;
-
        uint8_t send_buffer[9] = {0x00, };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if(handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if(target_info->devType != NET_NFC_JEWEL_PICC)
@@ -75,25 +70,20 @@ API net_nfc_error_e net_nfc_client_jewel_read_id(net_nfc_target_handle_s *handle
 API net_nfc_error_e net_nfc_client_jewel_read_byte(net_nfc_target_handle_s *handle,
                uint8_t block, uint8_t byte, nfc_transceive_data_callback callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
-
        data_s rawdata;
-
        data_s *UID = NULL;
-
        uint8_t send_buffer[9] = {0x00, };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if(handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if(block > 0xE || byte > 0x7 )
-               return NET_NFC_OUT_OF_BOUND;
+       RETVM_IF(block > 0xE || byte > 0x7, NET_NFC_OUT_OF_BOUND,
+               "block value is = [0x%x], byte value is = [0x%x]", block, byte);
 
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if(target_info->devType != NET_NFC_JEWEL_PICC)
@@ -103,9 +93,7 @@ API net_nfc_error_e net_nfc_client_jewel_read_byte(net_nfc_target_handle_s *hand
        }
 
        if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if(UID->length != 4)
                return NET_NFC_OUT_OF_BOUND;
@@ -135,22 +123,17 @@ API net_nfc_error_e net_nfc_client_jewel_read_byte(net_nfc_target_handle_s *hand
 API net_nfc_error_e net_nfc_client_jewel_read_all(net_nfc_target_handle_s *handle,
                nfc_transceive_data_callback callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
-
        data_s rawdata;
-
        data_s *UID = NULL;
-
        uint8_t send_buffer[9] = {0x00, };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if(handle == NULL )
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if(target_info->devType != NET_NFC_JEWEL_PICC)
@@ -160,9 +143,7 @@ API net_nfc_error_e net_nfc_client_jewel_read_all(net_nfc_target_handle_s *handl
        }
 
        if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if(UID->length != 4)
                return NET_NFC_OUT_OF_BOUND;
@@ -197,29 +178,24 @@ API net_nfc_error_e net_nfc_client_jewel_write_with_erase(
                nfc_transceive_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
        data_s rawdata;
        data_s *UID = NULL;
        uint8_t send_buffer[9] = {0x00, };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if(handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if(block > 0xE || byte > 0x7 )
-               return NET_NFC_OUT_OF_BOUND;
-
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETVM_IF(block > 0xE || byte > 0x7, NET_NFC_OUT_OF_BOUND,
+               "block value is = [0x%x], byte value is = [0x%x]", block, byte);
 
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
        if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if(UID->length != 4)
                return NET_NFC_OUT_OF_BOUND;
@@ -254,27 +230,23 @@ API net_nfc_error_e net_nfc_client_jewel_write_with_no_erase(
                nfc_transceive_callback callback,
                void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
-
        data_s rawdata;
-
        data_s *UID = NULL;
-
        uint8_t send_buffer[9] = {0x00, };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if(handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if(block > 0xE || byte > 0x7 )
-               return NET_NFC_OUT_OF_BOUND;
+       RETVM_IF(block > 0xE || byte > 0x7, NET_NFC_OUT_OF_BOUND,
+               "block value is = [0x%x], byte value is = [0x%x]", block, byte);
 
-       if(net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NO_DATA_FOUND;
 
+
        if(target_info->devType != NET_NFC_JEWEL_PICC)
        {
                NFC_ERR("only Jewel tag is available(TAG=%d)", target_info->devType);
@@ -282,9 +254,7 @@ API net_nfc_error_e net_nfc_client_jewel_write_with_no_erase(
        }
 
        if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        if(UID->length != 4)
                return NET_NFC_OUT_OF_BOUND;
index 3617d88..abb9714 100644 (file)
@@ -62,23 +62,21 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyA(
                void *callback,
                void *user_data)
 {
-       net_nfc_target_info_s* target_info = NULL;
        data_s rawdata;
        data_s *UID = NULL;
-       uint8_t* send_buffer = NULL;
        uint8_t* temp = NULL;
+       net_nfc_error_e result;
        int send_buffer_length = 0;
+       uint8_t* send_buffer = NULL;
        uint8_t sector_to_block = 0;
-       net_nfc_error_e result;
-
-       if (handle == NULL || auth_key == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       net_nfc_target_info_s* target_info = NULL;
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == auth_key, NET_NFC_NULL_PARAMETER);
 
-       if (auth_key->length != 6)
-               return NET_NFC_OUT_OF_BOUND;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
+       RETVM_IF(auth_key->length != 6, NET_NFC_OUT_OF_BOUND,
+               "auth_key->length(%d) != 6", auth_key->length);
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
@@ -93,9 +91,7 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyA(
        }
 
        if (net_nfc_get_tag_info_value(target_info, MIFARE_TAG_KEY, &UID) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        switch (target_info->devType)
        {
@@ -137,9 +133,8 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyA(
        /* cmd + addr + UID + AUTH_KEY + CRC_A */
        send_buffer_length = 1 + 1 + UID->length + auth_key->length + 2;
 
-       _net_nfc_util_alloc_mem(send_buffer,
-                       send_buffer_length * sizeof(uint8_t));
-       if (send_buffer == NULL)
+       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+       if (NULL == send_buffer)
        {
                net_nfc_free_data(UID);
                return NET_NFC_ALLOC_FAIL;
@@ -179,23 +174,22 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyB(
                void *callback,
                void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
        data_s rawdata;
        data_s *UID = NULL;
-       uint8_t* send_buffer = NULL;
        uint8_t* temp = NULL;
+       net_nfc_error_e result;
        int send_buffer_length = 0;
+       uint8_t* send_buffer = NULL;
        uint8_t sector_to_block = 0;
-       net_nfc_error_e result;
+       net_nfc_target_info_s *target_info = NULL;
 
-       if (handle == NULL || auth_key == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == auth_key, NET_NFC_NULL_PARAMETER);
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
+       RETVM_IF(auth_key->length != 6, NET_NFC_OUT_OF_BOUND,
+               "auth_key->length(%d) != 6", auth_key->length);
 
-       if (auth_key->length != 6)
-               return NET_NFC_OUT_OF_BOUND;
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
@@ -210,9 +204,7 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyB(
        }
 
        if (net_nfc_get_tag_info_value(target_info, MIFARE_TAG_KEY, &UID) != NET_NFC_OK)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        switch (target_info->devType)
        {
@@ -241,8 +233,7 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyB(
                        sector_to_block = sector * MIFARE_BLOCK_4 + 3;
                else
                {
-                       sector_to_block = (31 * MIFARE_BLOCK_4 + 3)
-                               + (sector - 32)
+                       sector_to_block = (31 * MIFARE_BLOCK_4 + 3) + (sector - 32)
                                * MIFARE_BLOCK_16 + 15;
                }
                break;
@@ -253,9 +244,8 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyB(
        /* cmd + addr + UID + AUTH_KEY + CRC_A */
        send_buffer_length = 1 + 1 + UID->length + auth_key->length + 2;
 
-       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length
-                       * sizeof(uint8_t));
-       if (send_buffer == NULL)
+       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+       if (NULL == send_buffer)
        {
                net_nfc_free_data(UID);
                return NET_NFC_ALLOC_FAIL;
@@ -290,15 +280,13 @@ API net_nfc_error_e net_nfc_client_mifare_authenticate_with_keyB(
 API net_nfc_error_e net_nfc_client_mifare_read(net_nfc_target_handle_s *handle,
                uint8_t addr, void *callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
        data_s rawdata;
        uint8_t send_buffer[4] = {0};
+       net_nfc_target_info_s *target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
@@ -327,10 +315,7 @@ API net_nfc_error_e net_nfc_client_mifare_read(net_nfc_target_handle_s *handle,
        rawdata.buffer = send_buffer;
        rawdata.length = 4;
 
-       return net_nfc_client_transceive_data(handle,
-                       &rawdata,
-                       callback,
-                       user_data);
+       return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
 }
 
 API net_nfc_error_e net_nfc_client_mifare_write_block(
@@ -340,22 +325,18 @@ API net_nfc_error_e net_nfc_client_mifare_write_block(
                void *callback,
                void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
        data_s rawdata;
+       net_nfc_error_e result;
        uint8_t* send_buffer = NULL;
        uint32_t send_buffer_length = 0;
-       net_nfc_error_e result;
-
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       net_nfc_target_info_s *target_info = NULL;
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NOT_INITIALIZED;
 
        if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
@@ -380,9 +361,8 @@ API net_nfc_error_e net_nfc_client_mifare_write_block(
                        /* cmd + addr + page + CRC */
                        send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE + 2;
 
-                       _net_nfc_util_alloc_mem(send_buffer,
-                                       send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -403,9 +383,8 @@ API net_nfc_error_e net_nfc_client_mifare_write_block(
                        /* cmd + addr + page + CRC */
                        send_buffer_length = 1 + 1 + data->length + 2;
 
-                       _net_nfc_util_alloc_mem(send_buffer,
-                                       send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -418,11 +397,9 @@ API net_nfc_error_e net_nfc_client_mifare_write_block(
 
                        memcpy(temp, data->buffer, data->length);
                }
-
        }
        else
        {
-
                if (data->length > MIFARE_BLOCK_SIZE)
                {
                        uint8_t* temp = NULL;
@@ -430,9 +407,8 @@ API net_nfc_error_e net_nfc_client_mifare_write_block(
                        /* cmd + addr + page + CRC */
                        send_buffer_length = 1 + 1 + MIFARE_BLOCK_SIZE + 2;
 
-                       _net_nfc_util_alloc_mem(send_buffer,
-                                       send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -453,7 +429,7 @@ API net_nfc_error_e net_nfc_client_mifare_write_block(
                        send_buffer_length = 1 + 1 + data->length + 2;
 
                        _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -488,21 +464,19 @@ API net_nfc_error_e net_nfc_client_mifare_write_page(
                void *callback,
                void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
+       data_s rawdata;
+       net_nfc_error_e result;
        uint8_t* send_buffer = NULL;
        uint32_t send_buffer_length = 0;
-       net_nfc_error_e result;
-       data_s rawdata;
+       net_nfc_target_info_s *target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NOT_INITIALIZED;
 
        if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
@@ -528,7 +502,7 @@ API net_nfc_error_e net_nfc_client_mifare_write_page(
                        send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE + 2;
 
                        _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -549,7 +523,7 @@ API net_nfc_error_e net_nfc_client_mifare_write_page(
                        send_buffer_length = 1 + 1 + data->length + 2;
 
                        _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -573,9 +547,8 @@ API net_nfc_error_e net_nfc_client_mifare_write_page(
                        /* cmd + addr + page + CRC */
                        send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE + 2;
 
-                       _net_nfc_util_alloc_mem(send_buffer,
-                                       send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -597,7 +570,7 @@ API net_nfc_error_e net_nfc_client_mifare_write_page(
                        send_buffer_length = 1 + 1 + data->length + 2;
 
                        _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
-                       if (send_buffer == NULL)
+                       if (NULL == send_buffer)
                                return NET_NFC_ALLOC_FAIL;
 
                        temp = send_buffer;
@@ -633,18 +606,13 @@ API net_nfc_error_e net_nfc_client_mifare_increment(
                void *callback,
                void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
-
        data_s rawdata;
-
        uint8_t send_buffer[8] = { 0 };
+       net_nfc_target_info_s *target_info = NULL;
 
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
@@ -674,8 +642,7 @@ API net_nfc_error_e net_nfc_client_mifare_increment(
        rawdata.buffer = send_buffer;
        rawdata.length = 8;
 
-       return net_nfc_client_transceive(handle, &rawdata, callback,
-                       user_data);
+       return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
 }
 
 API net_nfc_error_e net_nfc_client_mifare_decrement(
@@ -685,23 +652,18 @@ API net_nfc_error_e net_nfc_client_mifare_decrement(
                void *callback,
                void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
-
        data_s rawdata;
-
        uint8_t send_buffer[8] = { 0 };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
        if (target_info)
        {
-
                if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
                                target_info->devType > NET_NFC_MIFARE_4K_PICC)
                {
@@ -727,22 +689,19 @@ API net_nfc_error_e net_nfc_client_mifare_decrement(
        rawdata.buffer = send_buffer;
        rawdata.length = 8;
 
-       return net_nfc_client_transceive(handle, &rawdata, callback,
-                       user_data);
+       return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
 }
 
 API net_nfc_error_e net_nfc_client_mifare_transfer(net_nfc_target_handle_s *handle,
                uint8_t addr, void *callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
        data_s rawdata;
        uint8_t send_buffer[4] = { 0 };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
@@ -764,22 +723,19 @@ API net_nfc_error_e net_nfc_client_mifare_transfer(net_nfc_target_handle_s *hand
        rawdata.buffer = send_buffer;
        rawdata.length = 4;
 
-       return net_nfc_client_transceive(handle, &rawdata, callback,
-                       user_data);
+       return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
 }
 
 API net_nfc_error_e net_nfc_client_mifare_restore(net_nfc_target_handle_s *handle,
                uint8_t addr, void *callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info = NULL;
        data_s rawdata;
        uint8_t send_buffer[4] = { 0 };
+       net_nfc_target_info_s *target_info = NULL;
 
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if (net_nfc_client_tag_is_connected() == FALSE)
-               return NET_NFC_OPERATION_FAIL;
+       RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
 
        target_info = net_nfc_client_tag_get_client_target_info();
 
@@ -801,14 +757,12 @@ API net_nfc_error_e net_nfc_client_mifare_restore(net_nfc_target_handle_s *handl
        rawdata.buffer = send_buffer;
        rawdata.length = 4;
 
-       return net_nfc_client_transceive(handle, &rawdata, callback,
-                       user_data);
+       return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
 }
 
 API net_nfc_error_e net_nfc_client_mifare_create_default_key(data_s** key)
 {
-       if (key == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
 
        return net_nfc_create_data(key, default_key, 6);
 }
@@ -816,16 +770,15 @@ API net_nfc_error_e net_nfc_client_mifare_create_default_key(data_s** key)
 API net_nfc_error_e net_nfc_client_mifare_create_application_directory_key(
                data_s** key)
 {
-       if (key == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
 
        return net_nfc_create_data(key, mad_key, 6);
 }
 
-API net_nfc_error_e net_nfc_client_mifare_create_net_nfc_forum_key(data_s** key)
+API net_nfc_error_e net_nfc_client_mifare_create_net_nfc_forum_key(
+               data_s** key)
 {
-       if (key == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
 
        return net_nfc_create_data(key, net_nfc_forum_key, 6);
 }
index a7ea6e6..6ddbacc 100644 (file)
 API net_nfc_error_e net_nfc_get_tag_type(net_nfc_target_info_s *target_info,
                net_nfc_target_type_e *type)
 {
-       if (type == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == type, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == target_info, NET_NFC_INVALID_HANDLE);
 
        *type = NET_NFC_UNKNOWN_TARGET;
-
-       if (target_info == NULL)
-               return NET_NFC_INVALID_HANDLE;
-
        *type = target_info->devType;
+
        return NET_NFC_OK;
 }
 
 API net_nfc_error_e net_nfc_get_tag_handle(net_nfc_target_info_s *target_info,
                net_nfc_target_handle_s **handle)
 {
-       if (handle == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == target_info, NET_NFC_INVALID_HANDLE);
 
        *handle = NULL;
-
-       if (target_info == NULL)
-               return NET_NFC_INVALID_HANDLE;
-
        *handle = target_info->handle;
+
        return NET_NFC_OK;
 }
 
 API net_nfc_error_e net_nfc_get_tag_ndef_support(
                net_nfc_target_info_s *target_info, bool *is_support)
 {
-       if (target_info == NULL || is_support == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == is_support, NET_NFC_NULL_PARAMETER);
 
        *is_support = (bool)target_info->is_ndef_supported;
+
        return NET_NFC_OK;
 }
 
 API net_nfc_error_e net_nfc_get_tag_max_data_size(
-               net_nfc_target_info_s *target_info, uint32_t * max_size)
+               net_nfc_target_info_s *target_info, uint32_t *max_size)
 {
-       if (target_info == NULL || max_size == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == max_size, NET_NFC_NULL_PARAMETER);
 
        *max_size = target_info->maxDataSize;
+
        return NET_NFC_OK;
 }
 
 API net_nfc_error_e net_nfc_get_tag_actual_data_size(
                net_nfc_target_info_s *target_info, uint32_t *actual_data)
 {
-       if (target_info == NULL || actual_data == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == actual_data, NET_NFC_NULL_PARAMETER);
 
        *actual_data = target_info->actualDataSize;
+
        return NET_NFC_OK;
 }
 
@@ -87,14 +84,12 @@ API net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_s *target_info
 {
        int i = 0;
 
-       if (keys == NULL || number_of_keys == NULL || target_info == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if (target_info->tag_info_list == NULL)
-               return NET_NFC_NO_DATA_FOUND;
+       RETV_IF(NULL == keys, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == number_of_keys, NET_NFC_NULL_PARAMETER);
 
-       if (target_info->number_of_keys <= 0)
-               return NET_NFC_NO_DATA_FOUND;
+       RETV_IF(NULL == target_info->tag_info_list, NET_NFC_NO_DATA_FOUND);
+       RETV_IF(target_info->number_of_keys <= 0, NET_NFC_NO_DATA_FOUND);
 
        if (target_info->keylist != NULL)
        {
@@ -103,7 +98,7 @@ API net_nfc_error_e net_nfc_get_tag_info_keys(net_nfc_target_info_s *target_info
        }
 
        _net_nfc_util_alloc_mem(*keys, target_info->number_of_keys * sizeof(char *));
-       if (*keys == NULL)
+       if (NULL == *keys)
                return NET_NFC_ALLOC_FAIL;
 
        net_nfc_tag_info_s *tag_info = target_info->tag_info_list;
@@ -128,19 +123,19 @@ API net_nfc_error_e net_nfc_get_tag_info_value(net_nfc_target_info_s *target_inf
        int i;
        net_nfc_tag_info_s *tag_info;
 
-       if (target_info == NULL || key == NULL || value == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == value, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
 
-       if (target_info->tag_info_list == NULL)
-               return NET_NFC_NO_DATA_FOUND;
+       RETV_IF(NULL == target_info->tag_info_list, NET_NFC_NO_DATA_FOUND);
 
        tag_info = target_info->tag_info_list;
 
-       for (i=0;i < target_info->number_of_keys;i++, tag_info++)
+       for (i = 0; i < target_info->number_of_keys; i++, tag_info++)
        {
                if (strcmp(key, tag_info->key) == 0)
                {
-                       if (tag_info->value == NULL)
+                       if (NULL == tag_info->value)
                        {
                                return NET_NFC_NO_DATA_FOUND;
                        }
@@ -163,11 +158,11 @@ API net_nfc_error_e net_nfc_duplicate_target_info(net_nfc_target_info_s *origin,
 {
        net_nfc_target_info_s *temp = NULL;
 
-       if (origin == NULL || result == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == origin, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == result, NET_NFC_NULL_PARAMETER);
 
        _net_nfc_util_alloc_mem(temp, sizeof(net_nfc_target_info_s));
-       if (temp == NULL)
+       if (NULL == temp)
                return NET_NFC_ALLOC_FAIL;
 
        temp->ndefCardState = origin->ndefCardState;
@@ -178,12 +173,14 @@ API net_nfc_error_e net_nfc_duplicate_target_info(net_nfc_target_info_s *origin,
        temp->is_ndef_supported = origin->is_ndef_supported;
        temp->number_of_keys = origin->number_of_keys;
 
-       if (temp->number_of_keys > 0)
+       if (0 < temp->number_of_keys)
        {
                int i;
 
-               _net_nfc_util_alloc_mem(temp->tag_info_list, temp->number_of_keys * sizeof(net_nfc_tag_info_s));
-               if (temp->tag_info_list == NULL)
+               _net_nfc_util_alloc_mem(temp->tag_info_list,
+                               temp->number_of_keys * sizeof(net_nfc_tag_info_s));
+
+               if (NULL == temp->tag_info_list)
                {
                        _net_nfc_util_free_mem(temp);
                        return NET_NFC_ALLOC_FAIL;
@@ -192,18 +189,22 @@ API net_nfc_error_e net_nfc_duplicate_target_info(net_nfc_target_info_s *origin,
                for (i = 0; i < origin->number_of_keys; i++)
                {
                        if (origin->tag_info_list[i].key != NULL)
-                               _net_nfc_util_strdup(temp->tag_info_list[i].key, origin->tag_info_list[i].key);
+                       {
+                               _net_nfc_util_strdup(temp->tag_info_list[i].key,
+                                       origin->tag_info_list[i].key);
+                       }
 
                        if (origin->tag_info_list[i].value != NULL)
                        {
                                data_s *data = origin->tag_info_list[i].value;
 
-                               net_nfc_create_data(&temp->tag_info_list[i].value, data->buffer, data->length);
+                               net_nfc_create_data(&temp->tag_info_list[i].value,
+                                       data->buffer, data->length);
                        }
                }
        }
 
-       if (origin->raw_data.length > 0)
+       if (0 < origin->raw_data.length)
        {
                net_nfc_util_alloc_data(&temp->raw_data, origin->raw_data.length);
                memcpy(temp->raw_data.buffer, origin->raw_data.buffer, temp->raw_data.length);
@@ -218,7 +219,7 @@ static net_nfc_error_e _release_tag_info(net_nfc_target_info_s *info)
 {
        net_nfc_tag_info_s *list = NULL;
 
-       if (info == NULL)
+       if (NULL == info)
                return NET_NFC_NULL_PARAMETER;
 
        list = info->tag_info_list;
@@ -252,7 +253,7 @@ API net_nfc_error_e net_nfc_release_tag_info(net_nfc_target_info_s *target_info)
 {
        net_nfc_error_e result;
 
-       if (target_info == NULL)
+       if (NULL == target_info)
                return NET_NFC_NULL_PARAMETER;
 
        result = _release_tag_info(target_info);
index a6493df..e0bcc85 100644 (file)
 static NetNfcGDbusTransceive *transceive_proxy = NULL;
 
 static GVariant *transceive_data_to_transceive_variant(
-               net_nfc_target_type_e dev_type,
-               data_s *data);
-
-static void transceive_call(GObject *source_object,
-               GAsyncResult *res,
-               gpointer user_data);
-
-static void transceive_data_call(GObject *source_object,
-               GAsyncResult *res,
-               gpointer user_data);
-
-static GVariant *transceive_data_to_transceive_variant(
-               net_nfc_target_type_e devType,
-               data_s *data)
+               net_nfc_target_type_e devType, data_s *data)
 {
-       data_s transceive_info = { NULL, };
        GVariant *variant;
+       data_s transceive_info = { NULL, };
 
-       if (data == NULL)
-       {
-               NFC_ERR("data is empty");
-               return NULL;
-       }
+       RETV_IF(NULL == data, NULL);
 
        switch (devType)
        {
@@ -59,16 +42,11 @@ static GVariant *transceive_data_to_transceive_variant(
        case NET_NFC_MIFARE_1K_PICC :
        case NET_NFC_MIFARE_4K_PICC :
        case NET_NFC_MIFARE_ULTRA_PICC :
-               if (net_nfc_util_alloc_data(&transceive_info,
-                                       data->length + 2) == true)
+               if (net_nfc_util_alloc_data(&transceive_info, data->length + 2) == true)
                {
-                       memcpy(transceive_info.buffer,
-                                       data->buffer,
-                                       data->length);
+                       memcpy(transceive_info.buffer, data->buffer, data->length);
 
-                       net_nfc_util_compute_CRC(CRC_A,
-                                       transceive_info.buffer,
-                                       transceive_info.length);
+                       net_nfc_util_compute_CRC(CRC_A, transceive_info.buffer, transceive_info.length);
                }
                break;
 
@@ -81,24 +59,16 @@ static GVariant *transceive_data_to_transceive_variant(
 
                if (net_nfc_util_alloc_data(&transceive_info, 9) == true)
                {
-                       memcpy(transceive_info.buffer,
-                                       data->buffer,
-                                       data->length);
+                       memcpy(transceive_info.buffer, data->buffer, data->length);
 
-                       net_nfc_util_compute_CRC(CRC_B,
-                                       transceive_info.buffer,
-                                       transceive_info.length);
+                       net_nfc_util_compute_CRC(CRC_B, transceive_info.buffer, transceive_info.length);
                }
                break;
 
        default :
-               if(net_nfc_util_alloc_data(&transceive_info,
-                                       data->length) == true)
-               {
-                       memcpy(transceive_info.buffer,
-                                       data->buffer,
-                                       data->length);
-               }
+               if(net_nfc_util_alloc_data(&transceive_info, data->length) == true)
+                       memcpy(transceive_info.buffer, data->buffer, data->length);
+
                break;
        }
 
@@ -112,19 +82,24 @@ static GVariant *transceive_data_to_transceive_variant(
 static void transceive_data_call(GObject *source_object,
                GAsyncResult *res, gpointer user_data)
 {
-       NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e out_result;
-       GVariant *out_data = NULL;
+       gboolean ret;
        GError *error = NULL;
+       data_s resp = { NULL, };
+       GVariant *out_data = NULL;
+       net_nfc_error_e out_result;
+       nfc_transceive_data_callback callback;
+       NetNfcCallback *func_data = user_data;
 
        g_assert(user_data != NULL);
 
-       if (net_nfc_gdbus_transceive_call_transceive_data_finish(
+       ret = net_nfc_gdbus_transceive_call_transceive_data_finish(
                                NET_NFC_GDBUS_TRANSCEIVE(source_object),
                                (gint *)&out_result,
                                &out_data,
                                res,
-                               &error) == FALSE)
+                               &error);
+
+       if (FALSE == ret)
        {
                NFC_ERR("Can not finish transceive: %s", error->message);
                g_error_free(error);
@@ -152,17 +127,21 @@ static void transceive_data_call(GObject *source_object,
 static void transceive_call(GObject *source_object,
                GAsyncResult *res, gpointer user_data)
 {
-       NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e out_result;
+       gboolean ret;
        GError *error = NULL;
+       net_nfc_error_e out_result;
+       nfc_transceive_callback callback;
+       NetNfcCallback *func_data = user_data;
 
        g_assert(user_data != NULL);
 
-       if (net_nfc_gdbus_transceive_call_transceive_finish(
+       ret = net_nfc_gdbus_transceive_call_transceive_finish(
                                NET_NFC_GDBUS_TRANSCEIVE(source_object),
                                (gint *)&out_result,
                                res,
-                               &error) == FALSE)
+                               &error);
+
+       if (FALSE == ret)
        {
                NFC_ERR("Can not finish transceive: %s", error->message);
                g_error_free(error);
@@ -170,11 +149,10 @@ static void transceive_call(GObject *source_object,
                out_result = NET_NFC_IPC_FAIL;
        }
 
-       if (func_data->callback != NULL)
+       if (func_data->callback)
        {
-               ((nfc_transceive_callback)func_data->callback)(
-                       out_result,
-                       func_data->user_data);
+               callback = (nfc_transceive_callback)func_data->callback;
+               callback(out_result, func_data->user_data);
        }
 
        g_free(func_data);
@@ -183,40 +161,46 @@ static void transceive_call(GObject *source_object,
 API net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_s *handle,
                data_s *rawdata, nfc_transceive_callback callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info;
-       NetNfcCallback *funcdata;
        GVariant *arg_data;
+       NetNfcCallback *funcdata;
+       net_nfc_target_info_s *target_info;
 
-       if (transceive_proxy == NULL)
+       if (NULL == transceive_proxy)
        {
                NFC_ERR("Can not get TransceiveProxy");
 
                return NET_NFC_NOT_INITIALIZED;
        }
 
-
-       if (handle == NULL || rawdata == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
 
        /* prevent executing daemon when nfc is off */
-       if (net_nfc_client_manager_is_activated() == false) {
-               return NET_NFC_INVALID_STATE;
-       }
+       RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL || target_info->handle == NULL)
+
+       if (NULL == target_info)
+       {
+               NFC_ERR("target_info is NULL");
+               return NET_NFC_NOT_CONNECTED;
+       }
+
+       if (NULL == target_info->handle)
+       {
+               NFC_ERR("target_info->handle is NULL");
                return NET_NFC_NOT_CONNECTED;
+       }
 
        NFC_DBG("send request :: transceive = [%p]", handle);
 
-       arg_data = transceive_data_to_transceive_variant(target_info->devType,
-                       rawdata);
-       if (arg_data == NULL) {
+       arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+       if (NULL == arg_data)
                return NET_NFC_INVALID_PARAM;
-       }
 
        funcdata = g_try_new0(NetNfcCallback, 1);
-       if (funcdata == NULL) {
+       if (NULL == funcdata)
+       {
                g_variant_unref(arg_data);
 
                return NET_NFC_ALLOC_FAIL;
@@ -240,39 +224,41 @@ API net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_s *handle,
 API net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_s *handle,
                data_s *rawdata, nfc_transceive_data_callback callback, void *user_data)
 {
-       net_nfc_target_info_s *target_info;
-       NetNfcCallback *funcdata;
        GVariant *arg_data;
+       NetNfcCallback *funcdata;
+       net_nfc_target_info_s *target_info;
 
-       if (transceive_proxy == NULL)
-       {
-               NFC_ERR("Can not get TransceiveProxy");
-
-               return NET_NFC_NOT_INITIALIZED;
-       }
+       RETV_IF(NULL == transceive_proxy, NET_NFC_NOT_INITIALIZED);
 
-       if (handle == NULL || rawdata == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
 
        /* prevent executing daemon when nfc is off */
-       if (net_nfc_client_manager_is_activated() == false) {
-               return NET_NFC_INVALID_STATE;
-       }
+       RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL || target_info->handle == NULL)
+
+       if (NULL == target_info)
+       {
+               NFC_ERR("target_info is NULL");
+               return NET_NFC_NOT_CONNECTED;
+       }
+
+       if (NULL == target_info->handle)
+       {
+               NFC_ERR("target_info->handle is NULL");
                return NET_NFC_NOT_CONNECTED;
+       }
 
        NFC_DBG("send request :: transceive = [%p]", handle);
 
-       arg_data = transceive_data_to_transceive_variant(target_info->devType,
-                       rawdata);
-       if (arg_data == NULL) {
+       arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+       if (NULL == arg_data)
                return NET_NFC_INVALID_PARAM;
-       }
 
        funcdata = g_try_new0(NetNfcCallback, 1);
-       if (funcdata == NULL) {
+       if (NULL == funcdata)
+       {
                g_variant_unref(arg_data);
 
                return NET_NFC_ALLOC_FAIL;
@@ -296,48 +282,52 @@ API net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_s *hand
 API net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_s *handle,
                data_s *rawdata)
 {
+       gboolean ret;
+       GVariant *arg_data;
+       GError *error = NULL;
        net_nfc_target_info_s *target_info;
        net_nfc_error_e out_result = NET_NFC_OK;
-       GError *error = NULL;
-       GVariant *arg_data;
-
-       if (handle == NULL || rawdata == NULL)
-               return NET_NFC_NULL_PARAMETER;
 
-       if (transceive_proxy == NULL)
-       {
-               NFC_ERR("Can not get TransceiveProxy");
+       RETV_IF(NULL == transceive_proxy, NET_NFC_NOT_INITIALIZED);
 
-               return NET_NFC_NOT_INITIALIZED;
-       }
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
 
        /* prevent executing daemon when nfc is off */
-       if (net_nfc_client_manager_is_activated() == false) {
-               return NET_NFC_INVALID_STATE;
-       }
+       RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL || target_info->handle == NULL)
+
+       if (NULL == target_info)
+       {
+               NFC_ERR("target_info is NULL");
+               return NET_NFC_NOT_CONNECTED;
+       }
+
+       if (NULL == target_info->handle)
+       {
+               NFC_ERR("target_info->handle is NULL");
                return NET_NFC_NOT_CONNECTED;
+       }
 
        NFC_DBG("send request :: transceive = [%p]", handle);
 
-       arg_data = transceive_data_to_transceive_variant(target_info->devType,
-                       rawdata);
-       if (arg_data == NULL)
+       arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+       if (NULL == arg_data)
                return NET_NFC_ALLOC_FAIL;
 
-       if (net_nfc_gdbus_transceive_call_transceive_sync(transceive_proxy,
+       ret = net_nfc_gdbus_transceive_call_transceive_sync(transceive_proxy,
                                GPOINTER_TO_UINT(handle),
                                target_info->devType,
                                arg_data,
                                net_nfc_client_gdbus_get_privilege(),
                                (gint *)&out_result,
                                NULL,
-                               &error) == FALSE)
+                               &error);
+
+       if (FALSE == ret)
        {
-               NFC_ERR("Transceive (sync call) failed: %s",
-                               error->message);
+               NFC_ERR("Transceive (sync call) failed: %s", error->message);
                g_error_free(error);
 
                out_result = NET_NFC_IPC_FAIL;
@@ -349,39 +339,41 @@ API net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_s *hand
 API net_nfc_error_e net_nfc_client_transceive_data_sync(
                net_nfc_target_handle_s *handle, data_s *rawdata, data_s **response)
 {
+       gboolean ret;
+       GVariant *arg_data;
+       GError *error = NULL;
+       GVariant *out_data = NULL;
        net_nfc_target_info_s *target_info;
        net_nfc_error_e out_result = NET_NFC_OK;
-       GVariant *out_data = NULL;
-       GError *error = NULL;
-       GVariant *arg_data;
 
-       if (handle == NULL || rawdata == NULL)
-               return NET_NFC_NULL_PARAMETER;
-
-       if (transceive_proxy == NULL)
-       {
-               NFC_ERR("Can not get TransceiveProxy");
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
 
-               return NET_NFC_NOT_INITIALIZED;
-       }
+       RETV_IF(NULL == transceive_proxy, NET_NFC_NOT_INITIALIZED);
 
        /* prevent executing daemon when nfc is off */
-       if (net_nfc_client_manager_is_activated() == false) {
-               return NET_NFC_INVALID_STATE;
-       }
+       RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
 
        target_info = net_nfc_client_tag_get_client_target_info();
-       if (target_info == NULL || target_info->handle == NULL)
+       if (NULL == target_info)
+       {
+               NFC_ERR("target_info is NULL");
+               return NET_NFC_NOT_CONNECTED;
+       }
+
+       if (NULL == target_info->handle)
+       {
+               NFC_ERR("target_info->handle is NULL");
                return NET_NFC_NOT_CONNECTED;
+       }
 
        NFC_DBG("send request :: transceive = [%p]", handle);
 
-       arg_data = transceive_data_to_transceive_variant(target_info->devType,
-                       rawdata);
-       if (arg_data == NULL)
+       arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+       if (NULL == arg_data)
                return NET_NFC_ALLOC_FAIL;
 
-       if (net_nfc_gdbus_transceive_call_transceive_data_sync(
+       ret = net_nfc_gdbus_transceive_call_transceive_data_sync(
                                transceive_proxy,
                                GPOINTER_TO_UINT(handle),
                                target_info->devType,
@@ -390,19 +382,18 @@ API net_nfc_error_e net_nfc_client_transceive_data_sync(
                                (gint *)&out_result,
                                &out_data,
                                NULL,
-                               &error) == FALSE)
+                               &error);
+
+       if (FALSE == ret)
        {
-               NFC_ERR("Transceive (sync call) failed: %s",
-                               error->message);
+               NFC_ERR("Transceive (sync call) failed: %s", error->message);
                g_error_free(error);
 
                out_result = NET_NFC_IPC_FAIL;
        }
 
        if (response && out_data != NULL)
-       {
                *response = net_nfc_util_gdbus_variant_to_data(out_data);
-       }
 
        return out_result;
 }
@@ -425,7 +416,7 @@ net_nfc_error_e net_nfc_client_transceive_init(void)
                        "/org/tizen/NetNfcService/Transceive",
                        NULL,
                        &error);
-       if (transceive_proxy == NULL)
+       if (NULL == transceive_proxy)
        {
                NFC_ERR("Can not create proxy : %s", error->message);
                g_error_free(error);
index 9cf3e12..c62a25b 100644 (file)
@@ -85,18 +85,19 @@ void net_nfc_change_log_tag()
        log_tag = LOG_SERVER_TAG;
 }
 
-
 API void __net_nfc_util_free_mem(void **mem, char *filename, unsigned int line)
 {
-       if (mem == NULL)
+       if (NULL == mem)
        {
-               SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem free util, mem is NULL", filename, line);
+               SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem free util, mem is NULL",
+                               filename, line);
                return;
        }
 
-       if (*mem == NULL)
+       if (NULL == *mem)
        {
-               SECURE_LOGD("FILE: %s, LINE:%d, Invalid Parameter in mem free util, *mem is NULL", filename, line);
+               SECURE_LOGD("FILE: %s, LINE:%d, Invalid Parameter in mem free util, *mem is NULL",
+                               filename, line);
                return;
        }
 
@@ -104,55 +105,60 @@ API void __net_nfc_util_free_mem(void **mem, char *filename, unsigned int line)
        *mem = NULL;
 }
 
-API void __net_nfc_util_alloc_mem(void **mem, int size, char *filename, unsigned int line)
+API void __net_nfc_util_alloc_mem(void **mem, int size, char *filename,
+               unsigned int line)
 {
-       if (mem == NULL || size <= 0)
+       if (NULL == mem || size <= 0)
        {
-               SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem alloc util, mem [%p], size [%d]", filename, line, mem, size);
+               SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem alloc util",
+                       "mem [%p], size [%d]", filename, line, mem, size);
                return;
        }
 
        if (*mem != NULL)
        {
-               SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]", filename, line, *mem);
+               SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]",
+                               filename, line, *mem);
        }
 
        *mem = g_malloc0(size);
 
-       if (*mem == NULL)
+       if (NULL == *mem)
        {
-               SECURE_LOGD("FILE: %s, LINE:%d, Allocation is failed, size [%d]", filename, line, size);
+               SECURE_LOGD("FILE: %s, LINE:%d, Allocation is failed, size [%d]",
+                               filename, line, size);
        }
 }
 
-API void __net_nfc_util_strdup(char **output, const char *origin, char *filename, unsigned int line)
+API void __net_nfc_util_strdup(char **output, const char *origin, char *filename,
+               unsigned int line)
 {
-       if (output == NULL || origin == NULL)
+       if (NULL == output || NULL == origin)
        {
-               SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in strdup, output [%p], origin [%p]", filename, line, output, origin);
+               SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in strdup",
+                               "output [%p], origin [%p]", filename, line, output, origin);
                return;
        }
 
        if (*output != NULL)
        {
-               SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]", filename, line, *output);
+               SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]",
+                               filename, line, *output);
        }
 
        *output = g_strdup(origin);
 
-       if (*output == NULL)
-       {
+       if (NULL == *output)
                SECURE_LOGD("FILE: %s, LINE:%d, strdup failed", filename, line);
-       }
 }
 
 API bool net_nfc_util_alloc_data(data_s *data, uint32_t length)
 {
-       if (data == NULL || length == 0)
-               return false;
+       RETV_IF(0 == length, false);
+       RETV_IF(NULL == data, false);
 
        _net_nfc_util_alloc_mem(data->buffer, length);
-       if (data->buffer == NULL)
+       if (NULL == data->buffer)
                return false;
 
        data->length = length;
@@ -162,18 +168,19 @@ API bool net_nfc_util_alloc_data(data_s *data, uint32_t length)
 
 API void net_nfc_util_free_data(data_s *data)
 {
-       if (data == NULL || data->buffer == NULL)
-               return;
+       RET_IF(NULL == data);
+       RET_IF(NULL == data->buffer);
 
        _net_nfc_util_free_mem(data->buffer);
        data->length = 0;
 }
 
-net_nfc_conn_handover_carrier_state_e net_nfc_util_get_cps(net_nfc_conn_handover_carrier_type_e carrier_type)
+net_nfc_conn_handover_carrier_state_e net_nfc_util_get_cps(
+               net_nfc_conn_handover_carrier_type_e carrier_type)
 {
        net_nfc_conn_handover_carrier_state_e cps = NET_NFC_CONN_HANDOVER_CARRIER_INACTIVATE;
 
-       if (carrier_type == NET_NFC_CONN_HANDOVER_CARRIER_BT)
+       if (NET_NFC_CONN_HANDOVER_CARRIER_BT== carrier_type)
        {
                int ret = bluetooth_check_adapter();
 
@@ -195,7 +202,7 @@ net_nfc_conn_handover_carrier_state_e net_nfc_util_get_cps(net_nfc_conn_handover
                        break;
                }
        }
-       else if (carrier_type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
+       else if (NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS == carrier_type)
        {
                int wifi_state = 0;
 
@@ -229,33 +236,30 @@ uint8_t *net_nfc_util_get_local_bt_address()
        _net_nfc_util_alloc_mem(bt_addr, BLUETOOTH_ADDRESS_LENGTH);
        if (bt_addr != NULL)
        {
-               if (net_nfc_util_get_cps(NET_NFC_CONN_HANDOVER_CARRIER_BT) != NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE)
+               net_nfc_conn_handover_carrier_state_e ret;
+
+               ret = net_nfc_util_get_cps(NET_NFC_CONN_HANDOVER_CARRIER_BT);
+
+               if (ret != NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE)
                {
                        // bt power is off. so get bt address from configuration file.
                        FILE *fp = NULL;
 
                        if ((fp = fopen(HIDDEN_BT_ADDR_FILE, "r")) != NULL)
                        {
-                               unsigned char temp[BLUETOOTH_ADDRESS_LENGTH * 2] = { 0, };
-
                                int ch;
-                               int count = 0;
                                int i = 0;
+                               int count = 0;
+                               unsigned char temp[BLUETOOTH_ADDRESS_LENGTH * 2] = { 0, };
 
                                while ((ch = fgetc(fp)) != EOF && count < BLUETOOTH_ADDRESS_LENGTH * 2)
                                {
                                        if (((ch >= '0') && (ch <= '9')))
-                                       {
                                                temp[count++] = ch - '0';
-                                       }
                                        else if (((ch >= 'a') && (ch <= 'z')))
-                                       {
                                                temp[count++] = ch - 'a' + 10;
-                                       }
                                        else if (((ch >= 'A') && (ch <= 'Z')))
-                                       {
                                                temp[count++] = ch - 'A' + 10;
-                                       }
                                }
 
                                for (; i < BLUETOOTH_ADDRESS_LENGTH; i++)
@@ -288,15 +292,13 @@ void net_nfc_util_enable_bluetooth(void)
 
 bool net_nfc_util_strip_string(char *buffer, int buffer_length)
 {
-       bool result = false;
-       char *temp = NULL;
        int i = 0;
+       char *temp = NULL;
+       bool result = false;
 
        _net_nfc_util_alloc_mem(temp, buffer_length);
-       if (temp == NULL)
-       {
+       if (NULL == temp)
                return result;
-       }
 
        for (; i < buffer_length; i++)
        {
@@ -308,7 +310,6 @@ bool net_nfc_util_strip_string(char *buffer, int buffer_length)
        {
                memcpy(temp, &buffer[i], buffer_length - i);
                memset(buffer, 0x00, buffer_length);
-
                memcpy(buffer, temp, buffer_length - i);
 
                result = true;
@@ -327,15 +328,17 @@ static uint16_t _net_nfc_util_update_CRC(uint8_t ch, uint16_t *lpwCrc)
 {
        ch = (ch ^ (uint8_t)((*lpwCrc) & 0x00FF));
        ch = (ch ^ (ch << 4));
-       *lpwCrc = (*lpwCrc >> 8) ^ ((uint16_t)ch << 8) ^ ((uint16_t)ch << 3) ^ ((uint16_t)ch >> 4);
+       *lpwCrc = (*lpwCrc >> 8) ^ ((uint16_t)ch << 8) ^
+                       ((uint16_t)ch << 3) ^ ((uint16_t)ch >> 4);
        return (*lpwCrc);
 }
 
-void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer, uint32_t length)
+void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer,
+       uint32_t length)
 {
        uint8_t chBlock = 0;
-       int msg_length = length - 2;
        uint8_t *temp = buffer;
+       int msg_length = length - 2;
 
        // default is CRC_B
        uint16_t wCrc = 0xFFFF; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
@@ -351,17 +354,13 @@ void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer, uint32_t len
                break;
        }
 
-       do
-       {
+       do{
                chBlock = *buffer++;
                _net_nfc_util_update_CRC(chBlock, &wCrc);
-       }
-       while (--msg_length > 0);
+       } while (--msg_length > 0);
 
-       if (CRC_type == CRC_B)
-       {
+       if (CRC_B == CRC_type)
                wCrc = ~wCrc; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
-       }
 
        temp[length - 2] = (uint8_t)(wCrc & 0xFF);
        temp[length - 1] = (uint8_t)((wCrc >> 8) & 0xFF);
@@ -369,9 +368,9 @@ void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer, uint32_t len
 
 const char *net_nfc_util_get_schema_string(int index)
 {
-       if (index == 0 || index >= NET_NFC_SCHEMA_MAX)
-               return NULL;
-       else
-               return schema[index];
+       RETV_IF(0 == index, NULL);
+       RETV_IF(index >= NET_NFC_SCHEMA_MAX, NULL);
+
+       return schema[index];
 }
 
index 72d4507..bc8275e 100644 (file)
 void net_nfc_util_gdbus_variant_to_buffer(GVariant *variant, uint8_t **buffer,
                size_t *length)
 {
+       guint size = 0;
        GVariantIter *iter;
        guint8 *buf = NULL;
-       guint size = 0;
 
-       if (variant == NULL)
-               return;
+       RET_IF(NULL == variant);
 
        g_variant_get(variant, "a(y)", &iter);
 
        size = g_variant_iter_n_children(iter);
        buf  = g_new0(guint8, size);
+
        if (buf != NULL)
        {
-               guint8 element;
                guint i;
+               guint8 element;
 
                i = 0;
                while (g_variant_iter_loop(iter, "(y)", &element))
@@ -64,13 +64,12 @@ void net_nfc_util_gdbus_variant_to_buffer(GVariant *variant, uint8_t **buffer,
 
 data_s *net_nfc_util_gdbus_variant_to_data(GVariant *variant)
 {
+       guint size = 0;
        GVariantIter *iter;
        guint8 *buf = NULL;
-       guint size = 0;
        data_s *result = NULL;
 
-       if (variant == NULL)
-               return result;
+       RETV_IF(NULL == variant, result);
 
        g_variant_get(variant, "a(y)", &iter);
 
@@ -107,28 +106,22 @@ data_s *net_nfc_util_gdbus_variant_to_data(GVariant *variant)
 
 void net_nfc_util_gdbus_variant_to_data_s(GVariant *variant, data_s *data)
 {
-       GVariantIter *iter;
-
+       guint size = 0;
        guint8 element;
+       GVariantIter *iter;
        guint8 *buf = NULL;
 
-       guint size = 0;
-
-       if (data == NULL)
-               return;
+       RET_IF(NULL == data);
+       RET_IF(NULL == variant);
 
        data->buffer = NULL;
        data->length = 0;
 
-       if (variant == NULL)
-       {
-               return;
-       }
-
        g_variant_get(variant, "a(y)", &iter);
 
        size = g_variant_iter_n_children(iter);
        buf  = g_new0(guint8, size);
+
        if (buf != NULL)
        {
                guint i = 0;
@@ -153,7 +146,7 @@ GVariant *net_nfc_util_gdbus_buffer_to_variant(const uint8_t *buffer,
 
        g_variant_builder_init(&builder, G_VARIANT_TYPE("a(y)"));
 
-       if (buffer && length > 0)
+       if (NULL == buffer || length <= 0)
        {
                int i;
 
@@ -167,75 +160,83 @@ GVariant *net_nfc_util_gdbus_buffer_to_variant(const uint8_t *buffer,
 GVariant *net_nfc_util_gdbus_data_to_variant(const data_s *data)
 {
        if (data != NULL)
-       {
-               return net_nfc_util_gdbus_buffer_to_variant(data->buffer,
-                               data->length);
-       }
+               return net_nfc_util_gdbus_buffer_to_variant(data->buffer, data->length);
        else
-       {
                return net_nfc_util_gdbus_buffer_to_variant(NULL, 0);
-       }
 }
 
 ndef_message_s *net_nfc_util_gdbus_variant_to_ndef_message(GVariant *variant)
 {
-       ndef_message_s *message = NULL;
        data_s data = { NULL, 0 };
+       ndef_message_s *temp = NULL;
+       ndef_message_s *message = NULL;
 
-       if (variant == NULL)
-               return NULL;
+       RETV_IF(NULL == variant, NULL);
 
        net_nfc_util_gdbus_variant_to_data_s(variant, &data);
 
-       if (data.buffer && data.length > 0)
-       {
-               ndef_message_s *temp = NULL;
-
-               if (net_nfc_util_create_ndef_message(&temp) == NET_NFC_OK) {
-                       if (net_nfc_util_convert_rawdata_to_ndef_message(
-                                               &data, temp) == NET_NFC_OK) {
-                               message = temp;
-                       } else {
-                               NFC_ERR("net_nfc_create_ndef_message_from_rawdata failed");
+       if (NULL == data.buffer || data.length <= 0)
+               return NULL;
 
-                               net_nfc_util_free_ndef_message(temp);
-                       }
-               } else {
-                       NFC_ERR("net_nfc_util_create_ndef_message failed");
+       if (net_nfc_util_create_ndef_message(&temp) == NET_NFC_OK)
+       {
+               if (net_nfc_util_convert_rawdata_to_ndef_message(&data, temp) == NET_NFC_OK)
+               {
+                       message = temp;
                }
+               else
+               {
+                       NFC_ERR("net_nfc_create_ndef_message_from_rawdata failed");
 
-               net_nfc_util_free_data(&data);
+                       net_nfc_util_free_ndef_message(temp);
+               }
+       }
+       else
+       {
+               NFC_ERR("net_nfc_util_create_ndef_message failed");
        }
 
+       net_nfc_util_free_data(&data);
+
        return message;
 }
 
+
 GVariant *net_nfc_util_gdbus_ndef_message_to_variant(
                const ndef_message_s *message)
 {
-       GVariant *variant = NULL;
-       data_s *data = NULL;
        size_t length;
+       net_nfc_error_e ret;
+       data_s *data = NULL;
+       GVariant *variant = NULL;
 
-       length = net_nfc_util_get_ndef_message_length(
-                       (ndef_message_s *)message);
-       if (length > 0) {
+       length = net_nfc_util_get_ndef_message_length((ndef_message_s *)message);
+       if (length > 0)
+       {
                data_s temp = { NULL, 0 };
 
-               if (net_nfc_util_alloc_data(&temp, length) == true) {
-                       if (net_nfc_util_convert_ndef_message_to_rawdata(
-                                               (ndef_message_s *)message,
-                                               &temp) == NET_NFC_OK) {
+               if (net_nfc_util_alloc_data(&temp, length) == true)
+               {
+                       ret = net_nfc_util_convert_ndef_message_to_rawdata((ndef_message_s *)message,
+                                               &temp);
+                       if (NET_NFC_OK == ret)
+                       {
                                data = &temp;
-                       } else {
+                       }
+                       else
+                       {
                                NFC_ERR("can not convert ndef_message to rawdata");
 
                                net_nfc_util_free_data(&temp);
                        }
-               } else {
+               }
+               else
+               {
                        NFC_ERR("net_nfc_util_alloc_data failed");
                }
-       } else {
+       }
+       else
+       {
                NFC_ERR("message length is 0");
        }
 
index 6cb978b..19b5db0 100755 (executable)
@@ -37,7 +37,8 @@ void net_nfc_convert_byte_order(unsigned char *array, int size)
        int i;
        unsigned char tmp_char;
 
-       for (i=0;i<size/2;i++) {
+       for ( i = 0; i < size/2; i++)
+       {
                tmp_char = array[i];
                array[i] = array[size-1-i];
                array[size-1-i] = tmp_char;
@@ -51,20 +52,15 @@ static int __property_equal_to(gconstpointer key1, gconstpointer key2)
        const net_nfc_carrier_property_s *arg2 = key2;
 
        if (arg1->attribute < arg2->attribute)
-       {
                return -1;
-       }
        else if (arg1->attribute > arg2->attribute)
-       {
                return 1;
-       }
        else
-       {
                return 0;
-       }
 }
 
-static net_nfc_carrier_property_s *__find_property_by_attrubute(GList *list, uint16_t attribute)
+static net_nfc_carrier_property_s *__find_property_by_attrubute(GList *list,
+               uint16_t attribute)
 {
        GList *found = NULL;
        net_nfc_carrier_property_s temp;
@@ -72,28 +68,25 @@ static net_nfc_carrier_property_s *__find_property_by_attrubute(GList *list, uin
        temp.attribute = attribute;
        found = g_list_find_custom(list, &temp, __property_equal_to);
 
-       if (found == NULL)
-       {
+       if (NULL == found)
                return NULL;
-       }
 
        return (net_nfc_carrier_property_s *)found->data;
 }
 
 static void __find_nth_group(gpointer data, gpointer user_data)
 {
-       net_nfc_carrier_property_s *info = data;
        search_index *nth = user_data;
+       net_nfc_carrier_property_s *info = data;
 
-       if (info == NULL || user_data == NULL)
-               return;
+       RET_IF(NULL == info);
+       RET_IF(NULL == user_data);
 
        if (info->is_group)
        {
                if (nth->current == nth->target)
-               {
                        nth->found = data;
-               }
+
                nth->current++;
        }
 }
@@ -102,8 +95,7 @@ static void __free_all_data(gpointer data, gpointer user_data)
 {
        net_nfc_carrier_property_s *info = data;
 
-       if (info == NULL)
-               return;
+       RET_IF(NULL == info);
 
        if (info->is_group)
        {
@@ -112,22 +104,25 @@ static void __free_all_data(gpointer data, gpointer user_data)
        }
        else
        {
-               NFC_DBG("FREE: element is found ATTRIB:0x%X length:%d", info->attribute, info->length);
+               NFC_DBG("FREE: element is found ATTRIB:0x%X length:%d",
+                               info->attribute, info->length);
                _net_nfc_util_free_mem(info->data);
                _net_nfc_util_free_mem(info);
        }
 }
 
-static net_nfc_error_e __net_nfc_util_create_connection_handover_collsion_resolution_record(ndef_record_s **record)
+static net_nfc_error_e
+       __net_nfc_util_create_connection_handover_collsion_resolution_record(
+       ndef_record_s **record)
 {
+
        uint32_t state = 0;
-       data_s typeName = { 0 };
+       uint16_t random_num;
        data_s payload = { 0 };
+       data_s typeName = { 0 };
        uint8_t rand_buffer[2] = { 0, 0 };
-       uint16_t random_num;
 
-       if (record == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
 
        state = (uint32_t)time(NULL);
        random_num = (unsigned short)rand_r(&state);
@@ -141,9 +136,11 @@ static net_nfc_error_e __net_nfc_util_create_connection_handover_collsion_resolu
        payload.buffer = rand_buffer;
        payload.length = 2;
 
-       NFC_DBG("rand number = [0x%x] [0x%x] => [0x%x]", payload.buffer[0], payload.buffer[1], random_num);
+       NFC_DBG("rand number = [0x%x] [0x%x] => [0x%x]",
+               payload.buffer[0], payload.buffer[1], random_num);
 
-       return net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &typeName, NULL, &payload, record);
+       return net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE,
+               &typeName, NULL, &payload, record);
 }
 
 static int __net_nfc_get_size_of_attribute(int attribute)
@@ -173,23 +170,16 @@ static int __net_nfc_get_size_of_attribute(int attribute)
        }
 }
 
-net_nfc_error_e net_nfc_util_create_carrier_config(net_nfc_carrier_config_s **config, net_nfc_conn_handover_carrier_type_e type)
+net_nfc_error_e net_nfc_util_create_carrier_config(
+       net_nfc_carrier_config_s **config, net_nfc_conn_handover_carrier_type_e type)
 {
-       if (config == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
-
-       if (type < 0 || type >= NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
-       {
-               return NET_NFC_OUT_OF_BOUND;
-       }
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
+       RETV_IF(type < 0, NET_NFC_OUT_OF_BOUND);
+       RETV_IF(type >= NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN, NET_NFC_OUT_OF_BOUND);
 
        _net_nfc_util_alloc_mem(*config, sizeof(net_nfc_carrier_config_s));
-       if (*config == NULL)
-       {
+       if (NULL == *config)
                return NET_NFC_ALLOC_FAIL;
-       }
 
        (*config)->type = type;
        (*config)->length = 0;
@@ -204,27 +194,22 @@ net_nfc_error_e net_nfc_util_add_carrier_config_property(
 
        NFC_DBG("ADD property: [ATTRIB:0x%X, SIZE:%d]", attribute, size);
 
-       if (config == NULL || data == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
 
        if (__find_property_by_attrubute(config->data, attribute) != NULL)
-       {
                return NET_NFC_ALREADY_REGISTERED;
-       }
 
        _net_nfc_util_alloc_mem(elem, sizeof (net_nfc_carrier_property_s));
-       if (elem == NULL)
-       {
+       if (NULL == elem)
                return NET_NFC_ALLOC_FAIL;
-       }
+
        elem->attribute = attribute;
        elem->length = size;
        elem->is_group = false;
 
        _net_nfc_util_alloc_mem(elem->data, size);
-       if (elem->data == NULL)
+       if (NULL == elem->data)
        {
                _net_nfc_util_free_mem(elem);
                return NET_NFC_ALLOC_FAIL;
@@ -244,16 +229,11 @@ net_nfc_error_e net_nfc_util_remove_carrier_config_property(
 {
        net_nfc_carrier_property_s *elem = NULL;
 
-       if (config == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
 
        elem = __find_property_by_attrubute(config->data, attribute);
-       if (elem == NULL)
-       {
+       if (NULL == elem)
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        config->data = g_list_remove(config->data, elem);
        config->length -= (elem->length + 2 * __net_nfc_get_size_of_attribute(attribute));
@@ -279,11 +259,12 @@ net_nfc_error_e net_nfc_util_get_carrier_config_property(
 {
        net_nfc_carrier_property_s *elem = NULL;
 
-       if (config == NULL || size == NULL || data == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == size, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
 
        elem = __find_property_by_attrubute(config->data, attribute);
-       if (elem == NULL)
+       if (NULL == elem)
        {
                *size = 0;
                *data = NULL;
@@ -302,8 +283,8 @@ net_nfc_error_e net_nfc_util_get_carrier_config_property(
 net_nfc_error_e net_nfc_util_append_carrier_config_group(
                net_nfc_carrier_config_s *config, net_nfc_carrier_property_s *group)
 {
-       if (config == NULL || group == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
 
        if (g_list_find(config->data, group) != NULL)
                return NET_NFC_ALREADY_REGISTERED;
@@ -317,15 +298,11 @@ net_nfc_error_e net_nfc_util_append_carrier_config_group(
 net_nfc_error_e net_nfc_util_remove_carrier_config_group(
                net_nfc_carrier_config_s *config, net_nfc_carrier_property_s *group)
 {
-       if (config == NULL || group == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
 
        if (g_list_find(config->data, group) != NULL)
-       {
                return NET_NFC_NO_DATA_FOUND;
-       }
 
        config->length -= group->length;
        config->data = g_list_remove(config->data, group);
@@ -340,15 +317,9 @@ net_nfc_error_e net_nfc_util_get_carrier_config_group(
 {
        search_index result;
 
-       if (config == NULL || group == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
-
-       if (index < 0)
-       {
-               return NET_NFC_OUT_OF_BOUND;
-       }
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
+       RETV_IF(index < 0, NET_NFC_OUT_OF_BOUND);
 
        result.current = 0;
        result.target = index;
@@ -356,10 +327,9 @@ net_nfc_error_e net_nfc_util_get_carrier_config_group(
 
        g_list_foreach(config->data, __find_nth_group, &result);
 
-       if (result.found == NULL)
-       {
+       if (NULL == result.found)
                return NET_NFC_NO_DATA_FOUND;
-       }
+
        *group = (net_nfc_carrier_property_s *)result.found;
 
        return NET_NFC_OK;
@@ -367,10 +337,7 @@ net_nfc_error_e net_nfc_util_get_carrier_config_group(
 
 net_nfc_error_e net_nfc_util_free_carrier_config(net_nfc_carrier_config_s *config)
 {
-       if (config == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
 
        g_list_foreach(config->data, __free_all_data, NULL);
        g_list_free(config->data);
@@ -383,16 +350,11 @@ net_nfc_error_e net_nfc_util_free_carrier_config(net_nfc_carrier_config_s *confi
 net_nfc_error_e net_nfc_util_create_carrier_config_group(
                net_nfc_carrier_property_s **group, uint16_t attribute)
 {
-       if (group == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
 
        _net_nfc_util_alloc_mem(*group, sizeof(net_nfc_carrier_property_s));
-       if (*group == NULL)
-       {
+       if (NULL == *group)
                return NET_NFC_ALLOC_FAIL;
-       }
 
        (*group)->attribute = attribute;
        (*group)->is_group = true;
@@ -407,27 +369,22 @@ net_nfc_error_e net_nfc_util_add_carrier_config_group_property(
 
        NFC_DBG("ADD group property: [ATTRIB:0x%X, SIZE:%d]", attribute, size);
 
-       if (group == NULL || data == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
 
        if (__find_property_by_attrubute((GList *)group->data, attribute) != NULL)
-       {
                return NET_NFC_ALREADY_REGISTERED;
-       }
 
        _net_nfc_util_alloc_mem(elem, sizeof (net_nfc_carrier_property_s));
-       if (elem == NULL)
-       {
+       if (NULL == elem)
                return NET_NFC_ALLOC_FAIL;
-       }
+
        elem->attribute = attribute;
        elem->length = size;
        elem->is_group = false;
 
        _net_nfc_util_alloc_mem(elem->data, size);
-       if (elem->data == NULL)
+       if (NULL == elem->data)
        {
                _net_nfc_util_free_mem(elem);
                return NET_NFC_ALLOC_FAIL;
@@ -449,13 +406,12 @@ net_nfc_error_e net_nfc_util_get_carrier_config_group_property(
 {
        net_nfc_carrier_property_s *elem = NULL;
 
-       if (group == NULL || size == NULL || data == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == size, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
 
        elem = __find_property_by_attrubute((GList*)(group->data), attribute);
-       if (elem == NULL)
+       if (NULL == elem)
        {
                *size = 0;
                *data = NULL;
@@ -473,16 +429,12 @@ net_nfc_error_e net_nfc_util_remove_carrier_config_group_property(
 {
        net_nfc_carrier_property_s *elem = NULL;
 
-       if (group == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
 
        elem = __find_property_by_attrubute((GList*)(group->data), attribute);
-       if (elem == NULL)
-       {
+       if (NULL == elem)
                return NET_NFC_NO_DATA_FOUND;
-       }
+
        group->length -= elem->length;
        group->data = g_list_remove((GList*)(group->data), elem);
 
@@ -495,10 +447,8 @@ net_nfc_error_e net_nfc_util_remove_carrier_config_group_property(
 
 net_nfc_error_e net_nfc_util_free_carrier_group(net_nfc_carrier_property_s *group)
 {
-       if (group == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+
        g_list_foreach((GList*)(group->data), __free_all_data, NULL);
        g_list_free((GList*)(group->data));
 
@@ -509,13 +459,13 @@ net_nfc_error_e net_nfc_util_free_carrier_group(net_nfc_carrier_property_s *grou
 
 static void __make_serial_wifi(gpointer data, gpointer user_data)
 {
-       net_nfc_carrier_property_s *info = data;
-       data_s *payload = user_data;
-       uint8_t *current;
        int inc = 0;
+       uint8_t *current;
+       data_s *payload = user_data;
+       net_nfc_carrier_property_s *info = data;
 
-       if (info == NULL || user_data == NULL)
-               return;
+       RET_IF(NULL == info);
+       RET_IF(NULL == user_data);
 
        current = payload->buffer + payload->length;
        inc = __net_nfc_get_size_of_attribute(info->attribute);
@@ -532,7 +482,8 @@ static void __make_serial_wifi(gpointer data, gpointer user_data)
        }
        else
        {
-               NFC_DBG("[WIFI]Element is found attrib:0x%X length:%d current:%d", info->attribute, info->length, payload->length);
+               NFC_DBG("[WIFI]Element is found attrib:0x%X length:%d current:%d",
+                               info->attribute, info->length, payload->length);
                *(uint16_t *)current = info->attribute;
                net_nfc_convert_byte_order(current,2);
                *(uint16_t *)(current + inc) = info->length;
@@ -544,13 +495,13 @@ static void __make_serial_wifi(gpointer data, gpointer user_data)
 
 static void __make_serial_bt(gpointer data, gpointer user_data)
 {
-       net_nfc_carrier_property_s *info = data;
-       data_s *payload = user_data;
-       uint8_t *current;
        int inc = 0;
+       uint8_t *current;
+       data_s *payload = user_data;
+       net_nfc_carrier_property_s *info = data;
 
-       if (info == NULL || user_data == NULL)
-               return;
+       RET_IF(NULL == info);
+       RET_IF(NULL == user_data);
 
        current = payload->buffer + payload->length; /* payload->length is zero */
 
@@ -563,7 +514,8 @@ static void __make_serial_bt(gpointer data, gpointer user_data)
        {
                if (info->attribute != NET_NFC_BT_ATTRIBUTE_ADDRESS)
                {
-                       NFC_DBG("[BT]Element is found attrib:0x%X length:%d current:%d", info->attribute, info->length, payload->length);
+                       NFC_DBG("[BT]Element is found attrib:0x%X length:%d current:%d",
+                                       info->attribute, info->length, payload->length);
                        inc = __net_nfc_get_size_of_attribute(info->attribute);
                        *current = info->length + 1;
                        *(current + inc) = info->attribute;
@@ -585,31 +537,28 @@ net_nfc_error_e net_nfc_util_create_ndef_record_with_carrier_config(
        data_s payload = { NULL, 0 };
        data_s record_type = { NULL, 0 };
 
-       if (record == NULL || config == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
 
        _net_nfc_util_alloc_mem(payload.buffer, config->length);
-       if (payload.buffer == NULL)
-       {
+       if (NULL == payload.buffer)
                return NET_NFC_ALLOC_FAIL;
-       }
+
        payload.length = 0; /* this should be zero because this will be used as current position of data written */
 
-       if (config->type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
+       if (NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS == config->type)
        {
                record_type.buffer = (uint8_t *)CONN_HANDOVER_WIFI_BSS_CARRIER_MIME_NAME;
                record_type.length = strlen(CONN_HANDOVER_WIFI_BSS_CARRIER_MIME_NAME);
                g_list_foreach(config->data, __make_serial_wifi, &payload);
        }
-       else if (config->type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_IBSS)
+       else if (NET_NFC_CONN_HANDOVER_CARRIER_WIFI_IBSS == config->type)
        {
                record_type.buffer = (uint8_t *)CONN_HANDOVER_WIFI_IBSS_CARRIER_MIME_NAME;
                record_type.length = strlen(CONN_HANDOVER_WIFI_IBSS_CARRIER_MIME_NAME);
                g_list_foreach(config->data, __make_serial_wifi, &payload);
        }
-       else if (config->type == NET_NFC_CONN_HANDOVER_CARRIER_BT)
+       else if (NET_NFC_CONN_HANDOVER_CARRIER_BT == config->type)
        {
                record_type.buffer = (uint8_t *)CONN_HANDOVER_BT_CARRIER_MIME_NAME;
                record_type.length = strlen(CONN_HANDOVER_BT_CARRIER_MIME_NAME);
@@ -627,10 +576,12 @@ net_nfc_error_e net_nfc_util_create_ndef_record_with_carrier_config(
 
        NFC_DBG("payload length = %d", payload.length);
 
-       return net_nfc_util_create_record(NET_NFC_RECORD_MIME_TYPE, &record_type, NULL, &payload, record);
+       return net_nfc_util_create_record(NET_NFC_RECORD_MIME_TYPE, &record_type, NULL,
+                       &payload, record);
 }
 
-static net_nfc_error_e __net_nfc_get_list_from_serial_for_wifi(GList **list, uint8_t *data, uint32_t length)
+static net_nfc_error_e __net_nfc_get_list_from_serial_for_wifi(
+               GList **list, uint8_t *data, uint32_t length)
 {
        uint8_t *current = data;
        uint8_t *last = current + length;
@@ -639,10 +590,9 @@ static net_nfc_error_e __net_nfc_get_list_from_serial_for_wifi(GList **list, uin
        {
                net_nfc_carrier_property_s *elem = NULL;
                _net_nfc_util_alloc_mem(elem, sizeof(net_nfc_carrier_property_s));
-               if (elem == NULL)
-               {
+               if (NULL == elem)
                        return NET_NFC_ALLOC_FAIL;
-               }
+
                elem->attribute = current[0]<<8|current[1];
                elem->length = current[2]<<8|current[3];
 
@@ -654,7 +604,7 @@ static net_nfc_error_e __net_nfc_get_list_from_serial_for_wifi(GList **list, uin
                else
                {
                        _net_nfc_util_alloc_mem(elem->data, elem->length);
-                       if (elem->data == NULL)
+                       if (NULL == elem->data)
                        {
                                _net_nfc_util_free_mem(elem);
                                return NET_NFC_ALLOC_FAIL;
@@ -671,23 +621,22 @@ static net_nfc_error_e __net_nfc_get_list_from_serial_for_wifi(GList **list, uin
 
 net_nfc_error_e __net_nfc_get_list_from_serial_for_bt(GList **list, uint8_t *data, uint32_t length)
 {
-       net_nfc_carrier_property_s *elem = NULL;
-       uint8_t *current = data;
        uint8_t *last = NULL;
+       uint8_t *current = data;
+       net_nfc_carrier_property_s *elem = NULL;
 
        current += 2; /* remove oob data length  two bytes length*/
        length -= 2;
 
        _net_nfc_util_alloc_mem(elem, sizeof(net_nfc_carrier_property_s));
-       if (elem == NULL)
-       {
+       if (NULL == elem)
                return NET_NFC_ALLOC_FAIL;
-       }
+
        elem->attribute = (uint16_t)NET_NFC_BT_ATTRIBUTE_ADDRESS;
        elem->length = 6; /* BT address length is always 6 */
 
        _net_nfc_util_alloc_mem(elem->data, elem->length);
-       if (elem->data == NULL)
+       if (NULL == elem->data)
        {
                _net_nfc_util_free_mem(elem);
                return NET_NFC_ALLOC_FAIL;
@@ -704,15 +653,14 @@ net_nfc_error_e __net_nfc_get_list_from_serial_for_bt(GList **list, uint8_t *dat
        while (current < last)
        {
                _net_nfc_util_alloc_mem(elem, sizeof(net_nfc_carrier_property_s));
-               if (elem == NULL)
-               {
+               if (NULL == elem)
                        return NET_NFC_ALLOC_FAIL;
-               }
+
                elem->length = *((uint8_t *)current) - 1;
                elem->attribute = *((uint8_t *)(++current));
 
                _net_nfc_util_alloc_mem(elem->data, elem->length);
-               if (elem->data == NULL)
+               if (NULL == elem->data)
                {
                        _net_nfc_util_free_mem(elem);
                        return NET_NFC_ALLOC_FAIL;
index 6aed70a..1bbb629 100644 (file)
@@ -26,22 +26,20 @@ static net_nfc_error_e __net_nfc_repair_record_flags(ndef_message_s *ndef_messag
 net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
                data_s *rawdata, ndef_message_s *ndef)
 {
-       ndef_record_s *newRec = NULL;
-       ndef_record_s *prevRec = NULL;
-       uint8_t *current = NULL;
        uint8_t *last = NULL;
+       uint8_t *current = NULL;
        uint8_t ndef_header = 0;
+       ndef_record_s *newRec = NULL;
+       ndef_record_s *prevRec = NULL;
        net_nfc_error_e result = NET_NFC_OK;
 
-       if (rawdata == NULL || ndef == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == ndef, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
+       RETV_IF(rawdata->length < 3, NET_NFC_INVALID_FORMAT);
 
        current = rawdata->buffer;
        last = current + rawdata->length;
 
-       if(rawdata->length < 3)
-               return NET_NFC_INVALID_FORMAT;
-
        for(ndef->recordCount = 0; current < last; ndef->recordCount++)
        {
                ndef_header = *current++;
@@ -58,7 +56,7 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
                }
 
                _net_nfc_util_alloc_mem(newRec, sizeof(ndef_record_s));
-               if (newRec == NULL)
+               if (NULL == newRec)
                {
                        result = NET_NFC_ALLOC_FAIL;
                        goto error;
@@ -66,25 +64,19 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
 
                /* ndef header set */
                if (ndef_header & NET_NFC_NDEF_RECORD_MASK_MB)
-               {
                        newRec->MB = 1;
-               }
+
                if (ndef_header & NET_NFC_NDEF_RECORD_MASK_ME)
-               {
                        newRec->ME = 1;
-               }
+
                if (ndef_header & NET_NFC_NDEF_RECORD_MASK_CF)
-               {
                        newRec->CF = 1;
-               }
+
                if (ndef_header & NET_NFC_NDEF_RECORD_MASK_SR)
-               {
                        newRec->SR = 1;
-               }
+
                if (ndef_header & NET_NFC_NDEF_RECORD_MASK_IL)
-               {
                        newRec->IL = 1;
-               }
 
                newRec->TNF = ndef_header & NET_NFC_NDEF_RECORD_MASK_TNF;
 
@@ -112,21 +104,17 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
 
                /* ID length check */
                if(ndef_header & NET_NFC_NDEF_RECORD_MASK_IL)
-               {
                        newRec->id_s.length = *current++;
-               }
                else
-               {
                        newRec->id_s.length = 0;
-               }
 
                /* to do : chunked record */
 
-
                /* empty record check */
                if((ndef_header & NET_NFC_NDEF_RECORD_MASK_TNF) == NET_NFC_NDEF_TNF_EMPTY)
                {
-                       if(newRec->type_s.length != 0 || newRec->id_s.length != 0 || newRec->payload_s.length != 0)
+                       if(newRec->type_s.length != 0 || newRec->id_s.length != 0
+                               || newRec->payload_s.length != 0)
                        {
                                result = NET_NFC_INVALID_FORMAT;
                                goto error;
@@ -146,7 +134,7 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
                if(newRec->type_s.length > 0)
                {
                        _net_nfc_util_alloc_mem(newRec->type_s.buffer, newRec->type_s.length);
-                       if (newRec->type_s.buffer == NULL)
+                       if (NULL == newRec->type_s.buffer)
                        {
                                result = NET_NFC_ALLOC_FAIL;
                                goto error;
@@ -164,7 +152,7 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
                if(newRec->id_s.length > 0)
                {
                        _net_nfc_util_alloc_mem(newRec->id_s.buffer, newRec->id_s.length);
-                       if (newRec->id_s.buffer == NULL)
+                       if (NULL == newRec->id_s.buffer)
                        {
                                result = NET_NFC_ALLOC_FAIL;
                                goto error;
index 207fc1d..669052c 100644 (file)
@@ -22,8 +22,7 @@
 
 net_nfc_error_e net_nfc_util_free_record(ndef_record_s *record)
 {
-       if (record == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
 
        if (record->type_s.buffer != NULL)
                _net_nfc_util_free_mem(record->type_s.buffer);
@@ -43,14 +42,15 @@ net_nfc_error_e net_nfc_util_create_record(net_nfc_record_tnf_e recordType,
 {
        ndef_record_s *record_temp = NULL;
 
-       if (typeName == NULL || payload == NULL || record == NULL)
-               return NET_NFC_NULL_PARAMETER;
+       RETV_IF(NULL == typeName, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == payload, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
 
-       if (recordType < NET_NFC_RECORD_EMPTY || recordType > NET_NFC_RECORD_UNCHAGNED)
-               return NET_NFC_OUT_OF_BOUND;
+       RETV_IF(recordType < NET_NFC_RECORD_EMPTY, NET_NFC_OUT_OF_BOUND);
+       RETV_IF(recordType > NET_NFC_RECORD_UNCHAGNED, NET_NFC_OUT_OF_BOUND);
 
        /* empty_tag */
-       if (recordType == NET_NFC_RECORD_EMPTY)
+       if (NET_NFC_RECORD_EMPTY == recordType)
        {
                if ((typeName->buffer != NULL) || (payload->buffer != NULL)
                                || (id->buffer != NULL) || (typeName->length != 0) || (payload->length != 0)
@@ -61,7 +61,7 @@ net_nfc_error_e net_nfc_util_create_record(net_nfc_record_tnf_e recordType,
        }
 
        _net_nfc_util_alloc_mem(record_temp, sizeof(ndef_record_s));
-       if (record_temp == NULL)
+       if (NULL == record_temp)
                return NET_NFC_ALLOC_FAIL;
 
        // set type name and length and  TNF field
@@ -71,7 +71,7 @@ net_nfc_error_e net_nfc_util_create_record(net_nfc_record_tnf_e recordType,
        if(record_temp->type_s.length > 0)
        {
                _net_nfc_util_alloc_mem(record_temp->type_s.buffer, record_temp->type_s.length);
-               if (record_temp->type_s.buffer == NULL)
+               if (NULL == record_temp->type_s.buffer)
                {
                        _net_nfc_util_free_mem(record_temp);
 
@@ -90,8 +90,10 @@ net_nfc_error_e net_nfc_util_create_record(net_nfc_record_tnf_e recordType,
        record_temp->payload_s.length = payload->length;
        if(payload->length >0)
        {
-               _net_nfc_util_alloc_mem(record_temp->payload_s.buffer, record_temp->payload_s.length);
-               if (record_temp->payload_s.buffer == NULL)
+               _net_nfc_util_alloc_mem(record_temp->payload_s.buffer,
+                       record_temp->payload_s.length);
+
+               if (NULL == record_temp->payload_s.buffer)
                {
                        _net_nfc_util_free_mem(record_temp->type_s.buffer);
                        _net_nfc_util_free_mem(record_temp);
@@ -99,7 +101,8 @@ net_nfc_error_e net_nfc_util_create_record(net_nfc_record_tnf_e recordType,
                        return NET_NFC_ALLOC_FAIL;
                }
 
-               memcpy(record_temp->payload_s.buffer, payload->buffer, record_temp->payload_s.length);
+               memcpy(record_temp->payload_s.buffer, payload->buffer,
+                       record_temp->payload_s.length);
        }
        else
        {
@@ -108,20 +111,16 @@ net_nfc_error_e net_nfc_util_create_record(net_nfc_record_tnf_e recordType,
        }
 
        if (payload->length < 256)
-       {
                record_temp->SR = 1;
-       }
        else
-       {
                record_temp->SR = 0;
-       }
 
        // set id and id length and IL field
        if (id != NULL && id->buffer != NULL && id->length > 0)
        {
                record_temp->id_s.length = id->length;
                _net_nfc_util_alloc_mem(record_temp->id_s.buffer, record_temp->id_s.length);
-               if (record_temp->id_s.buffer == NULL)
+               if (NULL == record_temp->id_s.buffer)
                {
                        _net_nfc_util_free_mem(record_temp->payload_s.buffer);
                        _net_nfc_util_free_mem(record_temp->type_s.buffer);
@@ -151,28 +150,22 @@ net_nfc_error_e net_nfc_util_create_record(net_nfc_record_tnf_e recordType,
        return NET_NFC_OK;
 }
 
-net_nfc_error_e net_nfc_util_create_uri_type_record(const char *uri, net_nfc_schema_type_e protocol_schema, ndef_record_s **record)
+net_nfc_error_e net_nfc_util_create_uri_type_record(const char *uri,
+               net_nfc_schema_type_e protocol_schema, ndef_record_s **record)
 {
-       net_nfc_error_e error;
        data_s type_data;
+       net_nfc_error_e error;
        data_s payload_data = { NULL, 0 };
 
-       if (uri == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == uri, NET_NFC_NULL_PARAMETER);
 
        payload_data.length = strlen((char *)uri) + 1;
-       if (payload_data.length == 1)
-       {
-               return NET_NFC_INVALID_PARAM;
-       }
+
+       RETV_IF(1 == payload_data.length, NET_NFC_INVALID_PARAM);
 
        _net_nfc_util_alloc_mem(payload_data.buffer, payload_data.length);
-       if (payload_data.buffer == NULL)
-       {
+       if (NULL == payload_data.buffer)
                return NET_NFC_ALLOC_FAIL;
-       }
 
        payload_data.buffer[0] = protocol_schema;       /* first byte of payload is protocol scheme */
        memcpy(payload_data.buffer + 1, uri, payload_data.length - 1);
@@ -180,40 +173,38 @@ net_nfc_error_e net_nfc_util_create_uri_type_record(const char *uri, net_nfc_sch
        type_data.length = 1;
        type_data.buffer = (uint8_t *)URI_RECORD_TYPE;
 
-       error = net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type_data, NULL, &payload_data, record);
+       error = net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE,
+                       &type_data, NULL, &payload_data, record);
 
        _net_nfc_util_free_mem(payload_data.buffer);
 
        return error;
 }
 
-net_nfc_error_e net_nfc_util_create_text_type_record(const char *text, const char *lang_code_str, net_nfc_encode_type_e encode, ndef_record_s **record)
+net_nfc_error_e net_nfc_util_create_text_type_record(const char *text,
+       const char *lang_code_str, net_nfc_encode_type_e encode, ndef_record_s **record)
 {
+       int offset = 0;
        data_s type_data;
-       data_s payload_data;
        int controll_byte;
-       int offset = 0;
+       data_s payload_data;
 
-       if (text == NULL || lang_code_str == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == text, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == lang_code_str, NET_NFC_NULL_PARAMETER);
 
-       if ((encode < NET_NFC_ENCODE_UTF_8 || encode > NET_NFC_ENCODE_UTF_16))
-       {
-               return NET_NFC_OUT_OF_BOUND;
-       }
+       RETVM_IF(encode < NET_NFC_ENCODE_UTF_8 || NET_NFC_ENCODE_UTF_16 < encode ,
+               NET_NFC_OUT_OF_BOUND, "encode(%d) is invalid", encode);
 
        payload_data.length = strlen((char *)text) + strlen(lang_code_str) + 1;
 
        _net_nfc_util_alloc_mem(payload_data.buffer, payload_data.length);
-       if (payload_data.buffer == NULL)
+       if (NULL == payload_data.buffer)
        {
                return NET_NFC_ALLOC_FAIL;
        }
 
        controll_byte = strlen(lang_code_str) & 0x3F;
-       if (encode == NET_NFC_ENCODE_UTF_16)
+       if (NET_NFC_ENCODE_UTF_16 == encode)
        {
                controll_byte = controll_byte | 0x80;
        }
@@ -229,35 +220,29 @@ net_nfc_error_e net_nfc_util_create_text_type_record(const char *text, const cha
        type_data.length = 1;
        type_data.buffer = (uint8_t *)TEXT_RECORD_TYPE;
 
-       net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type_data, NULL, &payload_data, record);
+       net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type_data, NULL,
+               &payload_data, record);
 
        _net_nfc_util_free_mem(payload_data.buffer);
 
        return NET_NFC_OK;
 }
 
-net_nfc_error_e net_nfc_util_set_record_id(ndef_record_s *record, uint8_t *data, int length)
+net_nfc_error_e net_nfc_util_set_record_id(ndef_record_s *record,
+       uint8_t *data, int length)
 {
-       if (record == NULL || data == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
-
-       if (length < 1)
-       {
-               return NET_NFC_OUT_OF_BOUND;
-       }
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
+       RETV_IF(length < 1, NET_NFC_OUT_OF_BOUND);
 
        if (record->id_s.buffer != NULL && record->id_s.length > 0)
-       {
                _net_nfc_util_free_mem(record->id_s.buffer);
-       }
 
        _net_nfc_util_alloc_mem(record->id_s.buffer, length);
+
        if (record->id_s.buffer == NULL)
-       {
                return NET_NFC_ALLOC_FAIL;
-       }
+
        memcpy(record->id_s.buffer, data, length);
        record->id_s.length = length;
        record->IL = 1;
@@ -269,8 +254,7 @@ uint32_t net_nfc_util_get_record_length(ndef_record_s *Record)
 {
        uint32_t RecordLength = 1;
 
-       if (Record == NULL)
-               return 0;
+       RETV_IF(NULL == Record, 0);
 
        /* Type length is present only for following TNF
           NET_NFC_TNF_NFCWELLKNOWN
@@ -302,9 +286,7 @@ uint32_t net_nfc_util_get_record_length(ndef_record_s *Record)
 
        /* for non empty record */
        if (Record->TNF != NET_NFC_NDEF_TNF_EMPTY)
-       {
                RecordLength += Record->payload_s.length;
-       }
 
        /* ID and IDlength are present only if IL flag is set*/
        if (Record->IL != 0)
@@ -317,18 +299,17 @@ uint32_t net_nfc_util_get_record_length(ndef_record_s *Record)
        return RecordLength;
 }
 
-net_nfc_error_e net_nfc_util_create_uri_string_from_uri_record(ndef_record_s *record, char **uri)
+net_nfc_error_e net_nfc_util_create_uri_string_from_uri_record(
+       ndef_record_s *record, char **uri)
 {
        net_nfc_error_e result = NET_NFC_OK;
 
-       if (record == NULL || uri == NULL)
-       {
-               return NET_NFC_INVALID_PARAM;
-       }
+       RETV_IF(NULL == uri, NET_NFC_INVALID_PARAM);
+       RETV_IF(NULL == record, NET_NFC_INVALID_PARAM);
 
        *uri = NULL;
 
-       if (record->TNF == NET_NFC_RECORD_WELL_KNOWN_TYPE &&
+       if (NET_NFC_RECORD_WELL_KNOWN_TYPE == record->TNF &&
                        (record->type_s.length == 1 && record->type_s.buffer[0] == 'U'))
        {
                data_s *payload = &record->payload_s;
@@ -341,9 +322,7 @@ net_nfc_error_e net_nfc_util_create_uri_string_from_uri_record(ndef_record_s *re
                        /* buffer length include a schema byte.
                         * so it does not need to allocate one more byte for string. */
                        if ((scheme = net_nfc_util_get_schema_string(payload->buffer[0])) != NULL)
-                       {
                                length = strlen(scheme);
-                       }
 
                        *uri = (char *)calloc(1, length + payload->length);
                        if (*uri != NULL)
@@ -362,7 +341,7 @@ net_nfc_error_e net_nfc_util_create_uri_string_from_uri_record(ndef_record_s *re
                        NFC_ERR("invalid payload in record");
                }
        }
-       else if (record->TNF == NET_NFC_RECORD_URI)
+       else if (NET_NFC_RECORD_URI == record->TNF)
        {
                data_s *type = &record->type_s;
 
@@ -371,13 +350,9 @@ net_nfc_error_e net_nfc_util_create_uri_string_from_uri_record(ndef_record_s *re
                        *uri = (char *)calloc(1, type->length + 1);
 
                        if (*uri != NULL)
-                       {
                                memcpy(*uri, type->buffer, type->length);
-                       }
                        else
-                       {
                                result = NET_NFC_ALLOC_FAIL;
-                       }
                }
        }
        else
index f72ed3e..0e75387 100644 (file)
@@ -44,7 +44,8 @@
 //     return x509;
 //}
 
-static X509 *_load_certificate_from_mem(int format, uint8_t *buffer, uint32_t length, char *password)
+static X509 *_load_certificate_from_mem(int format, uint8_t *buffer,
+       uint32_t length, char *password)
 {
        X509 *x509 = NULL;
        BIO *mem = NULL;
@@ -138,13 +139,9 @@ net_nfc_openssl_verify_context_s *net_nfc_util_openssl_init_verify_certificate(v
        {
                result->store = X509_STORE_new();
                if (result->store != NULL)
-               {
                        OpenSSL_add_all_algorithms();
-               }
                else
-               {
                        NFC_ERR("X509_STORE_new failed");
-               }
        }
        else
        {
@@ -154,7 +151,8 @@ net_nfc_openssl_verify_context_s *net_nfc_util_openssl_init_verify_certificate(v
        return result;
 }
 
-void net_nfc_util_openssl_release_verify_certificate(net_nfc_openssl_verify_context_s *context)
+void net_nfc_util_openssl_release_verify_certificate(
+       net_nfc_openssl_verify_context_s *context)
 {
        if (context != NULL)
        {
@@ -168,7 +166,8 @@ void net_nfc_util_openssl_release_verify_certificate(net_nfc_openssl_verify_cont
        }
 }
 
-bool net_nfc_util_openssl_add_certificate_of_signer(net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
+bool net_nfc_util_openssl_add_certificate_of_signer(
+       net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
 {
        bool result = false;
 
@@ -185,24 +184,24 @@ bool net_nfc_util_openssl_add_certificate_of_signer(net_nfc_openssl_verify_conte
        return result;
 }
 
-bool net_nfc_util_openssl_add_certificate_of_ca(net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
+bool net_nfc_util_openssl_add_certificate_of_ca(
+       net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
 {
-       bool result = false;
        X509 *x509 = NULL;
+       bool result = false;
 
        x509 = _load_certificate_from_mem(1, buffer, length, NULL);
        if (x509 != NULL)
        {
                if (X509_STORE_add_cert(context->store, x509))
-               {
                        result = true;
-               }
        }
 
        return result;
 }
 
-int net_nfc_util_openssl_verify_certificate(net_nfc_openssl_verify_context_s *context)
+int net_nfc_util_openssl_verify_certificate(
+       net_nfc_openssl_verify_context_s *context)
 {
        int result = 0;
        X509_STORE_CTX *store_ctx = NULL;
@@ -212,13 +211,9 @@ int net_nfc_util_openssl_verify_certificate(net_nfc_openssl_verify_context_s *co
        {
                X509_STORE_set_flags(context->store, 0);
                if (X509_STORE_CTX_init(store_ctx, context->store, context->signer_cert, 0) == true)
-               {
                        result = X509_verify_cert(store_ctx);
-               }
                else
-               {
                        NFC_ERR("X509_STORE_CTX_init failed");
-               }
 
                X509_STORE_CTX_free(store_ctx);
        }
@@ -255,13 +250,9 @@ static int _load_pkcs12(BIO *in, const char *password, EVP_PKEY **pkey, X509 **c
        if ((p12 = d2i_PKCS12_bio(in, NULL)) != NULL)
        {
                if (PKCS12_verify_mac(p12, password, strlen(password)) == true)
-               {
                        ret = PKCS12_parse(p12, password, pkey, cert, ca);
-               }
                else
-               {
                        NFC_ERR("Mac verify error (wrong password?) in PKCS12 file");
-               }
 
                PKCS12_free(p12);
        }
@@ -278,21 +269,19 @@ EVP_PKEY *_load_key(const char *file, int format, const char *pass, ENGINE *e)
        BIO *key = NULL;
        EVP_PKEY *pkey = NULL;
 
-       if (file == NULL)
+       if (NULL == file)
        {
                NFC_ERR("no keyfile specified\n");
                return pkey;
        }
 
-       if (format == OPENSSL_FORMAT_ENGINE)
+       if (OPENSSL_FORMAT_ENGINE == format)
        {
                if (e != NULL)
                {
                        pkey = ENGINE_load_private_key(e, file, NULL/*ui_method*/, (void *)pass);
                        if (!pkey)
-                       {
                                NFC_ERR("cannot load key from engine");
-                       }
                }
                else
                {
@@ -312,14 +301,13 @@ EVP_PKEY *_load_key(const char *file, int format, const char *pass, ENGINE *e)
                                        break;
 
                                case OPENSSL_FORMAT_PEM :
-                                       pkey = PEM_read_bio_PrivateKey(key, NULL, (pem_password_cb *)_password_callback, (void *)pass);
+                                       pkey = PEM_read_bio_PrivateKey(key, NULL,
+                                               (pem_password_cb *)_password_callback, (void *)pass);
                                        break;
 
                                case OPENSSL_FORMAT_PKCS12 :
                                        if (_load_pkcs12(key, pass, &pkey, NULL, NULL) == false)
-                                       {
                                                NFC_ERR("_load_pkcs12 failed");
-                                       }
                                        break;
 
                                case OPENSSL_FORMAT_MSBLOB :
@@ -327,7 +315,8 @@ EVP_PKEY *_load_key(const char *file, int format, const char *pass, ENGINE *e)
                                        break;
 
                                case OPENSSL_FORMAT_PVK :
-                                       pkey = b2i_PVK_bio(key, (pem_password_cb *)_password_callback, (void *)pass);
+                                       pkey = b2i_PVK_bio(key, (pem_password_cb *)_password_callback,
+                                               (void *)pass);
                                        break;
 
                                default :
@@ -351,27 +340,24 @@ EVP_PKEY *_load_key(const char *file, int format, const char *pass, ENGINE *e)
        return pkey;
 }
 
-EVP_PKEY *_load_pubkey(const char *file, int format, const char *pass, ENGINE *e, const char *key_descrip)
+EVP_PKEY *_load_pubkey(const char *file, int format,
+       const char *pass, ENGINE *e, const char *key_descrip)
 {
        BIO *key = NULL;
        EVP_PKEY *pkey = NULL;
 
-       if (file == NULL)
+       if (NULL == file)
        {
                NFC_ERR("no keyfile specified");
                return pkey;
        }
 
-       if (format == OPENSSL_FORMAT_ENGINE)
+       if (OPENSSL_FORMAT_ENGINE == format)
        {
                if (e != NULL)
-               {
                        pkey = ENGINE_load_public_key(e, file, NULL/*ui_method*/, (void *)pass);
-               }
                else
-               {
                        NFC_ERR("no engine specified");
-               }
        }
        else
        {
@@ -404,7 +390,8 @@ EVP_PKEY *_load_pubkey(const char *file, int format, const char *pass, ENGINE *e
                                case OPENSSL_FORMAT_PEMRSA :
                                        {
                                                RSA *rsa;
-                                               rsa = PEM_read_bio_RSAPublicKey(key, NULL, (pem_password_cb *)_password_callback, (void *)pass);
+                                               rsa = PEM_read_bio_RSAPublicKey(key, NULL,
+                                                       (pem_password_cb *)_password_callback, (void *)pass);
                                                if (rsa)
                                                {
                                                        pkey = EVP_PKEY_new();
@@ -418,7 +405,8 @@ EVP_PKEY *_load_pubkey(const char *file, int format, const char *pass, ENGINE *e
                                        break;
 
                                case OPENSSL_FORMAT_PEM :
-                                       pkey = PEM_read_bio_PUBKEY(key, NULL, (pem_password_cb *)_password_callback, (void *)pass);
+                                       pkey = PEM_read_bio_PUBKEY(key, NULL,
+                                               (pem_password_cb *)_password_callback, (void *)pass);
                                        break;
 
                                case OPENSSL_FORMAT_MSBLOB :
@@ -446,12 +434,13 @@ EVP_PKEY *_load_pubkey(const char *file, int format, const char *pass, ENGINE *e
        return pkey;
 }
 
-int net_nfc_util_openssl_sign_buffer(uint32_t type, uint8_t *buffer, uint32_t length, char *key_file, char *password, uint8_t *sign, uint32_t *sign_len)
+int net_nfc_util_openssl_sign_buffer(uint32_t type, uint8_t *buffer,
+       uint32_t length, char *key_file, char *password, uint8_t *sign, uint32_t *sign_len)
 {
+       EVP_PKEY *pkey;
+       ENGINE *engine;
        int result = 0;
        const EVP_MD *md = NULL;
-       ENGINE *engine;
-       EVP_PKEY *pkey;
 
        OpenSSL_add_all_algorithms();
 
@@ -507,12 +496,13 @@ int net_nfc_util_openssl_sign_buffer(uint32_t type, uint8_t *buffer, uint32_t le
        return result;
 }
 
-int net_nfc_util_openssl_verify_signature(uint32_t type, uint8_t *buffer, uint32_t length, uint8_t *cert, uint32_t cert_len, uint8_t *sign, uint32_t sign_len)
+int net_nfc_util_openssl_verify_signature(uint32_t type, uint8_t *buffer,
+       uint32_t length, uint8_t *cert, uint32_t cert_len, uint8_t *sign, uint32_t sign_len)
 {
+       EVP_PKEY *pkey;
        int result = 0;
-       const EVP_MD *md = NULL;
        ENGINE *engine;
-       EVP_PKEY *pkey;
+       const EVP_MD *md = NULL;
 
        OpenSSL_add_all_algorithms();
 
@@ -650,7 +640,8 @@ int net_nfc_util_get_cert_list_from_file(char *file_name, char *password, uint8_
 #endif
 
 /* TODO : DER?? PEM?? */
-int net_nfc_util_get_cert_list_from_file(char *file_name, char *password, uint8_t **buffer, uint32_t *length, uint32_t *cert_count)
+int net_nfc_util_get_cert_list_from_file(char *file_name, char *password,
+       uint8_t **buffer, uint32_t *length, uint32_t *cert_count)
 {
        int result = 0;
        BIO *bio = NULL;
@@ -666,13 +657,13 @@ int net_nfc_util_get_cert_list_from_file(char *file_name, char *password, uint8_
 
                        if (_load_pkcs12(bio, password, &pkey, &x509, &ca) != 0)
                        {
-                               X509 *temp_x509;
                                int i;
+                               int32_t ret = 0;
+                               X509 *temp_x509;
+                               uint32_t count = 0;
+                               uint32_t offset = 0;
                                uint32_t temp_len = 0;
                                uint8_t *temp_buf = NULL;
-                               uint32_t offset = 0;
-                               uint32_t count = 0;
-                               int32_t ret = 0;
 
                                if ((ret = i2d_X509(x509, NULL)) > 0)
                                {
@@ -742,21 +733,20 @@ int net_nfc_util_get_cert_list_from_file(char *file_name, char *password, uint8_
        return result;
 }
 
-bool net_nfc_util_openssl_encode_base64(const uint8_t *buffer, const uint32_t buf_len, char *result, uint32_t max_len, bool new_line_char)
+bool net_nfc_util_openssl_encode_base64(const uint8_t *buffer,
+       const uint32_t buf_len, char *result, uint32_t max_len, bool new_line_char)
 {
-       bool ret = false;
        BUF_MEM *bptr;
        BIO *b64, *bmem;
+       bool ret = false;
 
-       if (buffer == NULL || buf_len == 0)
-       {
-               return ret;
-       }
+       RETV_IF(0 == buf_len, ret);
+       RETV_IF(NULL == buffer, ret);
 
        b64 = BIO_new(BIO_f_base64());
        bmem = BIO_new(BIO_s_mem());
 
-       if (new_line_char == false)
+       if (false == new_line_char)
                BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
 
        b64 = BIO_push(b64, bmem);
@@ -781,16 +771,15 @@ bool net_nfc_util_openssl_encode_base64(const uint8_t *buffer, const uint32_t bu
        return ret;
 }
 
-bool net_nfc_util_openssl_decode_base64(const char *buffer, uint8_t *result, uint32_t *out_len, bool new_line_char)
+bool net_nfc_util_openssl_decode_base64(const char *buffer, uint8_t *result,
+       uint32_t *out_len, bool new_line_char)
 {
+       char *temp;
        bool ret = false;
        unsigned int length = 0;
-       char *temp;
 
-       if (buffer == NULL || (length = strlen(buffer)) == 0)
-       {
-               return ret;
-       }
+       RETV_IF(NULL == buffer, ret);
+       RETV_IF((length = strlen(buffer)) == 0, ret);
 
        _net_nfc_util_alloc_mem(temp, length);
        if (temp != NULL)
@@ -799,7 +788,7 @@ bool net_nfc_util_openssl_decode_base64(const char *buffer, uint8_t *result, uin
 
                b64 = BIO_new(BIO_f_base64());
                bmem = BIO_new_mem_buf((void *)buffer, length);
-               if (new_line_char == false)
+               if (false == new_line_char)
                        BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
                bmem = BIO_push(b64, bmem);
 
@@ -828,16 +817,16 @@ bool net_nfc_util_openssl_decode_base64(const char *buffer, uint8_t *result, uin
        return ret;
 }
 
-bool net_nfc_util_openssl_digest(const char *algorithm, const uint8_t *buffer, const uint32_t buf_len, uint8_t *result, uint32_t *out_len)
+bool net_nfc_util_openssl_digest(const char *algorithm, const uint8_t *buffer,
+       const uint32_t buf_len, uint8_t *result, uint32_t *out_len)
 {
        const EVP_MD *md;
-       unsigned char *temp;
        bool ret = false;
+       unsigned char *temp;
 
-       if (algorithm == NULL || buffer == NULL || buf_len == 0)
-       {
-               return ret;
-       }
+       RETV_IF(0 == buf_len, ret);
+       RETV_IF(buffer == NULL, ret);
+       RETV_IF(algorithm == NULL, ret);
 
        OpenSSL_add_all_digests();
 
@@ -853,9 +842,8 @@ bool net_nfc_util_openssl_digest(const char *algorithm, const uint8_t *buffer, c
 
                        EVP_DigestInit(&mdCtx, md);
                        if (EVP_DigestUpdate(&mdCtx, buffer, buf_len) != 0)
-                       {
                                NFC_ERR("EVP_DigestUpdate failed");
-                       }
+
                        EVP_DigestFinal(&mdCtx, temp, &resultLen);
 
                        if (*out_len >= resultLen)
index 6253e5e..4fef23d 100644 (file)
 
 #define __NEXT_SUB_FIELD(__dst) ((__dst)->value + (__dst)->length)
 
-bool _get_records_data_buffer(ndef_record_s *begin_record, ndef_record_s *end_record, uint8_t **buffer, uint32_t *length)
+bool _get_records_data_buffer(ndef_record_s *begin_record,
+       ndef_record_s *end_record, uint8_t **buffer, uint32_t *length)
 {
-       bool result = false;
        uint32_t len = 0;
+       bool result = false;
        ndef_record_s *current_record = NULL;
 
-       if (begin_record == NULL || begin_record == end_record)
-               return result;
+       RETV_IF(NULL == begin_record, result);
+       RETV_IF(begin_record == end_record, result);
 
        /* count total buffer length */
        current_record = begin_record;
@@ -63,8 +64,11 @@ bool _get_records_data_buffer(ndef_record_s *begin_record, ndef_record_s *end_re
                        len += current_record->id_s.length;
 
                /* payload length */
-               if (current_record->payload_s.buffer != NULL && current_record->payload_s.length > 0)
+               if (current_record->payload_s.buffer != NULL &&
+                               current_record->payload_s.length > 0)
+               {
                        len += current_record->payload_s.length;
+               }
 
                current_record = current_record->next;
        }
@@ -83,23 +87,28 @@ bool _get_records_data_buffer(ndef_record_s *begin_record, ndef_record_s *end_re
                        while (offset < len && current_record != NULL && current_record != end_record)
                        {
                                /* type length */
-                               if (current_record->type_s.buffer != NULL && current_record->type_s.length > 0)
+                               if (current_record->type_s.buffer != NULL &&
+                                       current_record->type_s.length > 0)
                                {
-                                       memcpy(buf + offset, current_record->type_s.buffer, MIN(current_record->type_s.length, len - offset));
+                                       memcpy(buf + offset, current_record->type_s.buffer,
+                                               MIN(current_record->type_s.length, len - offset));
                                        offset += MIN(current_record->type_s.length, len - offset);
                                }
 
                                /* ID length */
                                if (current_record->id_s.buffer != NULL && current_record->id_s.length > 0)
                                {
-                                       memcpy(buf + offset, current_record->id_s.buffer, MIN(current_record->id_s.length, len - offset));
+                                       memcpy(buf + offset, current_record->id_s.buffer,
+                                               MIN(current_record->id_s.length, len - offset));
                                        offset += MIN(current_record->id_s.length, len - offset);
                                }
 
                                /* payload length */
-                               if (current_record->payload_s.buffer != NULL && current_record->payload_s.length > 0)
+                               if (current_record->payload_s.buffer != NULL &&
+                                       current_record->payload_s.length > 0)
                                {
-                                       memcpy(buf + offset, current_record->payload_s.buffer, MIN(current_record->payload_s.length, len - offset));
+                                       memcpy(buf + offset, current_record->payload_s.buffer,
+                                               MIN(current_record->payload_s.length, len - offset));
                                        offset += MIN(current_record->payload_s.length, len - offset);
                                }
 
@@ -116,14 +125,17 @@ bool _get_records_data_buffer(ndef_record_s *begin_record, ndef_record_s *end_re
        return result;
 }
 
-net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_record, ndef_record_s *sign_record)
+net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_record,
+       ndef_record_s *sign_record)
 {
-       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
-       uint8_t *buffer = NULL;
+       int ret;
        uint32_t length = 0;
+       uint8_t *buffer = NULL;
+       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
 
-       if (begin_record == NULL || sign_record == NULL || begin_record == sign_record)
-               return NET_NFC_INVALID_PARAM;
+       RETV_IF(NULL == sign_record, NET_NFC_INVALID_PARAM);
+       RETV_IF(NULL == begin_record, NET_NFC_INVALID_PARAM);
+       RETV_IF(begin_record == sign_record, NET_NFC_INVALID_PARAM);
 
        /* get signed data */
        if (_get_records_data_buffer(begin_record, sign_record, &buffer, &length) == true)
@@ -139,7 +151,7 @@ net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_recor
                NFC_DBG("signature type : %d", sign_info->sign_type);
                NFC_DBG("signature length : %d", sign_info->signature.length);
 
-               if (sign_info->uri_present == true)
+               if (true == sign_info->uri_present)
                {
                        /* TODO */
                        /* receive the signature data directed by uri */
@@ -149,9 +161,11 @@ net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_recor
                }
 
                /* parse certificate chain info */
-               chain_info = (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_info->signature));
+               chain_info =
+                       (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_info->signature));
 
-               SECURE_LOGD("certificate URI present? : %s", chain_info->uri_present ? "true" : "false");
+               SECURE_LOGD("certificate URI present? : %s",
+                       chain_info->uri_present ? "true" : "false");
                NFC_DBG("certificate format : %d", chain_info->cert_format);
                NFC_DBG("number of certificates : %d", chain_info->num_of_certs);
 
@@ -166,7 +180,15 @@ net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_recor
 
                        /* the first certificate is signer's one
                         * verify signature of content */
-                       if (net_nfc_util_openssl_verify_signature(sign_info->sign_type, buffer, length, data_info->value, data_info->length, sign_info->signature.value, sign_info->signature.length) == true)
+                       ret = net_nfc_util_openssl_verify_signature(sign_info->sign_type,
+                                               buffer,
+                                               length,
+                                               data_info->value,
+                                               data_info->length,
+                                               sign_info->signature.value,
+                                               sign_info->signature.length);
+
+                       if (true == ret)
                        {
                                if (chain_info->num_of_certs > 1)
                                {
@@ -177,7 +199,8 @@ net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_recor
                                        context = net_nfc_util_openssl_init_verify_certificate();
 
                                        /* add signer's certificate */
-                                       net_nfc_util_openssl_add_certificate_of_signer(context, data_info->value, data_info->length);
+                                       net_nfc_util_openssl_add_certificate_of_signer(context, data_info->value,
+                                               data_info->length);
 
                                        /* verify certificate using certificate chain */
                                        for (i = 1, data_info = (net_nfc_sub_field_s *)__NEXT_SUB_FIELD(data_info);
@@ -187,11 +210,12 @@ net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_recor
                                                NFC_DBG("certficate length : %d", data_info->length);
                                                //DEBUG_MSG_PRINT_BUFFER(data_info->value, data_info->length);
 
-                                               net_nfc_util_openssl_add_certificate_of_ca(context, data_info->value, data_info->length);
+                                               net_nfc_util_openssl_add_certificate_of_ca(context, data_info->value,
+                                                       data_info->length);
                                        }
 
                                        /* if the CA_Uri is present, continue adding certificate from uri */
-                                       if (chain_info->uri_present == true)
+                                       if (true == chain_info->uri_present)
                                        {
                                                /* TODO : Need to implement */
                                                NFC_ERR("NOT IMPLEMENTED (found_root == false && chain_info->uri_present == true)");
@@ -232,9 +256,8 @@ net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_recor
        else
        {
                if(buffer != NULL)
-               {
                        _net_nfc_util_free_mem(buffer);
-               }
+
                NFC_ERR("_get_records_data_buffer failed");
        }
 
@@ -243,19 +266,18 @@ net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_recor
 
 net_nfc_error_e net_nfc_util_verify_signature_ndef_message(ndef_message_s *msg)
 {
-       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
        ndef_record_s *begin_record = NULL;
        ndef_record_s *current_record = NULL;
+       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+
 
        begin_record = msg->records;
        current_record = msg->records;
 
        while (current_record != NULL)
        {
-               if (begin_record == NULL)
-               {
+               if (NULL == begin_record)
                        begin_record = current_record;
-               }
 
                if (IS_EMPTY_RECORD(current_record))
                {
@@ -277,40 +299,47 @@ net_nfc_error_e net_nfc_util_verify_signature_ndef_message(ndef_message_s *msg)
 /*
  * sign method
  */
-net_nfc_error_e net_nfc_util_sign_records(ndef_message_s *msg, int begin_index, int end_index, char *cert_file, char *password)
+net_nfc_error_e net_nfc_util_sign_records(ndef_message_s *msg, int begin_index,
+       int end_index, char *cert_file, char *password)
 {
-       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
-       ndef_record_s *begin_record = NULL, *end_record = NULL, *record = NULL;
-       data_s payload = { NULL, 0 };
-       uint8_t *data_buffer = NULL;
+       uint32_t cert_len = 0;
        uint32_t data_len = 0;
+       uint32_t cert_count = 0;
+       uint8_t *data_buffer = NULL;
+       uint8_t *cert_buffer = NULL;
+       data_s payload = { NULL, 0 };
        uint8_t signature[1024] = { 0, };
        uint32_t sign_len = sizeof(signature);
-       uint8_t *cert_buffer = NULL;
-       uint32_t cert_len = 0;
-       uint32_t cert_count = 0;
+       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+       ndef_record_s *begin_record = NULL, *end_record = NULL, *record = NULL;
+
 
        net_nfc_util_get_record_by_index(msg, begin_index, &begin_record);
        net_nfc_util_get_record_by_index(msg, end_index, &end_record);
 
-       NFC_DBG("total record count : %d, begin_index : %d, end_index : %d", msg->recordCount, begin_index, end_index);
+       NFC_DBG("total record count : %d, begin_index : %d, end_index : %d", msg->recordCount,
+               begin_index, end_index);
 
        /* get target data */
        _get_records_data_buffer(begin_record, end_record->next, &data_buffer, &data_len);
 
        DEBUG_MSG_PRINT_BUFFER(data_buffer, data_len);
 
-       net_nfc_util_openssl_sign_buffer(NET_NFC_SIGN_TYPE_PKCS_1, data_buffer, data_len, cert_file, password, signature, &sign_len);
+       net_nfc_util_openssl_sign_buffer(NET_NFC_SIGN_TYPE_PKCS_1, data_buffer, data_len,
+               cert_file, password, signature, &sign_len);
 
        /* get cert chain */
-       net_nfc_util_get_cert_list_from_file(cert_file, password, &cert_buffer, &cert_len, &cert_count);
+       net_nfc_util_get_cert_list_from_file(cert_file, password, &cert_buffer, &cert_len,
+               &cert_count);
 
        /* create payload */
-       payload.length = sizeof(net_nfc_signature_record_s) + sign_len + sizeof(net_nfc_certificate_chain_s) + cert_len;
+       payload.length = sizeof(net_nfc_signature_record_s) + sign_len +
+               sizeof(net_nfc_certificate_chain_s) + cert_len;
 
        _net_nfc_util_alloc_mem(payload.buffer, payload.length);
 
-       net_nfc_signature_record_s *sign_record = (net_nfc_signature_record_s *)payload.buffer;
+       net_nfc_signature_record_s *sign_record =
+               (net_nfc_signature_record_s *)payload.buffer;
        sign_record->version = 1;
        sign_record->uri_present = 0;
        sign_record->sign_type = NET_NFC_SIGN_TYPE_PKCS_1;
@@ -324,15 +353,13 @@ net_nfc_error_e net_nfc_util_sign_records(ndef_message_s *msg, int begin_index,
                __FILL_SUB_FIELD(&(sign_record->signature), signature, sign_len);
        }
 
-       net_nfc_certificate_chain_s *chain = (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_record->signature));
+       net_nfc_certificate_chain_s *chain =
+               (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_record->signature));
+
        if (cert_count < 16)
-       {
                chain->uri_present = 0;
-       }
        else
-       {
                chain->uri_present = 1;
-       }
 
        chain->cert_format = NET_NFC_CERT_FORMAT_X_509;
        chain->num_of_certs = cert_count;
@@ -347,7 +374,8 @@ net_nfc_error_e net_nfc_util_sign_records(ndef_message_s *msg, int begin_index,
        /* create record */
        data_s type = { (uint8_t *)"Sig", 3 };
 
-       net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type, NULL, &payload, &record);
+       net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type, NULL,
+               &payload, &record);
 
        /* get last record index */
        net_nfc_util_append_record_by_index(msg, end_index + 1, record);
@@ -359,7 +387,8 @@ net_nfc_error_e net_nfc_util_sign_records(ndef_message_s *msg, int begin_index,
        return result;
 }
 
-net_nfc_error_e net_nfc_util_sign_ndef_message(ndef_message_s *msg, char *cert_file, char *password)
+net_nfc_error_e net_nfc_util_sign_ndef_message(ndef_message_s *msg,
+       char *cert_file, char *password)
 {
        net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
 
index 6b087f6..d5555c5 100644 (file)
@@ -51,9 +51,9 @@ GOptionEntry option_entries[] = {
 
 pid_t net_nfc_server_gdbus_get_pid(const char *name)
 {
+       GVariant *_ret;
        guint pid = 0;
        GError *error = NULL;
-       GVariant *_ret;
 
        _ret = g_dbus_connection_call_sync(connection,
                        "org.freedesktop.DBus",
@@ -66,7 +66,9 @@ pid_t net_nfc_server_gdbus_get_pid(const char *name)
                        -1,
                        NULL,
                        &error);
-       if (_ret != NULL) {
+
+       if (_ret != NULL)
+       {
                g_variant_get(_ret, "(u)", &pid);
                g_variant_unref(_ret);
        }
@@ -78,14 +80,14 @@ static void _name_owner_changed(GDBusProxy *proxy,
                const gchar *name, const gchar *old_owner,
                const gchar *new_owner, void *user_data)
 {
-       if (name == NULL || old_owner == NULL || new_owner == NULL) {
-               NFC_ERR("invalid parameter");
+       RET_IF(NULL == name);
+       RET_IF(NULL == old_owner);
+       RET_IF(NULL == new_owner);
 
-               return;
-       }
-
-       if (strlen(new_owner) == 0) {
-               if (net_nfc_server_gdbus_check_client_is_running(old_owner)) {
+       if (strlen(new_owner) == 0)
+       {
+               if (net_nfc_server_gdbus_check_client_is_running(old_owner))
+               {
                        /* unregister service */
                        net_nfc_server_llcp_unregister_services(old_owner);
 
@@ -96,28 +98,25 @@ static void _name_owner_changed(GDBusProxy *proxy,
 }
 
 static void _on_name_owner_changed(GDBusConnection *connection,
-               const gchar *sender_name, const gchar *object_path,
-               const gchar *interface_name, const gchar *signal_name,
-               GVariant *parameters, gpointer user_data)
+               const gchar *sender_name,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
 {
        gchar *name;
        gchar *old_owner;
        gchar *new_owner;
 
-       g_variant_get(parameters,
-                       "(sss)",
-                       &name,
-                       &old_owner,
-                       &new_owner);
+       g_variant_get(parameters, "(sss)", &name, &old_owner, &new_owner);
 
-       _name_owner_changed((GDBusProxy *)connection,
-                       name, old_owner, new_owner, user_data);
+       _name_owner_changed((GDBusProxy *)connection, name, old_owner, new_owner, user_data);
 }
 
 static void _subscribe_name_owner_changed_event()
 {
-       if (connection == NULL)
-               return;
+       RET_IF(NULL == connection);
 
        /* subscribe signal */
        subscribe_id = g_dbus_connection_signal_subscribe(connection,
@@ -133,13 +132,11 @@ static void _subscribe_name_owner_changed_event()
 
 static void _unsubscribe_name_owner_changed_event()
 {
-       if (connection == NULL)
-               return;
+       RET_IF(NULL == connection);
 
        /* subscribe signal */
-       if (subscribe_id > 0) {
+       if (subscribe_id > 0)
                g_dbus_connection_signal_unsubscribe(connection, subscribe_id);
-       }
 }
 
 static void net_nfc_server_gdbus_init(void)
@@ -150,7 +147,7 @@ static void net_nfc_server_gdbus_init(void)
                g_object_unref(connection);
 
        connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-       if (connection == NULL)
+       if (NULL == connection)
        {
                NFC_ERR("Can not get connection %s", error->message);
                g_error_free (error);
@@ -185,7 +182,7 @@ static void net_nfc_server_gdbus_init(void)
 
        if (net_nfc_server_p2p_init(connection) == FALSE)
        {
-               NFC_ERR("Can not init tag");
+               NFC_ERR("Can not init p2p");
                return;
        }
 
@@ -197,25 +194,25 @@ static void net_nfc_server_gdbus_init(void)
 
        if (net_nfc_server_handover_init(connection) == FALSE)
        {
-               NFC_ERR("Can not initialize transceive");
+               NFC_ERR("Can not initialize handover");
                return;
        }
 
        if (net_nfc_server_se_init(connection) == FALSE)
        {
-               NFC_ERR("Can not init Test");
+               NFC_ERR("Can not init se");
                return;
        }
 
        if (net_nfc_server_snep_init(connection) == FALSE)
        {
-               NFC_ERR("Can not init controller thread");
+               NFC_ERR("Can not init snep");
                return;
        }
 
        if (net_nfc_server_system_handler_init(connection) == FALSE)
        {
-               NFC_ERR("Can not init controller thread");
+               NFC_ERR("Can not init system handler");
                return;
        }
 
@@ -307,12 +304,11 @@ static void on_name_lost(GDBusConnection *connnection, const gchar *name,
 
 int main(int argc, char *argv[])
 {
-
-       void *handle = NULL;
        guint id = 0;
+       void *handle = NULL;
+       GError *error = NULL;
        gboolean use_daemon = FALSE;
        GOptionContext *option_context;
-       GError *error = NULL;
 
        net_nfc_change_log_tag();
 
@@ -334,7 +330,7 @@ int main(int argc, char *argv[])
        net_nfc_app_util_clean_storage(MESSAGE_STORAGE);
 
        handle = net_nfc_controller_onload();
-       if (handle == NULL)
+       if (NULL == handle)
        {
                NFC_ERR("load plugin library is failed");
 
index 79b5529..eb2c6d4 100644 (file)
@@ -35,29 +35,6 @@ struct _ControllerFuncData
        gpointer data;
 };
 
-static gpointer controller_thread_func(gpointer user_data);
-
-static void controller_async_queue_free_func(gpointer user_data);
-
-static void controller_thread_deinit_thread_func(gpointer user_data);
-
-static void controller_target_detected_cb(void *info,
-               void *user_context);
-
-static void controller_se_transaction_cb(void *info,
-               void *user_context);
-
-static void controller_llcp_event_cb(void *info,
-               void *user_context);
-
-static void controller_init_thread_func(gpointer user_data);
-
-#ifndef ESE_ALWAYS_ON
-static void controller_deinit_thread_func(gpointer user_data);
-#endif
-
-static void restart_polling_loop_thread_func(gpointer user_data);
-
 static GAsyncQueue *controller_async_queue = NULL;
 
 static GThread *controller_thread = NULL;
@@ -69,7 +46,7 @@ static guint32 server_state = NET_NFC_SERVER_IDLE;
 
 static gpointer controller_thread_func(gpointer user_data)
 {
-       if (controller_async_queue == NULL)
+       if (NULL == controller_async_queue)
        {
                g_thread_exit(NULL);
                return NULL;
@@ -105,8 +82,7 @@ static void controller_thread_deinit_thread_func(gpointer user_data)
 static void controller_target_detected_cb(void *info,
                void *user_context)
 {
-       net_nfc_request_target_detected_t *req =
-               (net_nfc_request_target_detected_t *)info;
+       net_nfc_request_target_detected_t *req = (net_nfc_request_target_detected_t *)info;
 
        g_assert(info != NULL);
 
@@ -118,12 +94,16 @@ static void controller_target_detected_cb(void *info,
        {
                net_nfc_server_set_target_info(info);
 
-               if (req->devType != NET_NFC_UNKNOWN_TARGET) {
+               if (req->devType != NET_NFC_UNKNOWN_TARGET)
+               {
                        if (req->devType == NET_NFC_NFCIP1_TARGET ||
-                                       req->devType == NET_NFC_NFCIP1_INITIATOR) {
+                                       req->devType == NET_NFC_NFCIP1_INITIATOR)
+                       {
                                /* llcp target detected */
                                net_nfc_server_llcp_target_detected(info);
-                       } else {
+                       }
+                       else
+                       {
                                /* tag target detected */
                                net_nfc_server_tag_target_detected(info);
                        }
@@ -163,15 +143,9 @@ static void controller_se_transaction_cb(void *info,
 
 static void _controller_llcp_event_cb(gpointer user_data)
 {
-       net_nfc_request_llcp_msg_t *req_msg =
-               (net_nfc_request_llcp_msg_t *)user_data;
+       net_nfc_request_llcp_msg_t *req_msg = (net_nfc_request_llcp_msg_t *)user_data;
 
-       if (req_msg == NULL)
-       {
-               NFC_ERR("can not get llcp_event info");
-
-               return;
-       }
+       RET_IF(NULL == req_msg);
 
        switch (req_msg->request_type)
        {
@@ -191,20 +165,14 @@ static void _controller_llcp_event_cb(gpointer user_data)
 
        case NET_NFC_MESSAGE_SERVICE_LLCP_SOCKET_ERROR:
        case NET_NFC_MESSAGE_SERVICE_LLCP_SOCKET_ACCEPTED_ERROR:
-               net_nfc_controller_llcp_socket_error_cb(
-                               req_msg->llcp_socket,
-                               req_msg->result,
-                               NULL,
-                               (void *)req_msg->user_param);
+               net_nfc_controller_llcp_socket_error_cb(req_msg->llcp_socket,
+                       req_msg->result, NULL, (void *)req_msg->user_param);
                break;
 
        case NET_NFC_MESSAGE_SERVICE_LLCP_SEND:
        case NET_NFC_MESSAGE_SERVICE_LLCP_SEND_TO:
-               net_nfc_controller_llcp_sent_cb(
-                               req_msg->llcp_socket,
-                               req_msg->result,
-                               NULL,
-                               (void *)req_msg->user_param);
+               net_nfc_controller_llcp_sent_cb(req_msg->llcp_socket,
+                               req_msg->result, NULL, (void *)req_msg->user_param);
                break;
 
        case NET_NFC_MESSAGE_SERVICE_LLCP_RECEIVE:
@@ -214,9 +182,7 @@ static void _controller_llcp_event_cb(gpointer user_data)
                        data_s data = { msg->data.buffer, msg->data.length };
 
                        net_nfc_controller_llcp_received_cb(msg->client_socket,
-                                       msg->result,
-                                       &data,
-                                       (void *)req_msg->user_param);
+                                       msg->result, &data, (void *)req_msg->user_param);
                }
                break;
 
@@ -228,27 +194,19 @@ static void _controller_llcp_event_cb(gpointer user_data)
 
                        /* FIXME : pass sap */
                        net_nfc_controller_llcp_received_cb(msg->client_socket,
-                                       msg->result,
-                                       &data,
-                                       (void *)req_msg->user_param);
+                                       msg->result, &data, (void *)req_msg->user_param);
                }
                break;
 
        case NET_NFC_MESSAGE_SERVICE_LLCP_CONNECT:
        case NET_NFC_MESSAGE_SERVICE_LLCP_CONNECT_SAP:
-               net_nfc_controller_llcp_connected_cb(
-                               req_msg->llcp_socket,
-                               req_msg->result,
-                               NULL,
-                               (void *)req_msg->user_param);
+               net_nfc_controller_llcp_connected_cb(req_msg->llcp_socket,
+                               req_msg->result, NULL, (void *)req_msg->user_param);
                break;
 
        case NET_NFC_MESSAGE_SERVICE_LLCP_DISCONNECT:
-               net_nfc_controller_llcp_disconnected_cb(
-                               req_msg->llcp_socket,
-                               req_msg->result,
-                               NULL,
-                               (void *)req_msg->user_param);
+               net_nfc_controller_llcp_disconnected_cb(req_msg->llcp_socket,
+                               req_msg->result, NULL, (void *)req_msg->user_param);
                break;
 
        default:
@@ -295,11 +253,9 @@ static void controller_init_thread_func(gpointer user_data)
        NFC_INFO("net_nfc_contorller_register_listener success");
 
        result = net_nfc_server_llcp_set_config(NULL);
+
        if (result != NET_NFC_OK)
-       {
-               NFC_ERR("net_nfc_server_llcp_set config failed, [%d]",
-                               result);
-       }
+               NFC_ERR("net_nfc_server_llcp_set config failed, [%d]", result);
 
        NFC_INFO("net_nfc_server_llcp_set_config success");
 }
@@ -310,9 +266,8 @@ static void controller_deinit_thread_func(gpointer user_data)
        net_nfc_error_e result;
 
        if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
-                               NET_NFC_ALL_DISABLE,
-                               &result) == false) {
-
+                               NET_NFC_ALL_DISABLE, &result) == false)
+       {
                NFC_ERR("net_nfc_controller_configure_discovery failed, [%d]", result);
        }
 
@@ -332,10 +287,8 @@ static void controller_deinit_thread_func(gpointer user_data)
 
 static void restart_polling_loop_thread_func(gpointer user_data)
 {
-
        gint state = 0;
        gint pm_state = 0;
-
        net_nfc_error_e result;
 
        if (vconf_get_bool(VCONFKEY_NFC_STATE, &state) != 0)
@@ -351,10 +304,8 @@ static void restart_polling_loop_thread_func(gpointer user_data)
 
        if (pm_state == VCONFKEY_PM_STATE_NORMAL)
        {
-               if (net_nfc_controller_configure_discovery(
-                                       NET_NFC_DISCOVERY_MODE_CONFIG,
-                                       NET_NFC_ALL_ENABLE,
-                                       &result) == true)
+               if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
+                                       NET_NFC_ALL_ENABLE, &result) == true)
                {
                        NFC_DBG("polling enable");
                }
@@ -364,10 +315,8 @@ static void restart_polling_loop_thread_func(gpointer user_data)
 
        if (pm_state == VCONFKEY_PM_STATE_LCDOFF)
        {
-               if (net_nfc_controller_configure_discovery(
-                                       NET_NFC_DISCOVERY_MODE_CONFIG,
-                                       NET_NFC_ALL_DISABLE,
-                                       &result) == true)
+               if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
+                                       NET_NFC_ALL_DISABLE, &result) == true)
                {
                        NFC_DBG("polling disabled");
                }
@@ -380,18 +329,14 @@ gboolean net_nfc_server_controller_thread_init(void)
 {
        GError *error = NULL;
 
-       controller_async_queue = g_async_queue_new_full(
-                       controller_async_queue_free_func);
+       controller_async_queue = g_async_queue_new_full(controller_async_queue_free_func);
 
-       controller_thread = g_thread_try_new("controller_thread",
-                       controller_thread_func,
-                       NULL,
-                       &error);
+       controller_thread = g_thread_try_new("controller_thread", controller_thread_func,
+                       NULL, &error);
 
-       if (controller_thread == NULL)
+       if (NULL == controller_thread)
        {
-               NFC_ERR("can not create controller thread: %s",
-                               error->message);
+               NFC_ERR("can not create controller thread: %s", error->message);
                g_error_free(error);
                return FALSE;
        }
@@ -401,8 +346,7 @@ gboolean net_nfc_server_controller_thread_init(void)
 
 void net_nfc_server_controller_thread_deinit(void)
 {
-       if(net_nfc_server_controller_async_queue_push(
-                               controller_thread_deinit_thread_func,
+       if(net_nfc_server_controller_async_queue_push(controller_thread_deinit_thread_func,
                                NULL)==FALSE)
        {
                NFC_ERR("Failed to push onto the queue");
@@ -417,8 +361,7 @@ void net_nfc_server_controller_thread_deinit(void)
 
 void net_nfc_server_controller_init(void)
 {
-       if(net_nfc_server_controller_async_queue_push(
-                               controller_init_thread_func,
+       if(net_nfc_server_controller_async_queue_push(controller_init_thread_func,
                                NULL)==FALSE)
        {
                NFC_ERR("Failed to push onto the queue");
@@ -439,12 +382,11 @@ void net_nfc_server_controller_deinit(void)
 #endif
 
 gboolean net_nfc_server_controller_async_queue_push(
-               net_nfc_server_controller_func func,
-               gpointer user_data)
+               net_nfc_server_controller_func func, gpointer user_data)
 {
        ControllerFuncData *func_data;
 
-       if(controller_async_queue == NULL)
+       if(NULL == controller_async_queue)
        {
                NFC_ERR("controller_async_queue is not initialized");
 
@@ -462,8 +404,7 @@ gboolean net_nfc_server_controller_async_queue_push(
 
 void net_nfc_server_restart_polling_loop(void)
 {
-       if(net_nfc_server_controller_async_queue_push(
-                               restart_polling_loop_thread_func,
+       if(net_nfc_server_controller_async_queue_push(restart_polling_loop_thread_func,
                                NULL) == FALSE)
        {
                NFC_ERR("Failed to push onto the queue");
index 49b474c..e3f47ba 100644 (file)
@@ -68,26 +68,24 @@ void net_nfc_server_gdbus_deinit_client_context()
 
 /* TODO */
 bool net_nfc_server_gdbus_check_privilege(GDBusMethodInvocation *invocation,
-               GVariant *privilege,
-               const char *object,
-               const char *right)
+               GVariant *privilege, const char *object, const char *right)
 {
 #ifdef SECURITY_SERVER
-       data_s priv = { NULL, 0 };
        int result;
+       data_s priv = { NULL, 0 };
 
-       if (privilege == NULL || object == NULL || right == NULL) {
-               return false;
-       }
+       RETV_IF(NULL == right, false);
+       RETV_IF(NULL == object, false);
+       RETV_IF(NULL == privilege, false);
 
        net_nfc_util_gdbus_variant_to_data_s(privilege, &priv);
 
-       result = security_server_check_privilege_by_cookie((char *)priv.buffer,
-                       object, right);
+       result = security_server_check_privilege_by_cookie((char *)priv.buffer, object, right);
 
        net_nfc_util_free_data(&priv);
 
-       if (result < 0) {
+       if (result < 0)
+       {
                NFC_ERR("permission denied : \"%s\", \"%s\"", object, right);
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Privilege",
@@ -98,8 +96,7 @@ bool net_nfc_server_gdbus_check_privilege(GDBusMethodInvocation *invocation,
 #endif
        const char *id = g_dbus_method_invocation_get_sender(invocation);
 
-       net_nfc_server_gdbus_add_client_context(id,
-                       NET_NFC_CLIENT_ACTIVE_STATE);
+       net_nfc_server_gdbus_add_client_context(id, NET_NFC_CLIENT_ACTIVE_STATE);
 
        return true;
 }
@@ -170,9 +167,7 @@ void net_nfc_server_gdbus_add_client_context(const char *id,
                        info->launch_popup_state = NET_NFC_LAUNCH_APP_SELECT;
                        info->launch_popup_state_no_check = NET_NFC_LAUNCH_APP_SELECT;
 
-                       g_hash_table_insert(client_contexts,
-                                       (gpointer)info->id,
-                                       (gpointer)info);
+                       g_hash_table_insert(client_contexts, (gpointer)info->id, (gpointer)info);
 
                        NFC_DBG("current client count = [%d]",
                                        net_nfc_server_gdbus_get_client_count_no_lock());
@@ -216,21 +211,20 @@ void net_nfc_server_gdbus_cleanup_client_context(const char *id)
 }
 
 void net_nfc_server_gdbus_for_each_client_context(
-               net_nfc_server_gdbus_for_each_client_cb cb,
-               void *user_param)
+               net_nfc_server_gdbus_for_each_client_cb cb, void *user_param)
 {
-       GHashTableIter iter;
        char *id;
+       GHashTableIter iter;
        net_nfc_client_context_info_t *info;
 
-       if (cb == NULL)
-               return;
+       RET_IF(NULL == cb);
 
        pthread_mutex_lock(&context_lock);
 
        g_hash_table_iter_init(&iter, client_contexts);
-       while (g_hash_table_iter_next(&iter, (gpointer *)&id,
-                               (gpointer *)&info) == true) {
+
+       while (g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&info) == true)
+       {
                cb(info, user_param);
        }
 
@@ -250,9 +244,8 @@ client_state_e net_nfc_server_gdbus_get_client_state(const char *id)
        pthread_mutex_lock(&context_lock);
 
        info = net_nfc_server_gdbus_get_client_context_no_lock(id);
-       if (info != NULL) {
+       if (info != NULL)
                state = info->state;
-       }
 
        pthread_mutex_unlock(&context_lock);
 
@@ -266,9 +259,8 @@ void net_nfc_server_gdbus_set_client_state(const char *id, client_state_e state)
        pthread_mutex_lock(&context_lock);
 
        info = net_nfc_server_gdbus_get_client_context_no_lock(id);
-       if (info != NULL) {
+       if (info != NULL)
                info->state = state;
-       }
 
        pthread_mutex_unlock(&context_lock);
 }
@@ -282,12 +274,12 @@ void net_nfc_server_gdbus_set_launch_state(const char *id,
        pthread_mutex_lock(&context_lock);
 
        info = net_nfc_server_gdbus_get_client_context_no_lock(id);
-       if (info != NULL) {
-               if (check_foreground == CHECK_FOREGROUND) {
+       if (info != NULL)
+       {
+               if (check_foreground == CHECK_FOREGROUND)
                        info->launch_popup_state = popup_state;
-               } else {
+               else
                        info->launch_popup_state_no_check = popup_state;
-               }
        }
 
        pthread_mutex_unlock(&context_lock);
@@ -302,13 +294,12 @@ net_nfc_launch_popup_state_e net_nfc_server_gdbus_get_launch_state(
        pthread_mutex_lock(&context_lock);
 
        info = net_nfc_server_gdbus_get_client_context_no_lock(id);
-       if (info != NULL) {
-               if (info->launch_popup_state_no_check  ==
-                               NET_NFC_NO_LAUNCH_APP_SELECT) {
+       if (info != NULL)
+       {
+               if (info->launch_popup_state_no_check  == NET_NFC_NO_LAUNCH_APP_SELECT)
                        result = NET_NFC_NO_LAUNCH_APP_SELECT;
-               } else {
+               else
                        result = info->launch_popup_state;
-               }
        }
 
        pthread_mutex_unlock(&context_lock);
@@ -319,31 +310,31 @@ net_nfc_launch_popup_state_e net_nfc_server_gdbus_get_launch_state(
 net_nfc_launch_popup_state_e net_nfc_server_gdbus_get_client_popup_state(
                pid_t pid)
 {
-       GHashTableIter iter;
        char *id;
-       net_nfc_launch_popup_state_e state = NET_NFC_LAUNCH_APP_SELECT;
+       GHashTableIter iter;
        net_nfc_client_context_info_t *info = NULL, *temp;
+       net_nfc_launch_popup_state_e state = NET_NFC_LAUNCH_APP_SELECT;
 
        pthread_mutex_lock(&context_lock);
 
        g_hash_table_iter_init(&iter, client_contexts);
-       while (g_hash_table_iter_next(&iter, (gpointer *)&id,
-                               (gpointer *)&temp) == true) {
-               if (temp->launch_popup_state_no_check ==
-                               NET_NFC_NO_LAUNCH_APP_SELECT) {
+       while (g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&temp) == true)
+       {
+               if (NET_NFC_NO_LAUNCH_APP_SELECT == temp->launch_popup_state_no_check)
+               {
                        state = NET_NFC_NO_LAUNCH_APP_SELECT;
                        break;
                }
 
-               if (temp->pgid == pid) {
+               if (pid == temp->pgid)
+               {
                        info = temp;
                        break;
                }
        }
 
-       if (info != NULL) {
+       if (info != NULL)
                state = info->launch_popup_state;
-       }
 
        pthread_mutex_unlock(&context_lock);
 
@@ -357,9 +348,8 @@ void net_nfc_server_gdbus_increase_se_count(const char *id)
        pthread_mutex_lock(&context_lock);
 
        info = net_nfc_server_gdbus_get_client_context_no_lock(id);
-       if (info != NULL) {
+       if (info != NULL)
                info->ref_se++;
-       }
 
        pthread_mutex_unlock(&context_lock);
 }
@@ -371,9 +361,8 @@ void net_nfc_server_gdbus_decrease_se_count(const char *id)
        pthread_mutex_lock(&context_lock);
 
        info = net_nfc_server_gdbus_get_client_context_no_lock(id);
-       if (info != NULL) {
+       if (info != NULL)
                info->ref_se--;
-       }
 
        pthread_mutex_unlock(&context_lock);
 }
@@ -384,15 +373,17 @@ bool net_nfc_server_gdbus_is_server_busy()
 
        pthread_mutex_lock(&context_lock);
 
-       if (g_hash_table_size(client_contexts) > 0) {
-               GHashTableIter iter;
+       if (g_hash_table_size(client_contexts) > 0)
+       {
                char *id;
+               GHashTableIter iter;
                net_nfc_client_context_info_t *info;
 
                g_hash_table_iter_init(&iter, client_contexts);
-               while (g_hash_table_iter_next(&iter, (gpointer *)&id,
-                                       (gpointer *)&info) == true) {
-                       if (info->ref_se > 0) {
+               while (g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&info) == true)
+               {
+                       if (info->ref_se > 0)
+                       {
                                result = true;
                                break;
                        }
index 58b575a..d0c8079 100644 (file)
 
 static net_nfc_oem_interface_s g_interface;
 
-static void *net_nfc_controller_load_file(const char *dir_path,
-               const char *filename)
+static void *net_nfc_controller_load_file(const char *dir_path, const char *filename)
 {
-       void *handle = NULL;
-       char path[PATH_MAX] = { '\0' };
        struct stat st;
-
+       void *handle = NULL;
        net_nfc_error_e result;
+       char path[PATH_MAX] = { '\0' };
 
        bool (*onload)(net_nfc_oem_interface_s *interfaces);
 
        snprintf(path, PATH_MAX, "%s/%s", dir_path, filename);
        NFC_DBG("path : %s", path);
 
-       if (stat(path, &st) == -1) {
+       if (stat(path, &st) == -1)
+       {
                NFC_ERR("stat failed : file not found");
                goto ERROR;
        }
 
-       if (S_ISREG(st.st_mode) == 0) {
+       if (S_ISREG(st.st_mode) == 0)
+       {
                NFC_ERR("S_ISREG(st.st_mode) == 0");
                goto ERROR;
        }
 
        handle = dlopen(path, RTLD_LAZY);
-       if (handle == NULL) {
+       if (NULL == handle)
+       {
                char buffer[1024];
                NFC_ERR("dlopen failed, [%d] : %s",
                                errno, strerror_r(errno, buffer, sizeof(buffer)));
@@ -69,7 +70,8 @@ static void *net_nfc_controller_load_file(const char *dir_path,
        }
 
        onload = dlsym(handle, "onload");
-       if (onload == NULL) {
+       if (NULL == onload)
+       {
                char buffer[1024];
                NFC_ERR("dlsym failed, [%d] : %s",
                                errno, strerror_r(errno, buffer, sizeof(buffer)));
@@ -77,23 +79,23 @@ static void *net_nfc_controller_load_file(const char *dir_path,
        }
 
        memset(&g_interface, 0, sizeof(g_interface));
-       if (onload(&g_interface) == false) {
+       if (onload(&g_interface) == false)
+       {
                NFC_ERR("onload failed");
                goto ERROR;
        }
 
-       if (net_nfc_controller_support_nfc(&result) == false) {
-               NFC_ERR("net_nfc_controller_support_nfc failed, [%d]",
-                               result);
+       if (net_nfc_controller_support_nfc(&result) == false)
+       {
+               NFC_ERR("net_nfc_controller_support_nfc failed, [%d]", result);
                goto ERROR;
        }
 
        return handle;
 
 ERROR :
-       if (handle != NULL) {
+       if (handle != NULL)
                dlclose(handle);
-       }
 
        return NULL;
 }
@@ -106,7 +108,7 @@ void *net_nfc_controller_onload()
        void *handle = NULL;
 
        dirp = opendir(NFC_MANAGER_MODULEDIR);
-       if (dirp == NULL)
+       if (NULL == dirp)
        {
                NFC_ERR("Can not open directory %s", NFC_MANAGER_MODULEDIR);
                return NULL;
@@ -114,11 +116,8 @@ void *net_nfc_controller_onload()
 
        while ((dir = readdir(dirp)))
        {
-               if ((strcmp(dir->d_name, ".") == 0) ||
-                               (strcmp(dir->d_name, "..") == 0))
-               {
+               if ((strcmp(dir->d_name, ".") == 0) || (strcmp(dir->d_name, "..") == 0))
                        continue;
-               }
 
                /* check ".so" suffix */
                if (strcmp(dir->d_name + (strlen(dir->d_name) - strlen(".so")), ".so") != 0)
@@ -140,8 +139,7 @@ void *net_nfc_controller_onload()
        closedir(dirp);
 
        /* load default plugin */
-       handle = net_nfc_controller_load_file(NFC_MANAGER_MODULEDIR,
-                       NET_NFC_DEFAULT_PLUGIN);
+       handle = net_nfc_controller_load_file(NFC_MANAGER_MODULEDIR, NET_NFC_DEFAULT_PLUGIN);
 
        if (handle)
        {
@@ -648,16 +646,15 @@ static gint _compare_socket_info(gconstpointer a, gconstpointer b)
 
 static socket_info_t* _get_socket_info(net_nfc_llcp_socket_t socket)
 {
-       socket_info_t *result;
        GSList *item;
+       socket_info_t *result;
 
        item = g_slist_find_custom(llcp_sockets, GUINT_TO_POINTER(socket),
                        _compare_socket_info);
-       if (item != NULL) {
+       if (item != NULL)
                result = (socket_info_t *)item->data;
-       } else {
+       else
                result = NULL;
-       }
 
        return result;
 }
@@ -667,7 +664,8 @@ static socket_info_t* _add_socket_info(net_nfc_llcp_socket_t socket)
        socket_info_t *result;
 
        _net_nfc_util_alloc_mem(result, sizeof(socket_info_t));
-       if (result != NULL) {
+       if (result != NULL)
+       {
                result->socket = socket;
 
                llcp_sockets = g_slist_append(llcp_sockets, result);
@@ -682,7 +680,8 @@ static void _remove_socket_info(net_nfc_llcp_socket_t socket)
 
        item = g_slist_find_custom(llcp_sockets, GUINT_TO_POINTER(socket),
                        _compare_socket_info);
-       if (item != NULL) {
+       if (item != NULL)
+       {
                llcp_sockets = g_slist_remove_link(llcp_sockets, item);
                free(item->data);
        }
@@ -694,10 +693,10 @@ void net_nfc_controller_llcp_socket_error_cb(net_nfc_llcp_socket_t socket,
        socket_info_t *info;
 
        info = _get_socket_info(socket);
-       if (info != NULL) {
-               if (info->err_cb != NULL) {
+       if (info != NULL)
+       {
+               if (info->err_cb != NULL)
                        info->err_cb(socket, result, NULL, NULL, info->err_param);
-               }
 
                _remove_socket_info(socket);
        }
@@ -717,18 +716,22 @@ bool net_nfc_controller_llcp_create_socket(net_nfc_llcp_socket_t *socket,
                socket_info_t *info;
 
                info = _add_socket_info(-1);
-               if (info == NULL) {
+               if (NULL == info)
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                        *result = NET_NFC_ALLOC_FAIL;
                        return false;
                }
 
                ret = g_interface.create_llcp_socket(socket, socketType, miu, rw, result, NULL);
-               if (ret == true) {
+               if (true == ret)
+               {
                        info->socket = *socket;
                        info->err_cb = cb;
                        info->err_param = user_param;
-               } else {
+               }
+               else
+               {
                        _remove_socket_info(-1);
                }
 
@@ -763,12 +766,15 @@ void net_nfc_controller_llcp_incoming_cb(net_nfc_llcp_socket_t socket,
        socket_info_t *info = (socket_info_t *)user_param;
 
        info = _get_socket_info(info->socket);
-       if (info != NULL) {
-               if (_add_socket_info(socket) != NULL) {
-                       if (info->work_cb != NULL) {
+       if (info != NULL)
+       {
+               if (_add_socket_info(socket) != NULL)
+               {
+                       if (info->work_cb != NULL)
                                info->work_cb(socket, result, NULL, NULL, info->work_param);
-                       }
-               } else {
+               }
+               else
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                }
        }
@@ -786,7 +792,8 @@ bool net_nfc_controller_llcp_listen(net_nfc_target_handle_s* handle,
                socket_info_t *info;
 
                info = _get_socket_info(socket);
-               if (info == NULL) {
+               if (NULL == info)
+               {
                        NFC_ERR("_get_socket_info failed");
                        *result = NET_NFC_INVALID_HANDLE;
                        return false;
@@ -814,7 +821,8 @@ bool net_nfc_controller_llcp_accept(net_nfc_llcp_socket_t socket,
                socket_info_t *info;
 
                info = _get_socket_info(socket);
-               if (info == NULL) {
+               if (NULL == info)
+               {
                        NFC_ERR("_get_socket_info failed");
                        *result = NET_NFC_INVALID_HANDLE;
                        return false;
@@ -841,9 +849,8 @@ bool net_nfc_controller_llcp_reject(net_nfc_target_handle_s *handle,
                bool ret;
 
                ret = g_interface.reject_llcp(handle, socket, result);
-               if (ret == true) {
+               if (true == ret)
                        _remove_socket_info(socket);
-               }
 
                return ret;
        }
@@ -860,12 +867,10 @@ void net_nfc_controller_llcp_connected_cb(net_nfc_llcp_socket_t socket,
 {
        net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
 
-       if (param == NULL)
-               return;
+       RET_IF(NULL == param);
 
-       if (param->cb != NULL) {
+       if (param->cb != NULL)
                param->cb(param->socket, result, NULL, NULL, param->user_param);
-       }
 
        _net_nfc_util_free_mem(param);
 }
@@ -888,7 +893,8 @@ bool net_nfc_controller_llcp_connect_by_url(net_nfc_target_handle_s *handle,
                net_nfc_llcp_param_t *param = NULL;
 
                _net_nfc_util_alloc_mem(param, sizeof(*param));
-               if (param == NULL) {
+               if (NULL == param)
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                        *result = NET_NFC_ALLOC_FAIL;
                        return false;
@@ -952,12 +958,10 @@ void net_nfc_controller_llcp_disconnected_cb(net_nfc_llcp_socket_t socket,
 {
        net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
 
-       if (param == NULL)
-               return;
+       RET_IF(NULL == param);
 
-       if (param->cb != NULL) {
+       if (param->cb != NULL)
                param->cb(param->socket, result, NULL, NULL, param->user_param);
-       }
 
        _net_nfc_util_free_mem(param);
 }
@@ -979,7 +983,8 @@ bool net_nfc_controller_llcp_disconnect(net_nfc_target_handle_s *handle,
                net_nfc_llcp_param_t *param = NULL;
 
                _net_nfc_util_alloc_mem(param, sizeof(net_nfc_llcp_param_t));
-               if (param == NULL) {
+               if (NULL == param)
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                        *result = NET_NFC_ALLOC_FAIL;
                        return false;
@@ -1019,16 +1024,14 @@ void net_nfc_controller_llcp_received_cb(net_nfc_llcp_socket_t socket,
 {
        net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
 
-       if (param == NULL)
-               return;
+       RET_IF(NULL == param);
 
-       if (param->cb != NULL) {
+       if (param->cb != NULL)
                param->cb(param->socket, result, &param->data, data, param->user_param);
-       }
 
-       if (param->data.buffer != NULL) {
+       if (param->data.buffer != NULL)
                _net_nfc_util_free_mem(param->data.buffer);
-       }
+
        _net_nfc_util_free_mem(param);
 }
 
@@ -1044,7 +1047,8 @@ bool net_nfc_controller_llcp_recv(net_nfc_target_handle_s *handle,
                net_nfc_llcp_param_t *param = NULL;
 
                _net_nfc_util_alloc_mem(param, sizeof(*param));
-               if (param == NULL) {
+               if (NULL == param)
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                        *result = NET_NFC_ALLOC_FAIL;
                        return false;
@@ -1052,9 +1056,11 @@ bool net_nfc_controller_llcp_recv(net_nfc_target_handle_s *handle,
 
                param->socket = socket;
                param->cb = cb;
-               if (max_len > 0) {
+               if (max_len > 0)
+               {
                        _net_nfc_util_alloc_mem(param->data.buffer, max_len);
-                       if (param->data.buffer == NULL) {
+                       if (param->data.buffer == NULL)
+                       {
                                NFC_ERR("_net_nfc_util_alloc_mem failed");
                                _net_nfc_util_free_mem(param);
                                *result = NET_NFC_ALLOC_FAIL;
@@ -1079,12 +1085,10 @@ void net_nfc_controller_llcp_sent_cb(net_nfc_llcp_socket_t socket,
 {
        net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
 
-       if (param == NULL)
-               return;
+       RET_IF(NULL == param);
 
-       if (param->cb != NULL) {
+       if (param->cb != NULL)
                param->cb(param->socket, result, NULL, NULL, param->user_param);
-       }
 
        _net_nfc_util_free_mem(param);
 }
@@ -1101,7 +1105,8 @@ bool net_nfc_controller_llcp_send(net_nfc_target_handle_s *handle,
                net_nfc_llcp_param_t *param = NULL;
 
                _net_nfc_util_alloc_mem(param, sizeof(*param));
-               if (param == NULL) {
+               if (NULL == param)
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                        *result = NET_NFC_ALLOC_FAIL;
                        return false;
@@ -1132,7 +1137,8 @@ bool net_nfc_controller_llcp_recv_from(net_nfc_target_handle_s *handle,
                net_nfc_llcp_param_t *param = NULL;
 
                _net_nfc_util_alloc_mem(param, sizeof(*param));
-               if (param == NULL) {
+               if (NULL == param)
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                        *result = NET_NFC_ALLOC_FAIL;
                        return false;
@@ -1140,9 +1146,11 @@ bool net_nfc_controller_llcp_recv_from(net_nfc_target_handle_s *handle,
 
                param->socket = socket;
                param->cb = cb;
-               if (max_len > 0) {
+               if (max_len > 0)
+               {
                        _net_nfc_util_alloc_mem(param->data.buffer, max_len);
-                       if (param->data.buffer == NULL) {
+                       if (NULL == param->data.buffer)
+                       {
                                NFC_ERR("_net_nfc_util_alloc_mem failed");
                                _net_nfc_util_free_mem(param);
                                *result = NET_NFC_ALLOC_FAIL;
@@ -1174,7 +1182,8 @@ bool net_nfc_controller_llcp_send_to(net_nfc_target_handle_s *handle,
                net_nfc_llcp_param_t *param = NULL;
 
                _net_nfc_util_alloc_mem(param, sizeof(*param));
-               if (param == NULL) {
+               if (NULL == param)
+               {
                        NFC_ERR("_net_nfc_util_alloc_mem failed");
                        *result = NET_NFC_ALLOC_FAIL;
                        return false;
index 2a681bf..fafc6b0 100644 (file)
 
 static NetNfcGDbusHandover *handover_skeleton = NULL;
 
-static void handover_request_thread_func(gpointer user_data);
-
-static gboolean handover_handle_request(NetNfcGDbusHandover *hdover,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               gint32 arg_type,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
 static void handover_request_thread_func(gpointer user_data)
 {
-       HandoverRequestData *handover_data = (HandoverRequestData *)user_data;
        net_nfc_error_e result;
+       HandoverRequestData *handover_data = user_data;
 
        g_assert(handover_data != NULL);
        g_assert(handover_data->handoverobj != NULL);
        g_assert(handover_data->invocation != NULL);
 
        result = net_nfc_server_handover_default_client_start(
-                       GUINT_TO_POINTER(handover_data->handle),
-                       (void *)handover_data);
+                       GUINT_TO_POINTER(handover_data->handle), (void *)handover_data);
        if (result != NET_NFC_OK)
        {
                net_nfc_gdbus_handover_complete_request(
@@ -67,24 +57,23 @@ static gboolean handover_handle_request(NetNfcGDbusHandover *hdover,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       HandoverRequestData *data;
        gboolean result;
+       HandoverRequestData *data;
 
        NFC_INFO(">>> REQUEST from [%s]",
                        g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       if (net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "rw") == false)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(HandoverRequestData,1);
-       if(data == NULL)
+       if(NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
@@ -100,7 +89,7 @@ static gboolean handover_handle_request(NetNfcGDbusHandover *hdover,
 
        result = net_nfc_server_controller_async_queue_push(
                        handover_request_thread_func, data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Handover.ThreadError",
@@ -117,6 +106,7 @@ static gboolean handover_handle_request(NetNfcGDbusHandover *hdover,
 
 gboolean net_nfc_server_handover_init(GDBusConnection *connection)
 {
+       gboolean ret;
        GError *error = NULL;
 
        if (handover_skeleton)
@@ -124,16 +114,13 @@ gboolean net_nfc_server_handover_init(GDBusConnection *connection)
 
        handover_skeleton = net_nfc_gdbus_handover_skeleton_new();
 
-       g_signal_connect(handover_skeleton,
-                       "handle-request",
-                       G_CALLBACK(handover_handle_request),
-                       NULL);
+       g_signal_connect(handover_skeleton, "handle-request",
+                       G_CALLBACK(handover_handle_request), NULL);
+
+       ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(handover_skeleton),
+                               connection, "/org/tizen/NetNfcService/Handover", &error);
 
-       if (g_dbus_interface_skeleton_export(
-                               G_DBUS_INTERFACE_SKELETON(handover_skeleton),
-                               connection,
-                               "/org/tizen/NetNfcService/Handover",
-                               &error) == FALSE)
+       if (FALSE == ret)
        {
                g_error_free(error);
 
index 99e68fb..11d52d7 100755 (executable)
@@ -110,14 +110,16 @@ int _net_nfc_handover_bss_convert_encryption_type (int enc_type)
 
 wifi_ap_h _net_nfc_handover_bss_create_ap(net_nfc_carrier_config_s *config)
 {
-       wifi_ap_h ap_handle = NULL;
-       data_s temp = { NULL, 0 };
        int err = WIFI_ERROR_NONE;
+       data_s temp = { NULL, 0 };
+       wifi_ap_h ap_handle = NULL;
 
        // Sets SSID
        err = net_nfc_util_get_carrier_config_property(config,
                        NET_NFC_WIFI_ATTRIBUTE_SSID,(uint16_t *)&temp.length, &temp.buffer);
+
        NFC_DBG("SSID = [%s] err %d",temp.buffer, err);
+
        err = wifi_ap_create((char*)temp.buffer, &ap_handle);
        if(err != WIFI_ERROR_NONE)
        {
@@ -128,12 +130,15 @@ wifi_ap_h _net_nfc_handover_bss_create_ap(net_nfc_carrier_config_s *config)
        // Sets Authentication Type
        net_nfc_util_get_carrier_config_property(config,
                        NET_NFC_WIFI_ATTRIBUTE_AUTH_TYPE,(uint16_t *)&temp.length, &temp.buffer);
+
        if(temp.length == 2)
        {
                uint16_t securitytype = temp.buffer[0] <<8 | temp.buffer[1];
+
                NFC_DBG("wifi_ap_set_security_type %x", securitytype);
                err = wifi_ap_set_security_type(ap_handle,
                                _net_nfc_handover_bss_convert_security_type(securitytype));
+
                if(err != WIFI_ERROR_NONE)
                {
                        NFC_ERR("set security type failed");
@@ -145,6 +150,7 @@ wifi_ap_h _net_nfc_handover_bss_create_ap(net_nfc_carrier_config_s *config)
                NFC_ERR("Invalid authentication length");
                goto error;
        }
+
        net_nfc_util_get_carrier_config_property(config,
                        NET_NFC_WIFI_ATTRIBUTE_NET_KEY,(uint16_t *)&temp.length, &temp.buffer);
 
@@ -155,9 +161,11 @@ wifi_ap_h _net_nfc_handover_bss_create_ap(net_nfc_carrier_config_s *config)
                NFC_ERR("Failed to set passphrase");
                goto error;
        }
+
        // Sets encryption Type
        net_nfc_util_get_carrier_config_property(config,
                        NET_NFC_WIFI_ATTRIBUTE_ENC_TYPE,(uint16_t *)&temp.length, &temp.buffer);
+
        if(temp.length == 2)
        {
                uint16_t enc_type = temp.buffer[0] <<8 | temp.buffer[1];
@@ -170,6 +178,7 @@ wifi_ap_h _net_nfc_handover_bss_create_ap(net_nfc_carrier_config_s *config)
                NFC_ERR("Invalid Encryption length");
                goto error;
        }
+
        return ap_handle;
 error:
        if(ap_handle != NULL)
@@ -183,12 +192,12 @@ void _net_nfc_handover_bss_on_wifi_activated(wifi_error_e errorCode,
                void* user_data)
 {
        net_nfc_handover_bss_process_context_t *context = user_data;
-       if(context == NULL)
+       if(NULL == context)
        {
                NFC_ERR("Invalid context");
                return;
        }
-       if (errorCode == WIFI_ERROR_NONE)
+       if (WIFI_ERROR_NONE == errorCode)
        {
                NFC_ERR("WIFI activated succesfully");
                context->result = NET_NFC_OK;
@@ -203,12 +212,12 @@ void _net_nfc_handover_bss_on_wifi_activated(wifi_error_e errorCode,
 bool _net_nfc_handover_bss_wifi_for_each_access_point_found(
                wifi_ap_h ap_handle, void *user_data)
 {
-       data_s temp_ssid = { NULL, 0 };
-       int err = WIFI_ERROR_NONE;
        char* essid = NULL;
+       int err = WIFI_ERROR_NONE;
+       data_s temp_ssid = { NULL, 0 };
        net_nfc_handover_bss_process_context_t *context = user_data;
 
-       if(context == NULL)
+       if(NULL == context)
        {
                NFC_ERR("Invalid context");
                return false;
@@ -229,6 +238,7 @@ bool _net_nfc_handover_bss_wifi_for_each_access_point_found(
        }
 
        wifi_ap_get_essid(ap_handle, &essid);
+
        NFC_DBG("Scan Result Ap essid [%s]",essid);
        if(memcmp(temp_ssid.buffer, essid,temp_ssid.length) == 0)
        {
@@ -245,10 +255,9 @@ bool _net_nfc_handover_bss_wifi_for_each_access_point_found(
 void _net_nfc_handover_bss_on_wifi_bgscan_completed(
                wifi_error_e error_code, void* user_data)
 {
-
        net_nfc_handover_bss_process_context_t *context = user_data;
 
-       if(context == NULL)
+       if(NULL == context)
        {
                NFC_ERR("Invalid context");
                return;
@@ -258,9 +267,7 @@ void _net_nfc_handover_bss_on_wifi_bgscan_completed(
                NFC_ERR("Wifi scan failed");
                context->result = NET_NFC_OPERATION_FAIL;
                context->step = NET_NFC_LLCP_STEP_RETURN;
-               g_idle_add(
-                               _net_nfc_handover_bss_process_carrier_record,
-                               context);
+               g_idle_add(_net_nfc_handover_bss_process_carrier_record, context);
        }
        else
        {
@@ -281,9 +288,7 @@ void _net_nfc_handover_bss_on_wifi_scan_completed(wifi_error_e error_code,
                NFC_ERR("Wifi scan failed");
                context->result = NET_NFC_OPERATION_FAIL;
                context->step = NET_NFC_LLCP_STEP_RETURN;
-               g_idle_add(
-                               _net_nfc_handover_bss_process_carrier_record,
-                               context);
+               g_idle_add(_net_nfc_handover_bss_process_carrier_record, context);
        }
        else
        {
@@ -291,8 +296,8 @@ void _net_nfc_handover_bss_on_wifi_scan_completed(wifi_error_e error_code,
                                &context->config, context->carrier);
                context->ap_handle = NULL;
                err = wifi_foreach_found_aps(
-                               _net_nfc_handover_bss_wifi_for_each_access_point_found,
-                               context);
+                               _net_nfc_handover_bss_wifi_for_each_access_point_found, context);
+
                if(err != WIFI_ERROR_NONE)
                {
                        NFC_ERR("wifi_foreach_found_aps failed Err[%x]",err);
@@ -300,31 +305,32 @@ void _net_nfc_handover_bss_on_wifi_scan_completed(wifi_error_e error_code,
                        context->step = NET_NFC_LLCP_STEP_RETURN;
                        g_idle_add(_net_nfc_handover_bss_process_carrier_record, context);
                }
-               if(context->ap_handle == NULL)
+               if(NULL == context->ap_handle)
                {
-                       wifi_encryption_type_e enc_type;
                        wifi_security_type_e sec_type;
+                       wifi_encryption_type_e enc_type;
+
+                       context->ap_handle = _net_nfc_handover_bss_create_ap(context->config);
 
-                       context->ap_handle = _net_nfc_handover_bss_create_ap(
-                                       context->config);
                        wifi_ap_get_encryption_type(context->ap_handle, &enc_type);
                        NFC_DBG("Encryption type %x",enc_type);
+
                        wifi_ap_get_security_type(context->ap_handle, &sec_type);
                        NFC_DBG("Authentication type %x", sec_type);
                }
                else
                {
                        data_s temp = { NULL, 0 };
-                       wifi_encryption_type_e enc_type = WIFI_ENCRYPTION_TYPE_NONE;
                        wifi_security_type_e sec_type = WIFI_SECURITY_TYPE_NONE;
+                       wifi_encryption_type_e enc_type = WIFI_ENCRYPTION_TYPE_NONE;
+
                        //set passkey
                        net_nfc_util_get_carrier_config_property(context->config,
-                                       NET_NFC_WIFI_ATTRIBUTE_NET_KEY,(uint16_t *)&temp.length,
-                                       &temp.buffer);
+                                       NET_NFC_WIFI_ATTRIBUTE_NET_KEY, (uint16_t *)&temp.length, &temp.buffer);
 
                        NFC_ERR("Network Key %s",temp.buffer);
                        // Sets Network Key
-                       err = wifi_ap_set_passphrase(context->ap_handle,(char*)temp.buffer);
+                       err = wifi_ap_set_passphrase(context->ap_handle, (char*)temp.buffer);
 
                        wifi_ap_get_encryption_type(context->ap_handle, &enc_type);
                        NFC_DBG("Encryption type %x",enc_type);
@@ -342,13 +348,13 @@ void _net_nfc_handover_bss_on_wifi_connected(wifi_error_e error_code, void* user
 {
        net_nfc_handover_bss_process_context_t *context = user_data;
 
-       if(context == NULL)
+       if(NULL == context)
        {
                NFC_ERR("Invalid context");
                return;
        }
 
-       if(error_code == WIFI_ERROR_NONE)
+       if(WIFI_ERROR_NONE == error_code)
        {
                NFC_ERR("WIFI Connected succesfully");
                context->result = NET_NFC_OK;
@@ -358,6 +364,7 @@ void _net_nfc_handover_bss_on_wifi_connected(wifi_error_e error_code, void* user
                NFC_ERR("Failed to connect WIFI");
                context->result = NET_NFC_OPERATION_FAIL;
        }
+
        context->step = NET_NFC_LLCP_STEP_RETURN;
        g_idle_add(_net_nfc_handover_bss_process_carrier_record,context);
 }
@@ -369,7 +376,7 @@ static gboolean _net_nfc_handover_bss_process_carrier_record(
 
        net_nfc_handover_bss_process_context_t *context = user_data;
 
-       if(context == NULL)
+       if(NULL == context)
        {
                NFC_ERR("Invalid context");
                NFC_ERR("Handover Failed");
@@ -430,8 +437,7 @@ static gboolean _net_nfc_handover_bss_process_carrier_record(
 
                        int err = WIFI_ERROR_NONE;
                        NFC_DBG("STEP [2]");
-                       err = wifi_scan(_net_nfc_handover_bss_on_wifi_scan_completed,
-                                       context);
+                       err = wifi_scan(_net_nfc_handover_bss_on_wifi_scan_completed, context);
                        if(err != WIFI_ERROR_NONE)
                        {
                                NFC_ERR("Wifi scan failed");
@@ -460,7 +466,7 @@ static gboolean _net_nfc_handover_bss_process_carrier_record(
        case NET_NFC_LLCP_STEP_RETURN :
                {
                        NFC_DBG("STEP return");
-                       if(context->result == NET_NFC_OK)
+                       if(NET_NFC_OK == context->result)
                        {
                                NFC_DBG("Handover completed succesfully");
                        }
@@ -469,10 +475,8 @@ static gboolean _net_nfc_handover_bss_process_carrier_record(
                                NFC_ERR("Handover Failed");
                        }
                        wifi_deinitialize();
-                       context->cb(context->result,
-                                       NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS,
-                                       NULL,
-                                       context->user_param);
+                       context->cb(context->result, NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS,
+                                       NULL, context->user_param);
                }
                break;
 
@@ -529,8 +533,7 @@ _net_nfc_wifi_direct_power_changed(int err, wifi_direct_device_state_e device_st
 
                context->step = NET_NFC_LLCP_STEP_RETURN;
                context->result = NET_NFC_OPERATION_FAIL;
-               g_idle_add((GSourceFunc)
-                               _net_nfc_handover_bss_wfd_get_carrier_record,
+               g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                (gpointer)context);
        }
 }
@@ -544,8 +547,7 @@ _net_nfc_wifi_scan_completed_cb(int err, wifi_direct_discovery_state_e discovery
 
        if(discovery_state == WIFI_DIRECT_ONLY_LISTEN_STARTED && err == WIFI_DIRECT_ERROR_NONE)
        {
-               g_idle_add((GSourceFunc)
-                               _net_nfc_handover_bss_wfd_get_carrier_record,
+               g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                (gpointer)context);
        }
        else
@@ -553,8 +555,7 @@ _net_nfc_wifi_scan_completed_cb(int err, wifi_direct_discovery_state_e discovery
                NFC_ERR("wifi scan error");
                context->step = NET_NFC_LLCP_STEP_RETURN;
                context->result = NET_NFC_OPERATION_FAIL;
-               g_idle_add((GSourceFunc)
-                               _net_nfc_handover_bss_wfd_get_carrier_record,
+               g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                (gpointer)context);
        }
 
@@ -573,8 +574,7 @@ _net_nfc_wifi_direct_connection_changed(wifi_direct_error_e error_code,
        if(connection_state == WIFI_DIRECT_GROUP_CREATED
                        && error_code == WIFI_DIRECT_ERROR_NONE)
        {
-               g_idle_add((GSourceFunc)
-                               _net_nfc_handover_bss_wfd_get_carrier_record,
+               g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                (gpointer)context);
        }
        else
@@ -584,8 +584,7 @@ _net_nfc_wifi_direct_connection_changed(wifi_direct_error_e error_code,
 
                context->step = NET_NFC_LLCP_STEP_RETURN;
                context->result = NET_NFC_OPERATION_FAIL;
-               g_idle_add((GSourceFunc)
-                               _net_nfc_handover_bss_wfd_get_carrier_record,
+               g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                (gpointer)context);
        }
 }
@@ -597,17 +596,12 @@ static net_nfc_error_e _net_nfc_handover_bss_create_carrier_record(
 {
        net_nfc_error_e result;
 
-       if ((result = net_nfc_util_create_handover_carrier_record(
-                                       record)) == NET_NFC_OK)
-       {
-               NFC_ERR("net_nfc_util_create_ndef_record"
-                               "_with_carrier_config [%d]",result);
-       }
+       result = net_nfc_util_create_handover_carrier_record(record);
+
+       if (NET_NFC_OK == result)
+               NFC_ERR("net_nfc_util_create_ndef_record_with_carrier_config [%d]",result);
        else
-       {
-               NFC_ERR("net_nfc_util_create_carrier_config failed "
-                               "[%d]", result);
-       }
+               NFC_ERR("net_nfc_util_create_carrier_config failed [%d]", result);
 
        return result;
 }
@@ -629,8 +623,8 @@ static int _net_nfc_handover_getpassword(uint8_t** password )
        FILE *f = fopen("/tmp/nfc_p2p_passphrase.txt","r");
        if(f != NULL)
        {
-               int readlength;
                int cnt;
+               int readlength;
                readlength = fread(data, 1 , 255, f);
                for(cnt = 0; cnt < readlength; cnt++)
                {
@@ -652,24 +646,25 @@ static int _net_nfc_handover_getpassword(uint8_t** password )
 static net_nfc_error_e _net_nfc_handover_bss_create_config_record(
                ndef_record_s **record)
 {
-       char* mac_address = NULL;
+       int pw_length = 0;
        char* ssid = NULL;
+       net_nfc_error_e result;
+       char* mac_address = NULL;
+       data_s enc_type = {NULL,0};
+       data_s mac_data = {NULL,0};
+       data_s ssid_data = {NULL,0};
+       data_s auth_data = {NULL,0};
+       data_s version_data = {NULL,0};
+       data_s net_index_data = {NULL,0};
        net_nfc_carrier_config_s *config = NULL;
        net_nfc_carrier_property_s *cred_config = NULL;
-       net_nfc_error_e result;
+
 #if 0
        char *passphrase = NULL;
 #else
        uint8_t *password = NULL;
 #endif
-       int pw_length = 0;
 
-       data_s version_data = {NULL,0};
-       data_s net_index_data = {NULL,0};
-       data_s ssid_data = {NULL,0};
-       data_s auth_data = {NULL,0};
-       data_s enc_type = {NULL,0};
-       data_s mac_data = {NULL,0};
 
        _net_nfc_util_alloc_mem(version_data.buffer,1);
        if(version_data.buffer)
@@ -677,14 +672,17 @@ static net_nfc_error_e _net_nfc_handover_bss_create_config_record(
                version_data.length = 1;
                *version_data.buffer = 0x01;
 
-               if ((result = net_nfc_util_create_carrier_config(
-                                               &config,
-                                               NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)) == NET_NFC_OK)
+               result = net_nfc_util_create_carrier_config(&config,
+                                               NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS);
+
+               if (NET_NFC_OK == result)
                {
-                       if ((result = net_nfc_util_add_carrier_config_property(
+                       result = net_nfc_util_add_carrier_config_property(
                                                        config,
                                                        NET_NFC_WIFI_ATTRIBUTE_VERSION,
-                                                       version_data.length, version_data.buffer)) != NET_NFC_OK)
+                                                       version_data.length, version_data.buffer);
+
+                       if (result != NET_NFC_OK)
                        {
                                NFC_ERR("net_nfc_util_add_carrier_config_property failed"
                                                "[%d]", result);
@@ -694,11 +692,11 @@ static net_nfc_error_e _net_nfc_handover_bss_create_config_record(
                _net_nfc_util_free_mem(version_data.buffer);
        }
 
-       if ((result = net_nfc_util_create_carrier_config_group(
-                                       &cred_config,
-                                       NET_NFC_WIFI_ATTRIBUTE_CREDENTIAL)) == NET_NFC_OK)
-       {
+       result = net_nfc_util_create_carrier_config_group(&cred_config,
+                                       NET_NFC_WIFI_ATTRIBUTE_CREDENTIAL);
 
+       if (NET_NFC_OK == result)
+       {
                _net_nfc_util_alloc_mem(net_index_data.buffer,1);
                if(net_index_data.buffer)
                {
@@ -797,15 +795,11 @@ static net_nfc_error_e _net_nfc_handover_bss_create_config_record(
        }
        net_nfc_util_append_carrier_config_group(config, cred_config);
 
-       result = net_nfc_util_create_ndef_record_with_carrier_config(
-                       record,
-                       config);
+       result = net_nfc_util_create_ndef_record_with_carrier_config(record, config);
 
        if (result != NET_NFC_OK)
        {
-               NFC_ERR("net_nfc_util_create_ndef_record"
-                               "_with_carrier_config failed"
-                               "[%d]",result);
+               NFC_ERR("net_nfc_util_create_ndef_record_with_carrier_config failed [%d]",result);
        }
 
        return result;
@@ -820,38 +814,26 @@ static void _net_nfc_handover_bss_get_carrier_record(
 
        if(context != NULL)
        {
-
                if (context->result != NET_NFC_OK && context->result != NET_NFC_BUSY)
-               {
                        NFC_ERR("context->result is error [%d]", context->result);
-               }
 
                context->result = NET_NFC_OK;
-
                context->cps = NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE;
 
                /* Create carrier record */
-               context->result =_net_nfc_handover_bss_create_carrier_record(
-                               &context->carrier);
+               context->result =_net_nfc_handover_bss_create_carrier_record(&context->carrier);
+
                if (context->result!= NET_NFC_OK)
-               {
-                       NFC_ERR("create_bss_config_record failed"
-                                       " [%d]", context->result);
-               }
+                       NFC_ERR("create_bss_config_record failed [%d]", context->result);
 
                /* complete and return to upper step */
-               context->cb(context->result,
-                               context->cps,
-                               context->carrier,
-                               0,
-                               NULL,
+               context->cb(context->result, context->cps, context->carrier, 0, NULL,
                                context->user_param);
        }
 }
 
 #ifdef TARGET
-static void _net_nfc_wifi_process_error(
-               int error,
+static void _net_nfc_wifi_process_error(int error,
                net_nfc_handover_bss_get_context_t *context)
 {
        NFC_ERR("_net_nfc_wifi_process_error - [%d]",error);
@@ -859,8 +841,7 @@ static void _net_nfc_wifi_process_error(
        context->step = NET_NFC_LLCP_STEP_RETURN;
        context->result = NET_NFC_OPERATION_FAIL;
 
-       g_idle_add((GSourceFunc)
-                       _net_nfc_handover_bss_wfd_get_carrier_record,
+       g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                        (gpointer)context);
 
        return;
@@ -877,8 +858,7 @@ static int _net_nfc_handover_process_wifi_direct_setup(
                return err;
        }
 
-       err = wifi_direct_set_device_state_changed_cb(
-                       _net_nfc_wifi_direct_power_changed,
+       err = wifi_direct_set_device_state_changed_cb(_net_nfc_wifi_direct_power_changed,
                        context);
 
        if(err != WIFI_DIRECT_ERROR_NONE)
@@ -887,8 +867,7 @@ static int _net_nfc_handover_process_wifi_direct_setup(
                return err;
        }
 
-       err = wifi_direct_set_discovery_state_changed_cb(
-                       _net_nfc_wifi_scan_completed_cb,
+       err = wifi_direct_set_discovery_state_changed_cb(_net_nfc_wifi_scan_completed_cb,
                        context);
 
        if(err != WIFI_DIRECT_ERROR_NONE)
@@ -898,8 +877,7 @@ static int _net_nfc_handover_process_wifi_direct_setup(
        }
 
        err = wifi_direct_set_connection_state_changed_cb(
-                       _net_nfc_wifi_direct_connection_changed,
-                       context);
+                       _net_nfc_wifi_direct_connection_changed, context);
 
        if (err != WIFI_DIRECT_ERROR_NONE)
        {
@@ -925,8 +903,7 @@ static int _net_nfc_handover_process_wifi_direct_setup(
                        NFC_DBG("wifi direct is enabled already");
 
                        /* do next step */
-                       g_idle_add((GSourceFunc)
-                                       _net_nfc_handover_bss_wfd_get_carrier_record,
+                       g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                        (gpointer)context);
                }
                return WIFI_DIRECT_ERROR_NONE;
@@ -946,13 +923,12 @@ static int _net_nfc_handover_process_wifi_group_setup(
        context->step = NET_NFC_LLCP_STEP_03;
        context->result = NET_NFC_OK;
 
-       if(err == WIFI_DIRECT_ERROR_NONE)
+       if(WIFI_DIRECT_ERROR_NONE == err)
        {
-               if(group_owner == true)
+               if(true == group_owner)
                {
                        NFC_DBG("Already group owner, continue next step");
-                       g_idle_add((GSourceFunc)
-                                       _net_nfc_handover_bss_wfd_get_carrier_record,
+                       g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                        (gpointer)context);
                }
                else
@@ -978,7 +954,7 @@ static gboolean _net_nfc_handover_bss_wfd_get_carrier_record(
                net_nfc_handover_bss_get_context_t *context)
 {
        LOGD("[%s:%d] START", __func__, __LINE__);
-       if(context == NULL)
+       if(NULL == context)
        {
                NFC_ERR("Invalid context");
                return FALSE;
@@ -990,8 +966,7 @@ static gboolean _net_nfc_handover_bss_wfd_get_carrier_record(
 
                if (context->result != NET_NFC_OK && context->result != NET_NFC_BUSY)
                {
-                       NFC_ERR("context->result is error"
-                                       " [%d]", context->result);
+                       NFC_ERR("context->result is error [%d]", context->result);
 
                        context->step = NET_NFC_LLCP_STEP_RETURN;
                }
@@ -1021,16 +996,14 @@ static gboolean _net_nfc_handover_bss_wfd_get_carrier_record(
                        context->step = NET_NFC_LLCP_STEP_RETURN;
 
                        /* append config to ndef message */
-                       context->result =_net_nfc_handover_bss_create_config_record(
-                                       &context->carrier);
+                       context->result =_net_nfc_handover_bss_create_config_record(&context->carrier);
                        if (context->result != NET_NFC_OK)
                        {
                                NFC_ERR("_net_nfc_handover_bss_create_config_record failed"
                                                "[%d]", context->result);
                        }
 
-                       g_idle_add((GSourceFunc)
-                                       _net_nfc_handover_bss_wfd_get_carrier_record,
+                       g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
                                        (gpointer)context);
 
                        break;
@@ -1043,12 +1016,8 @@ static gboolean _net_nfc_handover_bss_wfd_get_carrier_record(
                        wifi_direct_deinitialize();
 
                        /* complete and return to upper step */
-                       context->cb(context->result,
-                                       context->cps,
-                                       context->carrier,
-                                       context->aux_data_count,
-                                       context->aux_data,
-                                       context->user_param);
+                       context->cb(context->result, context->cps, context->carrier,
+                                       context->aux_data_count, context->aux_data, context->user_param);
                        break;
 
                default :
@@ -1062,8 +1031,7 @@ static gboolean _net_nfc_handover_bss_wfd_get_carrier_record(
 #endif
 
 net_nfc_error_e net_nfc_server_handover_bss_get_carrier_record(
-               net_nfc_server_handover_get_carrier_record_cb cb,
-               void *user_param)
+               net_nfc_server_handover_get_carrier_record_cb cb, void *user_param)
 {
        net_nfc_error_e result = NET_NFC_OK;
        net_nfc_handover_bss_create_context_t *context = NULL;
@@ -1076,7 +1044,6 @@ net_nfc_error_e net_nfc_server_handover_bss_get_carrier_record(
                context->step = NET_NFC_LLCP_STEP_01;
 
                _net_nfc_handover_bss_get_carrier_record(context);
-
        }
        else
        {
@@ -1088,8 +1055,7 @@ net_nfc_error_e net_nfc_server_handover_bss_get_carrier_record(
 
 #ifdef TARGET
 net_nfc_error_e net_nfc_server_handover_bss_wfd_get_carrier_record(
-               net_nfc_server_handover_get_carrier_record_cb cb,
-               void *user_param)
+               net_nfc_server_handover_get_carrier_record_cb cb, void *user_param)
 {
        net_nfc_handover_bss_get_context_t *context = NULL;
 
index 46dcc4d..d5385ba 100755 (executable)
@@ -59,24 +59,24 @@ static net_nfc_error_e _net_nfc_handover_bt_get_oob_data(
                net_nfc_carrier_config_s *config,
                bt_oob_data_t *oob)
 {
-       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
        data_s hash = { NULL, 0 };
        data_s randomizer = { NULL, 0 };
+       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
 
        LOGD("[%s:%d] START", __func__, __LINE__);
 
-       if (config == NULL || oob == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == oob, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
 
        memset(oob, 0, sizeof(bt_oob_data_t));
 
-       if ((result = net_nfc_util_get_carrier_config_property(
-                                       config,
-                                       NET_NFC_BT_ATTRIBUTE_OOB_HASH_C,
-                                       (uint16_t *)&hash.length,
-                                       &hash.buffer)) == NET_NFC_OK)
+       result = net_nfc_util_get_carrier_config_property(
+                                               config,
+                                               NET_NFC_BT_ATTRIBUTE_OOB_HASH_C,
+                                               (uint16_t *)&hash.length,
+                                               &hash.buffer);
+
+       if (NET_NFC_OK == result)
        {
                if (hash.length == 16)
                {
@@ -93,11 +93,13 @@ static net_nfc_error_e _net_nfc_handover_bt_get_oob_data(
                }
        }
 
-       if ((result = net_nfc_util_get_carrier_config_property(
+       result = net_nfc_util_get_carrier_config_property(
                                        config,
                                        NET_NFC_BT_ATTRIBUTE_OOB_HASH_R,
                                        (uint16_t *)&randomizer.length,
-                                       &randomizer.buffer)) == NET_NFC_OK)
+                                       &randomizer.buffer);
+
+       if (NET_NFC_OK == result)
        {
                if (randomizer.length == 16)
                {
index 12af281..b5f4072 100644 (file)
@@ -210,243 +210,41 @@ struct _LlcpSimpleData
 };
 
 static void llcp_socket_error_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_incoming_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_connect_by_url_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_connect_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_send_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_send_to_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_receive_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_receive_from_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_disconnect_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-/* client method */
-static void llcp_handle_config_thread_func(gpointer user_data);
-
-static void llcp_handle_listen_thread_func(gpointer user_data);
-
-static void llcp_handle_accept_thread_func(gpointer user_data);
-
-static void llcp_handle_reject_thread_func(gpointer user_data);
-
-static void llcp_handle_connect_thread_func(gpointer user_data);
-
-static void llcp_handle_connect_sap_thread_func(gpointer user_data);
-
-static void llcp_handle_send_thread_func(gpointer user_data);
-
-static void llcp_handle_send_to_thread_func(gpointer user_data);
-
-static void llcp_handle_receive_thread_func(gpointer user_data);
-
-static void llcp_handle_receive_from_thread_func(gpointer user_data);
-
-static void llcp_handle_close_thread_func(gpointer user_data);
-
-static void llcp_handle_disconnect_thread_func(gpointer user_data);
-
-/* methods */
-static gboolean llcp_handle_config(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               GVariant *arg_config,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_listen(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               guint16 arg_miu,
-               guint8 arg_rw,
-               gint32 arg_type,
-               guint8 arg_sap,
-               const gchar *arg_service_name,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_connect(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               guint16 arg_miu,
-               guint8 arg_rw,
-               gint32 arg_type,
-               const gchar *arg_service_name,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_connect_sap(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               guint16 arg_miu,
-               guint8 arg_rw,
-               gint32 arg_type,
-               guint8 arg_sap,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_send(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               GVariant *arg_data,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_send_to(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               guint8 arg_sap,
-               GVariant *arg_data,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_receive(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               guint32 arg_req_length,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_receive_from(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               guint32 arg_req_length,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_close(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean llcp_handle_disconnect(NetNfcGDbusLlcp *llcp,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               guint32 arg_client_socket,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-
-/* simple */
-static void llcp_simple_socket_error_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_simple_listen_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_simple_connect_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_simple_send_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-static void llcp_simple_receive_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param);
-
-
-static void llcp_socket_error_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       llcp_client_data *client_data = (llcp_client_data *)user_param;
+       gboolean ret;
        GError *error = NULL;
+       llcp_client_data *client_data = user_param;
 
-       if (g_dbus_connection_emit_signal(
+       ret = g_dbus_connection_emit_signal(
                                client_data->connection,
                                client_data->id,
-                               "/org/tizen/NetNfcService/Llcp",
+                          "/org/tizen/NetNfcService/Llcp",
                                "org.tizen.NetNfcService.Llcp",
                                "Error",
                                g_variant_new("(uui)",
-                                       GPOINTER_TO_UINT(client_data->handle),
-                                       socket,
-                                       result),
-                               &error) == false) {
-               if (error != NULL && error->message != NULL) {
+                               GPOINTER_TO_UINT(client_data->handle),
+                               socket,
+                               result),
+                               &error);
+
+       if (FALSE == ret)
+       {
+               if (error != NULL && error->message != NULL)
                        NFC_ERR("g_dbus_connection_emit_signal failed : %s", error->message);
-               } else {
+               else
                        NFC_ERR("g_dbus_connection_emit_signal failed");
-               }
        }
 }
 
 static void llcp_incoming_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       llcp_client_data *client_data = (llcp_client_data *)user_param;
+       gboolean ret;
        GError *error = NULL;
+       llcp_client_data *client_data = user_param;
 
-       if (g_dbus_connection_emit_signal(
+       ret = g_dbus_connection_emit_signal(
                                client_data->connection,
                                client_data->id,
                                "/org/tizen/NetNfcService/Llcp",
@@ -456,31 +254,28 @@ static void llcp_incoming_cb(net_nfc_llcp_socket_t socket,
                                        GPOINTER_TO_UINT(client_data->handle),
                                        client_data->socket,
                                        socket),
-                               &error) == false) {
-               if (error != NULL && error->message != NULL) {
+                               &error);
+
+       if (FALSE == ret)
+       {
+               if (error != NULL && error->message != NULL)
                        NFC_ERR("g_dbus_connection_emit_signal failed : %s", error->message);
-               } else {
+               else
                        NFC_ERR("g_dbus_connection_emit_signal failed");
-               }
        }
 }
 
 static void llcp_connect_by_url_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpConnectData *llcp_data = (LlcpConnectData *)user_param;
+       LlcpConnectData *llcp_data = user_param;
 
        g_assert(llcp_data != NULL);
        g_assert(llcp_data->llcp != NULL);
        g_assert(llcp_data->invocation != NULL);
 
-       net_nfc_gdbus_llcp_complete_connect(llcp_data->llcp,
-                       llcp_data->invocation,
-                       result,
-                       socket);
+       net_nfc_gdbus_llcp_complete_connect(llcp_data->llcp, llcp_data->invocation,
+                       result, socket);
 
        g_free(llcp_data->service_name);
 
@@ -491,22 +286,16 @@ static void llcp_connect_by_url_cb(net_nfc_llcp_socket_t socket,
 }
 
 static void llcp_connect_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpConnectSapData *llcp_data = (LlcpConnectSapData *)user_param;
+       LlcpConnectSapData *llcp_data = user_param;
 
        g_assert(llcp_data != NULL);
        g_assert(llcp_data->llcp != NULL);
        g_assert(llcp_data->invocation != NULL);
 
-       net_nfc_gdbus_llcp_complete_connect_sap(
-                       llcp_data->llcp,
-                       llcp_data->invocation,
-                       result,
-                       socket);
+       net_nfc_gdbus_llcp_complete_connect_sap(llcp_data->llcp, llcp_data->invocation,
+                       result, socket);
 
        g_object_unref(llcp_data->invocation);
        g_object_unref(llcp_data->llcp);
@@ -515,22 +304,16 @@ static void llcp_connect_cb(net_nfc_llcp_socket_t socket,
 }
 
 static void llcp_send_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpSendData *llcp_data = (LlcpSendData *)user_param;
+       LlcpSendData *llcp_data = user_param;
 
        g_assert(llcp_data != NULL);
        g_assert(llcp_data->llcp != NULL);
        g_assert(llcp_data->invocation != NULL);
 
-       net_nfc_gdbus_llcp_complete_send(
-                       llcp_data->llcp,
-                       llcp_data->invocation,
-                       result,
-                       socket);
+       net_nfc_gdbus_llcp_complete_send(llcp_data->llcp, llcp_data->invocation,
+                       result, socket);
 
        net_nfc_util_free_data(&llcp_data->data);
 
@@ -541,22 +324,16 @@ static void llcp_send_cb(net_nfc_llcp_socket_t socket,
 }
 
 static void llcp_send_to_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpSendToData *llcp_data = (LlcpSendToData *)user_param;
+       LlcpSendToData *llcp_data = user_param;
 
        g_assert(llcp_data != NULL);
        g_assert(llcp_data->llcp != NULL);
        g_assert(llcp_data->invocation != NULL);
 
-       net_nfc_gdbus_llcp_complete_send_to(
-                       llcp_data->llcp,
-                       llcp_data->invocation,
-                       result,
-                       socket);
+       net_nfc_gdbus_llcp_complete_send_to(llcp_data->llcp, llcp_data->invocation,
+                       result, socket);
 
        net_nfc_util_free_data(&llcp_data->data);
 
@@ -566,25 +343,19 @@ static void llcp_send_to_cb(net_nfc_llcp_socket_t socket,
        g_free(llcp_data);
 }
 
-static void llcp_receive_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+static void llcp_receive_cb(net_nfc_llcp_socket_t socket, net_nfc_error_e result,
+               data_s *data, void *extra, void *user_param)
 {
-       LlcpReceiveData *llcp_data = (LlcpReceiveData *)user_param;
        GVariant *variant;
+       LlcpReceiveData *llcp_data = user_param;
 
        g_assert(llcp_data != NULL);
        g_assert(llcp_data->llcp != NULL);
        g_assert(llcp_data->invocation != NULL);
 
        variant = net_nfc_util_gdbus_data_to_variant(data);
-       net_nfc_gdbus_llcp_complete_receive(
-                       llcp_data->llcp,
-                       llcp_data->invocation,
-                       result,
-                       variant);
+       net_nfc_gdbus_llcp_complete_receive(llcp_data->llcp, llcp_data->invocation,
+                       result, variant);
 
        g_object_unref(llcp_data->invocation);
        g_object_unref(llcp_data->llcp);
@@ -598,20 +369,16 @@ static void llcp_receive_from_cb(net_nfc_llcp_socket_t socket,
                void *extra,
                void *user_param)
 {
-       LlcpReceiveData *llcp_data = (LlcpReceiveData *)user_param;
        GVariant *variant;
+       LlcpReceiveData *llcp_data = user_param;
 
        g_assert(llcp_data != NULL);
        g_assert(llcp_data->llcp != NULL);
        g_assert(llcp_data->invocation != NULL);
 
        variant = net_nfc_util_gdbus_data_to_variant(data);
-       net_nfc_gdbus_llcp_complete_receive_from(
-                       llcp_data->llcp,
-                       llcp_data->invocation,
-                       result,
-                       (guint8) (int)extra,
-                       variant);
+       net_nfc_gdbus_llcp_complete_receive_from(llcp_data->llcp, llcp_data->invocation,
+                       result, (guint8) (int)extra, variant);
 
        g_object_unref(llcp_data->invocation);
        g_object_unref(llcp_data->llcp);
@@ -621,22 +388,16 @@ static void llcp_receive_from_cb(net_nfc_llcp_socket_t socket,
 
 
 static void llcp_disconnect_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpDisconnectData *llcp_data = (LlcpDisconnectData *)user_param;
+       LlcpDisconnectData *llcp_data = user_param;
 
        g_assert(llcp_data != NULL);
        g_assert(llcp_data->llcp != NULL);
        g_assert(llcp_data->invocation != NULL);
 
-       net_nfc_gdbus_llcp_complete_disconnect(
-                       llcp_data->llcp,
-                       llcp_data->invocation,
-                       result,
-                       socket);
+       net_nfc_gdbus_llcp_complete_disconnect(llcp_data->llcp, llcp_data->invocation,
+                       result, socket);
 
        g_object_unref(llcp_data->invocation);
        g_object_unref(llcp_data->llcp);
@@ -647,8 +408,8 @@ static void llcp_disconnect_cb(net_nfc_llcp_socket_t socket,
 
 static void llcp_handle_config_thread_func(gpointer user_data)
 {
-       LlcpConfigData *data = (LlcpConfigData *)user_data;
        net_nfc_error_e result;
+       LlcpConfigData *data = user_data;
        net_nfc_llcp_config_info_s config;
 
        g_assert(data != NULL);
@@ -662,9 +423,7 @@ static void llcp_handle_config_thread_func(gpointer user_data)
 
        result = net_nfc_server_llcp_set_config(&config);
 
-       net_nfc_gdbus_llcp_complete_config(data->llcp,
-                       data->invocation,
-                       result);
+       net_nfc_gdbus_llcp_complete_config(data->llcp, data->invocation, result);
 
        g_object_unref(data->invocation);
        g_object_unref(data->llcp);
@@ -674,36 +433,32 @@ static void llcp_handle_config_thread_func(gpointer user_data)
 
 static void llcp_handle_listen_thread_func(gpointer user_data)
 {
-       LlcpListenData *data = (LlcpListenData *)user_data;
+       bool ret;
+       net_nfc_error_e result;
        llcp_client_data *client_data;
-
+       LlcpListenData *data = user_data;
        net_nfc_llcp_socket_t socket = -1;
-       net_nfc_error_e result;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
        client_data = g_try_new0(llcp_client_data, 1);
-       if (client_data == NULL) {
+       if (NULL == client_data)
+       {
                result = NET_NFC_ALLOC_FAIL;
 
                goto ERROR;
        }
 
-       client_data->connection = g_dbus_method_invocation_get_connection(
-                       data->invocation);
-       client_data->id = g_strdup(
-                       g_dbus_method_invocation_get_sender(data->invocation));
+       client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+       client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
        client_data->handle = (net_nfc_target_handle_s*)data->handle;
 
-       if (net_nfc_controller_llcp_create_socket(&socket,
-                               data->type,
-                               data->miu,
-                               data->rw,
-                               &result,
-                               llcp_socket_error_cb,
-                               client_data) == false)
+       ret = net_nfc_controller_llcp_create_socket(&socket, data->type, data->miu, data->rw,
+                               &result, llcp_socket_error_cb, client_data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
 
@@ -712,29 +467,28 @@ static void llcp_handle_listen_thread_func(gpointer user_data)
 
        client_data->socket = socket;
 
-       if (net_nfc_controller_llcp_bind(socket,
-                               data->sap,
-                               &result) == false)
+       if (net_nfc_controller_llcp_bind(socket, data->sap, &result) == false)
        {
                NFC_ERR("net_nfc_controller_llcp_bind failed [%d]", result);
 
                goto ERROR;
        }
 
-       if (net_nfc_controller_llcp_listen(GUINT_TO_POINTER(data->handle),
+       ret = net_nfc_controller_llcp_listen(GUINT_TO_POINTER(data->handle),
                                (uint8_t *)data->service_name,
                                socket,
                                &result,
                                llcp_incoming_cb,
-                               client_data) == false)
+                               client_data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
 
                goto ERROR;
        }
 
-       net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation,
-                       result,
+       net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation, result,
                        GPOINTER_TO_UINT(socket));
 
        g_object_unref(data->invocation);
@@ -745,9 +499,7 @@ static void llcp_handle_listen_thread_func(gpointer user_data)
        return;
 
 ERROR :
-       net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation,
-                       result,
-                       -1);
+       net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation, result, -1);
 
        if (socket != -1)
                net_nfc_controller_llcp_socket_close(socket, &result);
@@ -764,38 +516,39 @@ ERROR :
 
 static void llcp_handle_accept_thread_func(gpointer user_data)
 {
-       LlcpAcceptData *data = (LlcpAcceptData *)user_data;
-       llcp_client_data *client_data;
+       bool ret;
        net_nfc_error_e result;
+       llcp_client_data *client_data;
+       LlcpAcceptData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
        client_data = g_try_new0(llcp_client_data, 1);
-       if (client_data == NULL) {
+       if (NULL == client_data)
+       {
                result = NET_NFC_ALLOC_FAIL;
 
                goto ERROR;
        }
 
-       client_data->connection = g_dbus_method_invocation_get_connection(
-                       data->invocation);
-       client_data->id = g_strdup(
-                       g_dbus_method_invocation_get_sender(data->invocation));
+       client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+       client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
        client_data->handle = (net_nfc_target_handle_s*)data->handle;
        client_data->socket = data->client_socket;
 
-       if (net_nfc_controller_llcp_accept(data->client_socket, &result,
-                               llcp_socket_error_cb,
-                               client_data) == false) {
+       ret = net_nfc_controller_llcp_accept(data->client_socket, &result,
+                               llcp_socket_error_cb, client_data);
+
+       if (false == ret)
+       {
                NFC_ERR("net_nfc_controller_llcp_accept failed [%d]", result);
 
                goto ERROR;
        }
 
-       net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation,
-                       result);
+       net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation, result);
 
        g_object_unref(data->invocation);
        g_object_unref(data->llcp);
@@ -805,8 +558,7 @@ static void llcp_handle_accept_thread_func(gpointer user_data)
        return;
 
 ERROR :
-       net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation,
-                       result);
+       net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation, result);
 
        g_free(client_data);
 
@@ -818,21 +570,21 @@ ERROR :
 
 static void llcp_handle_reject_thread_func(gpointer user_data)
 {
-       LlcpAcceptData *data = (LlcpAcceptData *)user_data;
+       bool ret;
        net_nfc_error_e result;
+       LlcpAcceptData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
-       if (net_nfc_controller_llcp_reject(GUINT_TO_POINTER(data->handle),
-                               data->client_socket,
-                               &result) == false) {
+       ret = net_nfc_controller_llcp_reject(GUINT_TO_POINTER(data->handle),
+                               data->client_socket, &result);
+
+       if (false == ret)
                NFC_ERR("net_nfc_controller_llcp_reject failed [%d]", result);
-       }
 
-       net_nfc_gdbus_llcp_complete_reject(data->llcp, data->invocation,
-                       result);
+       net_nfc_gdbus_llcp_complete_reject(data->llcp, data->invocation, result);
 
        g_object_unref(data->invocation);
        g_object_unref(data->llcp);
@@ -843,35 +595,33 @@ static void llcp_handle_reject_thread_func(gpointer user_data)
 
 static void llcp_handle_connect_thread_func(gpointer user_data)
 {
-       LlcpConnectData *data = (LlcpConnectData *)user_data;
+       bool ret;
+       net_nfc_error_e result;
        llcp_client_data *client_data;
+       LlcpConnectData *data = user_data;
        net_nfc_llcp_socket_t socket = -1;
-       net_nfc_error_e result;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
        client_data = g_try_new0(llcp_client_data, 1);
-       if (client_data == NULL) {
+
+       if (NULL == client_data)
+       {
                result = NET_NFC_ALLOC_FAIL;
 
                goto ERROR;
        }
 
-       client_data->connection = g_dbus_method_invocation_get_connection(
-                       data->invocation);
-       client_data->id = g_strdup(
-                       g_dbus_method_invocation_get_sender(data->invocation));
+       client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+       client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
        client_data->handle = (net_nfc_target_handle_s*)data->handle;
 
-       if (net_nfc_controller_llcp_create_socket(&socket,
-                               data->type,
-                               data->miu,
-                               data->rw,
-                               &result,
-                               llcp_socket_error_cb,
-                               client_data) == false)
+       ret = net_nfc_controller_llcp_create_socket(&socket, data->type, data->miu, data->rw,
+                               &result, llcp_socket_error_cb, client_data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
 
@@ -880,13 +630,15 @@ static void llcp_handle_connect_thread_func(gpointer user_data)
 
        client_data->socket = socket;
 
-       if (net_nfc_controller_llcp_connect_by_url(
+       ret = net_nfc_controller_llcp_connect_by_url(
                                GUINT_TO_POINTER(data->handle),
                                socket,
                                (uint8_t *)data->service_name,
                                &result,
                                llcp_connect_by_url_cb,
-                               data) == false)
+                               data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
 
@@ -901,9 +653,7 @@ static void llcp_handle_connect_thread_func(gpointer user_data)
        return;
 
 ERROR :
-       net_nfc_gdbus_llcp_complete_connect(data->llcp, data->invocation,
-                       result,
-                       -1);
+       net_nfc_gdbus_llcp_complete_connect(data->llcp, data->invocation, result, -1);
 
        if (socket != -1)
                net_nfc_controller_llcp_socket_close(socket, &result);
@@ -920,36 +670,32 @@ ERROR :
 
 static void llcp_handle_connect_sap_thread_func(gpointer user_data)
 {
-       LlcpConnectSapData *data = (LlcpConnectSapData *)user_data;
+       bool ret;
        llcp_client_data *client_data;
-
        net_nfc_llcp_socket_t socket = -1;
        net_nfc_error_e result = NET_NFC_OK;
+       LlcpConnectSapData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
        client_data = g_try_new0(llcp_client_data, 1);
-       if (client_data == NULL) {
+       if (NULL == client_data)
+       {
                result = NET_NFC_ALLOC_FAIL;
 
                goto ERROR;
        }
 
-       client_data->connection = g_dbus_method_invocation_get_connection(
-                       data->invocation);
-       client_data->id = g_strdup(
-                       g_dbus_method_invocation_get_sender(data->invocation));
+       client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+       client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
        client_data->handle = (net_nfc_target_handle_s*)data->handle;
 
-       if (net_nfc_controller_llcp_create_socket(&socket,
-                               data->type,
-                               data->miu,
-                               data->rw,
-                               &result,
-                               llcp_socket_error_cb,
-                               client_data) == false)
+       ret = net_nfc_controller_llcp_create_socket(&socket, data->type, data->miu, data->rw,
+                               &result, llcp_socket_error_cb, client_data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
 
@@ -958,12 +704,10 @@ static void llcp_handle_connect_sap_thread_func(gpointer user_data)
 
        client_data->socket = socket;
 
-       if (net_nfc_controller_llcp_connect(GUINT_TO_POINTER(data->handle),
-                               socket,
-                               data->sap,
-                               &result,
-                               llcp_connect_cb,
-                               data) == false)
+       ret = net_nfc_controller_llcp_connect(GUINT_TO_POINTER(data->handle), socket,
+                               data->sap, &result, llcp_connect_cb, data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
 
@@ -978,9 +722,7 @@ static void llcp_handle_connect_sap_thread_func(gpointer user_data)
        return;
 
 ERROR :
-       net_nfc_gdbus_llcp_complete_connect_sap(data->llcp, data->invocation,
-                       result,
-                       -1);
+       net_nfc_gdbus_llcp_complete_connect_sap(data->llcp, data->invocation, result, -1);
 
        if (socket != -1)
                net_nfc_controller_llcp_socket_close(socket, &result);
@@ -995,25 +737,22 @@ ERROR :
 
 static void llcp_handle_send_thread_func(gpointer user_data)
 {
-       LlcpSendData *data = (LlcpSendData *)user_data;
+       bool ret;
        net_nfc_error_e result;
+       LlcpSendData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
-       if (net_nfc_controller_llcp_send(GUINT_TO_POINTER(data->handle),
-                               data->client_socket,
-                               &data->data,
-                               &result,
-                               llcp_send_cb,
-                               data) == false)
+       ret = net_nfc_controller_llcp_send(GUINT_TO_POINTER(data->handle),
+                               data->client_socket, &data->data, &result, llcp_send_cb, data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_send failed [%d]", result);
 
-               net_nfc_gdbus_llcp_complete_send(data->llcp,
-                               data->invocation,
-                               result,
+               net_nfc_gdbus_llcp_complete_send(data->llcp, data->invocation, result,
                                data->client_socket);
 
                net_nfc_util_free_data(&data->data);
@@ -1027,26 +766,27 @@ static void llcp_handle_send_thread_func(gpointer user_data)
 
 static void llcp_handle_send_to_thread_func(gpointer user_data)
 {
-       LlcpSendToData *data = (LlcpSendToData *)user_data;
+       bool ret;
        net_nfc_error_e result;
+       LlcpSendToData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
-       if (net_nfc_controller_llcp_send_to(GUINT_TO_POINTER(data->handle),
+       ret = net_nfc_controller_llcp_send_to(GUINT_TO_POINTER(data->handle),
                                data->client_socket,
                                &data->data,
                                data->sap,
                                &result,
                                llcp_send_to_cb,
-                               data) == false)
+                               data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_send_to failed [%d]", result);
 
-               net_nfc_gdbus_llcp_complete_send_to(data->llcp,
-                               data->invocation,
-                               result,
+               net_nfc_gdbus_llcp_complete_send_to(data->llcp, data->invocation, result,
                                data->client_socket);
 
                net_nfc_util_free_data(&data->data);
@@ -1060,25 +800,26 @@ static void llcp_handle_send_to_thread_func(gpointer user_data)
 
 static void llcp_handle_receive_thread_func(gpointer user_data)
 {
-       LlcpReceiveData *data = (LlcpReceiveData *)user_data;
+       bool ret;
        net_nfc_error_e result;
+       LlcpReceiveData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
-       if (net_nfc_controller_llcp_recv(GUINT_TO_POINTER(data->handle),
+       ret = net_nfc_controller_llcp_recv(GUINT_TO_POINTER(data->handle),
                                data->client_socket,
                                data->req_length,
                                &result,
                                llcp_receive_cb,
-                               data) == false)
+                               data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_recv failed [%d]", result);
 
-               net_nfc_gdbus_llcp_complete_receive(data->llcp,
-                               data->invocation,
-                               result,
+               net_nfc_gdbus_llcp_complete_receive(data->llcp, data->invocation, result,
                                net_nfc_util_gdbus_buffer_to_variant(NULL, 0));
 
                g_object_unref(data->invocation);
@@ -1090,26 +831,26 @@ static void llcp_handle_receive_thread_func(gpointer user_data)
 
 static void llcp_handle_receive_from_thread_func(gpointer user_data)
 {
-       LlcpReceiveData *data = (LlcpReceiveData *)user_data;
+       bool ret;
        net_nfc_error_e result;
+       LlcpReceiveData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
        g_assert(data->invocation != NULL);
 
-       if (net_nfc_controller_llcp_recv_from(GUINT_TO_POINTER(data->handle),
+       ret = net_nfc_controller_llcp_recv_from(GUINT_TO_POINTER(data->handle),
                                data->client_socket,
                                data->req_length,
                                &result,
                                llcp_receive_from_cb,
-                               data) == false)
+                               data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_recv_from failed [%d]", result);
 
-               net_nfc_gdbus_llcp_complete_receive_from(data->llcp,
-                               data->invocation,
-                               result,
-                               -1,
+               net_nfc_gdbus_llcp_complete_receive_from(data->llcp, data->invocation, result, -1,
                                net_nfc_util_gdbus_buffer_to_variant(NULL, 0));
 
                g_object_unref(data->invocation);
@@ -1121,8 +862,8 @@ static void llcp_handle_receive_from_thread_func(gpointer user_data)
 
 static void llcp_handle_close_thread_func(gpointer user_data)
 {
-       LlcpCloseData *data = (LlcpCloseData *)user_data;
        net_nfc_error_e result;
+       LlcpCloseData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
@@ -1130,16 +871,15 @@ static void llcp_handle_close_thread_func(gpointer user_data)
 
        net_nfc_controller_llcp_socket_close(data->client_socket, &result);
 
-       net_nfc_gdbus_llcp_complete_close(data->llcp,
-                       data->invocation,
-                       result,
+       net_nfc_gdbus_llcp_complete_close(data->llcp, data->invocation, result,
                        data->client_socket);
 }
 
 static void llcp_handle_disconnect_thread_func(gpointer user_data)
 {
-       LlcpDisconnectData *data = (LlcpDisconnectData *)user_data;
+       bool ret;
        net_nfc_error_e result;
+       LlcpDisconnectData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->llcp != NULL);
@@ -1154,17 +894,14 @@ static void llcp_handle_disconnect_thread_func(gpointer user_data)
                NFC_DBG("net_nfc_controller_disconnect pm_unlock_state[%d]!!", ret_val);
        }
 
-       if (net_nfc_controller_llcp_disconnect(GUINT_TO_POINTER(data->handle),
-                               data->client_socket,
-                               &result,
-                               llcp_disconnect_cb,
-                               data) == false)
+       ret = net_nfc_controller_llcp_disconnect(GUINT_TO_POINTER(data->handle),
+                               data->client_socket, &result, llcp_disconnect_cb, data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_disconnect failed [%d]", result);
 
-               net_nfc_gdbus_llcp_complete_disconnect(data->llcp,
-                               data->invocation,
-                               result,
+               net_nfc_gdbus_llcp_complete_disconnect(data->llcp, data->invocation, result,
                                data->client_socket);
 
                g_object_unref(data->invocation);
@@ -1181,24 +918,25 @@ static gboolean llcp_handle_config(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpConfigData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                       "nfc-manager::p2p", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpConfigData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.AllocationError",
                                "Can not allocate memory");
@@ -1209,17 +947,12 @@ static gboolean llcp_handle_config(NetNfcGDbusLlcp *llcp,
        data->llcp = g_object_ref(llcp);
        data->invocation = g_object_ref(invocation);
 
-       g_variant_get(arg_config,
-                       "(qqyy)",
-                       &data->miu,
-                       &data->wks,
-                       &data->lto,
-                       &data->option);
+       g_variant_get(arg_config, "(qqyy)", &data->miu, &data->wks, &data->lto, &data->option);
 
        result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_config_thread_func,
-                       data);
-       if (result == FALSE)
+                       llcp_handle_config_thread_func, data);
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1246,24 +979,25 @@ static gboolean llcp_handle_listen(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpListenData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                       "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpListenData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.AllocationError",
                                "Can not allocate memory");
@@ -1281,10 +1015,10 @@ static gboolean llcp_handle_listen(NetNfcGDbusLlcp *llcp,
        data->sap = arg_sap;
        data->service_name = g_strdup(arg_service_name);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_listen_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_listen_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1308,6 +1042,7 @@ static gboolean llcp_handle_accept(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpAcceptData *data;
 
@@ -1315,20 +1050,20 @@ static gboolean llcp_handle_accept(NetNfcGDbusLlcp *llcp,
                        g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                       "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpAcceptData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Llcp.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Llcp.MemoryError", "Out of memory");
 
                return FALSE;
        }
@@ -1338,10 +1073,10 @@ static gboolean llcp_handle_accept(NetNfcGDbusLlcp *llcp,
        data->handle = arg_handle;
        data->client_socket = arg_client_socket;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_accept_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_accept_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1363,27 +1098,27 @@ static gboolean llcp_handle_reject(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpAcceptData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                       "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpAcceptData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Llcp.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Llcp.MemoryError", "Out of memory");
 
                return FALSE;
        }
@@ -1393,10 +1128,10 @@ static gboolean llcp_handle_reject(NetNfcGDbusLlcp *llcp,
        data->handle = arg_handle;
        data->client_socket = arg_client_socket;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_reject_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_reject_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1422,27 +1157,27 @@ static gboolean llcp_handle_connect(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpConnectData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                       "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpConnectData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1456,10 +1191,10 @@ static gboolean llcp_handle_connect(NetNfcGDbusLlcp *llcp,
        data->type = arg_type;
        data->service_name = g_strdup(arg_service_name);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_connect_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_connect_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1487,27 +1222,27 @@ static gboolean llcp_handle_connect_sap(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpConnectSapData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                       "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpConnectSapData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1522,9 +1257,9 @@ static gboolean llcp_handle_connect_sap(NetNfcGDbusLlcp *llcp,
        data->sap = arg_sap;
 
        result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_connect_sap_thread_func,
-                       data);
-       if (result == FALSE)
+                       llcp_handle_connect_sap_thread_func, data);
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1547,27 +1282,27 @@ static gboolean llcp_handle_send(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpSendData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpSendData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1579,10 +1314,10 @@ static gboolean llcp_handle_send(NetNfcGDbusLlcp *llcp,
 
        net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_send_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_send_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1608,27 +1343,27 @@ static gboolean llcp_handle_send_to(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpSendToData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpSendToData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1641,10 +1376,10 @@ static gboolean llcp_handle_send_to(NetNfcGDbusLlcp *llcp,
 
        net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_send_to_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_send_to_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1669,27 +1404,28 @@ static gboolean llcp_handle_receive(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpReceiveData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "w");
+
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpReceiveData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1700,10 +1436,9 @@ static gboolean llcp_handle_receive(NetNfcGDbusLlcp *llcp,
        data->client_socket = arg_client_socket;
        data->req_length = arg_req_length;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_receive_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_receive_thread_func,
                        data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1726,27 +1461,28 @@ static gboolean llcp_handle_receive_from(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpReceiveData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
+
+       ret == net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "w");
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "w") == false) {
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpReceiveData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1758,9 +1494,8 @@ static gboolean llcp_handle_receive_from(NetNfcGDbusLlcp *llcp,
        data->req_length = arg_req_length;
 
        result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_receive_from_thread_func,
-                       data);
-       if (result == FALSE)
+                       llcp_handle_receive_from_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1782,27 +1517,27 @@ static gboolean llcp_handle_close(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpCloseData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
+       ret == net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "w");
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "w") == false) {
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpCloseData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1812,10 +1547,10 @@ static gboolean llcp_handle_close(NetNfcGDbusLlcp *llcp,
        data->handle = arg_handle;
        data->client_socket = arg_client_socket;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_close_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_close_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1837,27 +1572,27 @@ static gboolean llcp_handle_disconnect(NetNfcGDbusLlcp *llcp,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        LlcpDisconnectData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
+       ret == net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "w");
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "w") == false) {
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(LlcpDisconnectData, 1);
-       if (data == NULL) {
+       if (NULL == data)
+       {
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1867,10 +1602,10 @@ static gboolean llcp_handle_disconnect(NetNfcGDbusLlcp *llcp,
        data->handle = arg_handle;
        data->client_socket = arg_client_socket;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       llcp_handle_disconnect_thread_func,
+       result = net_nfc_server_controller_async_queue_push(llcp_handle_disconnect_thread_func,
                        data);
-       if (result == FALSE)
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Llcp.ThreadError",
@@ -1887,7 +1622,7 @@ static gboolean llcp_handle_disconnect(NetNfcGDbusLlcp *llcp,
 
 void net_nfc_server_llcp_deactivated(gpointer user_data)
 {
-       net_nfc_target_handle_s *handle = (net_nfc_target_handle_s *)user_data;
+       net_nfc_target_handle_s *handle = user_data;
 
        if (handle != NULL)
        {
@@ -1896,13 +1631,9 @@ void net_nfc_server_llcp_deactivated(gpointer user_data)
                if (net_nfc_controller_disconnect(handle, &result) == false)
                {
                        if (result != NET_NFC_NOT_CONNECTED)
-                       {
                                net_nfc_controller_exception_handler();
-                       }
                        else
-                       {
                                NFC_ERR("target was not connected.");
-                       }
                }
 
                net_nfc_server_set_state(NET_NFC_SERVER_IDLE);
@@ -1917,21 +1648,15 @@ void net_nfc_server_llcp_deactivated(gpointer user_data)
 }
 
 static void llcp_simple_socket_error_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+       LlcpSimpleData *simple_data = user_param;
 
        g_assert(simple_data != NULL);
 
        if (simple_data->error_callback)
        {
-               simple_data->error_callback(result,
-                               simple_data->handle,
-                               socket,
-                               data,
+               simple_data->error_callback(result, simple_data->handle, socket, data,
                                simple_data->user_data);
        }
 
@@ -1939,25 +1664,18 @@ static void llcp_simple_socket_error_cb(net_nfc_llcp_socket_t socket,
 }
 
 static void llcp_simple_listen_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+       LlcpSimpleData *simple_data = user_param;
 
        g_assert(simple_data != NULL);
 
-       if (result != NET_NFC_OK) {
+       if (result != NET_NFC_OK)
                NFC_ERR("listen socket failed, [%d]", result);
-       }
 
        if (simple_data->callback)
        {
-               simple_data->callback(result,
-                               simple_data->handle,
-                               socket,
-                               data,
+               simple_data->callback(result, simple_data->handle, socket, data,
                                simple_data->user_data);
        }
 
@@ -1965,25 +1683,18 @@ static void llcp_simple_listen_cb(net_nfc_llcp_socket_t socket,
 }
 
 static void llcp_simple_connect_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+       LlcpSimpleData *simple_data = user_param;
 
        g_assert(simple_data != NULL);
 
-       if (result != NET_NFC_OK) {
+       if (result != NET_NFC_OK)
                NFC_ERR("connect socket failed, [%d]", result);
-       }
 
        if (simple_data->callback)
        {
-               simple_data->callback(result,
-                               simple_data->handle,
-                               socket,
-                               data,
+               simple_data->callback(result, simple_data->handle, socket, data,
                                simple_data->user_data);
        }
 
@@ -1991,21 +1702,15 @@ static void llcp_simple_connect_cb(net_nfc_llcp_socket_t socket,
 }
 
 static void llcp_simple_send_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+       LlcpSimpleData *simple_data = user_param;
 
        g_assert(simple_data != NULL);
 
        if (simple_data->callback)
        {
-               simple_data->callback(result,
-                               simple_data->handle,
-                               socket,
-                               data,
+               simple_data->callback(result, simple_data->handle, socket, data,
                                simple_data->user_data);
        }
 
@@ -2013,21 +1718,15 @@ static void llcp_simple_send_cb(net_nfc_llcp_socket_t socket,
 }
 
 static void llcp_simple_receive_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
-       LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+       LlcpSimpleData *simple_data = user_param;
 
        g_assert(simple_data != NULL);
 
        if (simple_data->callback)
        {
-               simple_data->callback(result,
-                               simple_data->handle,
-                               socket,
-                               data,
+               simple_data->callback(result, simple_data->handle, socket, data,
                                simple_data->user_data);
        }
 
@@ -2045,72 +1744,43 @@ gboolean net_nfc_server_llcp_init(GDBusConnection *connection)
 
        llcp_skeleton = net_nfc_gdbus_llcp_skeleton_new();
 
-       g_signal_connect(llcp_skeleton,
-                       "handle-config",
-                       G_CALLBACK(llcp_handle_config),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-listen",
-                       G_CALLBACK(llcp_handle_listen),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-accept",
-                       G_CALLBACK(llcp_handle_accept),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-reject",
-                       G_CALLBACK(llcp_handle_reject),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-connect",
-                       G_CALLBACK(llcp_handle_connect),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-connect-sap",
-                       G_CALLBACK(llcp_handle_connect_sap),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-send",
-                       G_CALLBACK(llcp_handle_send),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-send-to",
-                       G_CALLBACK(llcp_handle_send_to),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-receive",
-                       G_CALLBACK(llcp_handle_receive),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-receive-from",
-                       G_CALLBACK(llcp_handle_receive_from),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-close",
-                       G_CALLBACK(llcp_handle_close),
-                       NULL);
-
-       g_signal_connect(llcp_skeleton,
-                       "handle-disconnect",
-                       G_CALLBACK(llcp_handle_disconnect),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(llcp_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/Llcp",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(llcp_skeleton, "handle-config",
+                       G_CALLBACK(llcp_handle_config), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-listen",
+                       G_CALLBACK(llcp_handle_listen), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-accept",
+                       G_CALLBACK(llcp_handle_accept), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-reject",
+                       G_CALLBACK(llcp_handle_reject), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-connect",
+                       G_CALLBACK(llcp_handle_connect), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-connect-sap",
+                       G_CALLBACK(llcp_handle_connect_sap), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-send", G_CALLBACK(llcp_handle_send), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-send-to",
+                       G_CALLBACK(llcp_handle_send_to), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-receive",
+                       G_CALLBACK(llcp_handle_receive), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-receive-from",
+                       G_CALLBACK(llcp_handle_receive_from), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-close", G_CALLBACK(llcp_handle_close), NULL);
+
+       g_signal_connect(llcp_skeleton, "handle-disconnect",
+                       G_CALLBACK(llcp_handle_disconnect), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(llcp_skeleton),
+                       connection, "/org/tizen/NetNfcService/Llcp", &error);
+       if (FALSE == result)
        {
                g_error_free(error);
 
@@ -2134,7 +1804,7 @@ net_nfc_error_e net_nfc_server_llcp_set_config(
 {
        net_nfc_error_e result;
 
-       if (config == NULL)
+       if (NULL == config)
        {
                net_nfc_controller_llcp_config(&llcp_config, &result);
                return result;
@@ -2173,17 +1843,16 @@ net_nfc_error_e net_nfc_server_llcp_simple_server(net_nfc_target_handle_s *handl
                net_nfc_server_llcp_callback error_callback,
                gpointer user_data)
 {
-       net_nfc_error_e result = NET_NFC_OK;
-       LlcpSimpleData *simple_data = NULL;
+       bool ret;
        net_nfc_llcp_socket_t socket = -1;
        net_nfc_llcp_config_info_s config;
+       net_nfc_error_e result = NET_NFC_OK;
+       LlcpSimpleData *simple_data = NULL;
 
-       if (handle == NULL)
+       if (NULL == handle)
                return NET_NFC_NULL_PARAMETER;
 
-       if (net_nfc_controller_llcp_get_remote_config(handle,
-                               &config,
-                               &result) == false)
+       if (net_nfc_controller_llcp_get_remote_config(handle, &config, &result) == false)
        {
                NFC_ERR("net_nfc_controller_llcp_get_remote_config failed [%d]", result);
 
@@ -2191,7 +1860,8 @@ net_nfc_error_e net_nfc_server_llcp_simple_server(net_nfc_target_handle_s *handl
        }
 
        simple_data = g_try_new0(LlcpSimpleData, 1);
-       if (simple_data == NULL) {
+       if (NULL == simple_data)
+       {
                NFC_ERR("g_try_new0 failed");
 
                result = NET_NFC_ALLOC_FAIL;
@@ -2206,13 +1876,15 @@ net_nfc_error_e net_nfc_server_llcp_simple_server(net_nfc_target_handle_s *handl
 
        simple_data->miu = MIN(config.miu, net_nfc_server_llcp_get_miu());
 
-       if (net_nfc_controller_llcp_create_socket(&socket,
+       ret = net_nfc_controller_llcp_create_socket(&socket,
                                NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED,
                                simple_data->miu,
                                1,
                                &result,
                                llcp_simple_socket_error_cb,
-                               simple_data) == false)
+                               simple_data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
 
@@ -2221,21 +1893,17 @@ net_nfc_error_e net_nfc_server_llcp_simple_server(net_nfc_target_handle_s *handl
 
        simple_data->socket = socket;
 
-       if (net_nfc_controller_llcp_bind(socket,
-                               sap,
-                               &result) == false)
+       if (net_nfc_controller_llcp_bind(socket, sap, &result) == false)
        {
                NFC_ERR("net_nfc_controller_llcp_bind failed [%d]", result);
 
                goto ERROR;
        }
 
-       if (net_nfc_controller_llcp_listen(handle,
-                               (uint8_t *)san,
-                               socket,
-                               &result,
-                               llcp_simple_listen_cb,
-                               simple_data) == false)
+       ret = net_nfc_controller_llcp_listen(handle, (uint8_t *)san, socket, &result,
+                               llcp_simple_listen_cb, simple_data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
 
@@ -2250,15 +1918,15 @@ net_nfc_error_e net_nfc_server_llcp_simple_server(net_nfc_target_handle_s *handl
        return result;
 
 ERROR :
-       if (socket != -1) {
+       if (socket != -1)
+       {
                net_nfc_error_e temp;
 
                net_nfc_controller_llcp_socket_close(socket, &temp);
        }
 
-       if (simple_data != NULL) {
+       if (simple_data != NULL)
                g_free(simple_data);
-       }
 
        return result;
 }
@@ -2271,17 +1939,16 @@ net_nfc_error_e net_nfc_server_llcp_simple_client(
                net_nfc_server_llcp_callback error_callback,
                gpointer user_data)
 {
+       bool ret;
        net_nfc_error_e result;
-       LlcpSimpleData *simple_data = NULL;
        net_nfc_llcp_socket_t socket = -1;
        net_nfc_llcp_config_info_s config;
+       LlcpSimpleData *simple_data = NULL;
 
-       if (handle == NULL)
+       if (NULL == handle)
                return NET_NFC_NULL_PARAMETER;
 
-       if (net_nfc_controller_llcp_get_remote_config(handle,
-                               &config,
-                               &result) == false)
+       if (net_nfc_controller_llcp_get_remote_config(handle, &config, &result) == false)
        {
                NFC_ERR("net_nfc_controller_llcp_get_remote_config failed [%d]", result);
 
@@ -2289,7 +1956,8 @@ net_nfc_error_e net_nfc_server_llcp_simple_client(
        }
 
        simple_data = g_try_new0(LlcpSimpleData, 1);
-       if (simple_data == NULL) {
+       if (NULL == simple_data)
+       {
                NFC_ERR("g_try_new0 failed");
 
                result = NET_NFC_ALLOC_FAIL;
@@ -2304,13 +1972,15 @@ net_nfc_error_e net_nfc_server_llcp_simple_client(
 
        simple_data->miu = MIN(config.miu, net_nfc_server_llcp_get_miu());
 
-       if (net_nfc_controller_llcp_create_socket(&socket,
+       ret = net_nfc_controller_llcp_create_socket(&socket,
                                NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED,
                                simple_data->miu,
                                1,
                                &result,
                                llcp_simple_socket_error_cb,
-                               simple_data) == false)
+                               simple_data);
+
+       if (false == ret)
        {
                NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
 
@@ -2319,14 +1989,11 @@ net_nfc_error_e net_nfc_server_llcp_simple_client(
 
        simple_data->socket = socket;
 
-       if (san == NULL)
+       if (NULL == san)
        {
-               if (net_nfc_controller_llcp_connect(handle,
-                                       simple_data->socket,
-                                       sap,
-                                       &result,
-                                       llcp_simple_connect_cb,
-                                       simple_data) == false)
+               ret = net_nfc_controller_llcp_connect(handle, simple_data->socket, sap,
+                                       &result, llcp_simple_connect_cb, simple_data);
+               if (false == ret)
                {
                        NFC_ERR("net_nfc_controller_llcp_connect failed [%d]", result);
 
@@ -2335,12 +2002,9 @@ net_nfc_error_e net_nfc_server_llcp_simple_client(
        }
        else
        {
-               if (net_nfc_controller_llcp_connect_by_url(handle,
-                                       simple_data->socket,
-                                       (uint8_t *)san,
-                                       &result,
-                                       llcp_simple_connect_cb,
-                                       simple_data) == false)
+               ret = net_nfc_controller_llcp_connect_by_url(handle, simple_data->socket,
+                                       (uint8_t *)san, &result, llcp_simple_connect_cb, simple_data);
+               if (false == ret)
                {
                        NFC_ERR("net_nfc_controller_llcp_connect_by_url failed [%d]", result);
 
@@ -2356,15 +2020,15 @@ net_nfc_error_e net_nfc_server_llcp_simple_client(
        return result;
 
 ERROR :
-       if (socket != -1) {
+       if (socket != -1)
+       {
                net_nfc_error_e temp;
 
                net_nfc_controller_llcp_socket_close(socket, &temp);
        }
 
-       if (simple_data != NULL) {
+       if (simple_data != NULL)
                g_free(simple_data);
-       }
 
        return result;
 }
@@ -2375,24 +2039,25 @@ net_nfc_error_e net_nfc_server_llcp_simple_accept(
                net_nfc_server_llcp_callback error_callback,
                gpointer user_data)
 {
+       bool ret;
        net_nfc_error_e result;
        LlcpSimpleData *simple_data;
 
        simple_data = g_try_new0(LlcpSimpleData, 1);
-       if (simple_data != NULL) {
+       if (simple_data != NULL)
+       {
                simple_data->handle = handle;
                simple_data->socket = socket;
                simple_data->error_callback = error_callback;
                simple_data->user_data = user_data;
 
-               if (net_nfc_controller_llcp_accept(socket,
-                                       &result,
-                                       llcp_simple_socket_error_cb,
-                                       simple_data) == false)
-               {
+               ret = net_nfc_controller_llcp_accept(socket, &result,
+                                       llcp_simple_socket_error_cb, simple_data);
+               if (false == ret)
                        NFC_ERR("net_nfc_controller_llcp_accept failed [%d]", result);
-               }
-       } else {
+       }
+       else
+       {
                NFC_ERR("g_try_new0 failed");
 
                result = NET_NFC_ALLOC_FAIL;
@@ -2411,33 +2076,32 @@ net_nfc_error_e net_nfc_server_llcp_simple_send(
                net_nfc_server_llcp_callback callback,
                gpointer user_data)
 {
+       bool ret;
        net_nfc_error_e result;
        LlcpSimpleData *simple_data;
 
        simple_data = g_try_new0(LlcpSimpleData, 1);
-       if (simple_data != NULL) {
+       if (simple_data != NULL)
+       {
                simple_data->handle = handle;
                simple_data->socket = socket;
                simple_data->callback = callback;
                simple_data->user_data = user_data;
 
-               if (net_nfc_controller_llcp_send(handle,
-                                       socket,
-                                       data,
-                                       &result,
-                                       llcp_simple_send_cb,
-                                       simple_data) == false)
-               {
-                       NFC_ERR("net_nfc_controller_llcp_send failed [%d]",
-                                       result);
-               }
-       } else {
+               ret = net_nfc_controller_llcp_send(handle, socket, data, &result,
+                                       llcp_simple_send_cb, simple_data);
+
+               if (false == ret)
+                       NFC_ERR("net_nfc_controller_llcp_send failed [%d]", result);
+       }
+       else
+       {
                NFC_ERR("g_try_new0 failed");
 
                result = NET_NFC_ALLOC_FAIL;
        }
 
-       if (result == NET_NFC_BUSY)
+       if (NET_NFC_BUSY == result)
                result = NET_NFC_OK;
 
        return result;
@@ -2449,34 +2113,35 @@ net_nfc_error_e net_nfc_server_llcp_simple_receive(
                net_nfc_server_llcp_callback callback,
                gpointer user_data)
 {
+       bool ret;
        net_nfc_error_e result;
        LlcpSimpleData *simple_data;
 
        simple_data = g_try_new0(LlcpSimpleData, 1);
-       if (simple_data != NULL) {
+       if (simple_data != NULL)
+       {
                simple_data->handle = handle;
                simple_data->socket = socket;
                simple_data->callback = callback;
                simple_data->user_data = user_data;
 
-               if (net_nfc_controller_llcp_recv(handle,
-                                       socket,
-                                       net_nfc_server_llcp_get_miu(),
-                                       &result,
-                                       llcp_simple_receive_cb,
-                                       simple_data) == false)
+               ret = net_nfc_controller_llcp_recv(handle, socket, net_nfc_server_llcp_get_miu(),
+                                       &result, llcp_simple_receive_cb, simple_data);
+               if (false == ret)
                {
                        NFC_ERR("net_nfc_controller_llcp_recv failed [%d]", result);
 
                        g_free(simple_data);
                }
-       } else {
+       }
+       else
+       {
                NFC_ERR("g_try_new0 failed");
 
                result = NET_NFC_ALLOC_FAIL;
        }
 
-       if (result == NET_NFC_BUSY)
+       if (NET_NFC_BUSY == result)
                result = NET_NFC_OK;
 
        return result;
@@ -2496,50 +2161,48 @@ static GHashTable *service_table;
 
 static void _llcp_init()
 {
-       if (service_table == NULL)
+       if (NULL == service_table)
                service_table = g_hash_table_new(NULL, NULL);
 }
 
 inline static service_t *_llcp_find_service(uint32_t sap)
 {
-       return (service_t *)g_hash_table_lookup(service_table,
-                       (gconstpointer)sap);
+       return (service_t *)g_hash_table_lookup(service_table, (gconstpointer)sap);
 }
 
 static net_nfc_error_e _llcp_add_service(const char *id, uint32_t sap,
                const char *san, net_nfc_server_llcp_activate_cb cb, void *user_data)
 {
-       service_t *service = NULL;
        net_nfc_error_e result;
+       service_t *service = NULL;
 
-       if (cb == NULL) {
-               NFC_ERR("callback is mandatory");
-
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == cb, NET_NFC_NULL_PARAMETER);
 
        _llcp_init();
 
-       if (_llcp_find_service(sap) == NULL) {
+       if (_llcp_find_service(sap) == NULL)
+       {
                NFC_DBG("new service, sap [%d]", sap);
 
                service = g_try_new0(service_t, 1);
-               if (service != NULL) {
+               if (service != NULL)
+               {
                        service->sap = sap;
-                       if (san != NULL && strlen(san) > 0) {
+                       if (san != NULL && strlen(san) > 0)
                                service->san = g_strdup(san);
-                       }
-                       if (id != NULL && strlen(id) > 0) {
+
+                       if (id != NULL && strlen(id) > 0)
                                service->id = g_strdup(id);
-                       }
+
                        service->cb = cb;
                        service->user_data = user_data;
 
-                       g_hash_table_insert(service_table, (gpointer)sap,
-                                       (gpointer)service);
+                       g_hash_table_insert(service_table, (gpointer)sap, (gpointer)service);
 
                        result = NET_NFC_OK;
-               } else {
+               }
+               else
+               {
                        NFC_ERR("alloc failed");
 
                        result = NET_NFC_ALLOC_FAIL;
@@ -2558,7 +2221,8 @@ static void _llcp_remove_service(uint32_t sap)
        service_t *service = NULL;
 
        service = _llcp_find_service(sap);
-       if (service != NULL) {
+       if (service != NULL)
+       {
                g_free(service->san);
                g_free(service->id);
                g_free(service);
@@ -2569,17 +2233,19 @@ static void _llcp_remove_service(uint32_t sap)
 
 static void _llcp_remove_services(const char *id)
 {
-       GHashTableIter iter;
        gpointer key;
        service_t *service;
+       GHashTableIter iter;
 
-       if (service_table == NULL)
+       if (NULL == service_table)
                return;
 
        g_hash_table_iter_init (&iter, service_table);
 
-       while (g_hash_table_iter_next (&iter, &key, (gpointer)&service)) {
-               if (id == NULL || strcmp(service->id, id) == 0) {
+       while (g_hash_table_iter_next (&iter, &key, (gpointer)&service))
+       {
+               if (id == NULL || strcmp(service->id, id) == 0)
+               {
                        g_free(service->san);
                        g_free(service->id);
                        g_free(service);
@@ -2616,11 +2282,12 @@ net_nfc_error_e net_nfc_server_llcp_register_service(const char *id, sap_t sap,
 net_nfc_error_e net_nfc_server_llcp_unregister_service(const char *id,
                sap_t sap, const char *san)
 {
-       net_nfc_error_e result;
        service_t *service;
+       net_nfc_error_e result;
 
        service = _llcp_find_service(sap);
-       if (service != NULL) {
+       if (service != NULL)
+       {
                /* invoke callback */
                service->cb(NET_NFC_LLCP_UNREGISTERED, NULL, service->sap,
                                service->san, service->user_data);
@@ -2628,7 +2295,9 @@ net_nfc_error_e net_nfc_server_llcp_unregister_service(const char *id,
                _llcp_remove_service(sap);
 
                result = NET_NFC_OK;
-       } else {
+       }
+       else
+       {
                NFC_ERR("service is not registered");
 
                result = NET_NFC_NOT_REGISTERED;
@@ -2646,16 +2315,17 @@ net_nfc_error_e net_nfc_server_llcp_unregister_services(const char *id)
 
 net_nfc_error_e net_nfc_server_llcp_unregister_all()
 {
-       GHashTableIter iter;
        gpointer key;
        service_t *service;
+       GHashTableIter iter;
 
-       if (service_table == NULL)
+       if (NULL == service_table)
                return NET_NFC_OK;
 
        g_hash_table_iter_init(&iter, service_table);
 
-       while (g_hash_table_iter_next(&iter, &key, (gpointer)&service)) {
+       while (g_hash_table_iter_next(&iter, &key, (gpointer)&service))
+       {
                service->cb(NET_NFC_LLCP_UNREGISTERED, NULL, service->sap,
                                service->san, service->user_data);
 
@@ -2679,12 +2349,13 @@ net_nfc_error_e net_nfc_server_llcp_start_registered_services(
 
 static void net_nfc_server_llcp_process(gpointer user_data)
 {
+       bool ret;
+       net_nfc_target_handle_s *handle;
        net_nfc_current_target_info_s *target;
 #if 0
        net_nfc_error_e result;
        net_nfc_target_type_e dev_type;
 #endif
-       net_nfc_target_handle_s *handle;
 
        target = net_nfc_server_get_target_info();
 
@@ -2696,7 +2367,7 @@ static void net_nfc_server_llcp_process(gpointer user_data)
 #if 0
        dev_type = target->devType;
 
-       if (dev_type == NET_NFC_NFCIP1_TARGET)
+       if (NET_NFC_NFCIP1_TARGET == dev_type)
        {
                NFC_DBG("LLCP : target, try to connect");
 
@@ -2704,10 +2375,9 @@ static void net_nfc_server_llcp_process(gpointer user_data)
                {
                        NFC_ERR("net_nfc_controller_connect is failed, [%d]", result);
 
-                       if (net_nfc_controller_configure_discovery(
-                                               NET_NFC_DISCOVERY_MODE_RESUME,
-                                               NET_NFC_ALL_ENABLE,
-                                               &result) == false)
+                       ret = net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+                                               NET_NFC_ALL_ENABLE, &result);
+                       if (false == ret)
                        {
                                NFC_ERR("net_nfc_controller_configure_discovery is failed [%d]", result);
                                net_nfc_controller_exception_handler();
@@ -2729,9 +2399,7 @@ static void net_nfc_server_llcp_process(gpointer user_data)
 
        if (net_nfc_controller_llcp_activate_llcp(handle, &result) == false)
        {
-               NFC_ERR("%s is failed [%d]",
-                               "net_nfc_controller_llcp_activate_llcp",
-                               result);
+               NFC_ERR("%s is failed [%d]", "net_nfc_controller_llcp_activate_llcp", result);
 
                return;
        }
@@ -2743,9 +2411,12 @@ static void net_nfc_server_llcp_process(gpointer user_data)
 
 void net_nfc_server_llcp_target_detected(void *info)
 {
-       if (net_nfc_server_controller_async_queue_push(
-                               net_nfc_server_llcp_process, NULL) == FALSE)
-       {
+       gboolean ret;
+
+       ret = net_nfc_server_controller_async_queue_push(
+                               net_nfc_server_llcp_process, NULL);
+
+       if (FALSE == ret)
                NFC_ERR("can not push to controller thread");
-       }
+
 }
index 9dd3566..474aa84 100644 (file)
@@ -43,33 +43,13 @@ struct _ManagerActivationData
 
 static NetNfcGDbusManager *manager_skeleton = NULL;
 
-static net_nfc_error_e manager_active(void);
-
-static net_nfc_error_e manager_deactive(void);
-
-static void manager_handle_active_thread_func(gpointer user_data);
-
-static gboolean manager_handle_set_active(NetNfcGDbusManager *manager,
-               GDBusMethodInvocation *invocation,
-               gboolean arg_is_active,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean manager_handle_get_server_state(NetNfcGDbusManager *manager,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-
-static void manager_active_thread_func(gpointer user_data);
-
 
 /* reimplementation of net_nfc_service_init()*/
 static net_nfc_error_e manager_active(void)
 {
-       net_nfc_error_e result;
        int ret;
        int se_type;
+       net_nfc_error_e result;
 
        if (net_nfc_controller_is_ready(&result) == false)
        {
@@ -80,9 +60,9 @@ static net_nfc_error_e manager_active(void)
 
        /* keep_SE_select_value */
        ret = vconf_get_int(VCONFKEY_NFC_SE_TYPE, &se_type);
-       if (ret == 0)
+       if (0 == ret)
        {
-               NFC_DBG("manager_active  se_type [%d]",se_type);
+               NFC_DBG("manager_active se_type [%d]",se_type);
                result = net_nfc_server_se_change_se(se_type);
        }
 
@@ -95,10 +75,8 @@ static net_nfc_error_e manager_active(void)
        /* register default handover server */
        net_nfc_server_handover_default_server_register();
 
-       if (net_nfc_controller_configure_discovery(
-                               NET_NFC_DISCOVERY_MODE_START,
-                               NET_NFC_ALL_ENABLE,
-                               &result) == TRUE)
+       if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_START,
+                               NET_NFC_ALL_ENABLE, &result) == TRUE)
        {
                /* vconf on */
                if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
@@ -119,6 +97,7 @@ static net_nfc_error_e manager_active(void)
 /* reimplementation of net_nfc_service_deinit()*/
 static net_nfc_error_e manager_deactive(void)
 {
+       bool ret;
        net_nfc_error_e result;
 
        if (net_nfc_controller_is_ready(&result) == false)
@@ -134,10 +113,10 @@ static net_nfc_error_e manager_deactive(void)
        /* keep_SE_select_value do not need to update vconf and gdbus_se_setting */
        result = net_nfc_server_se_disable_card_emulation();
 
-       if (net_nfc_controller_configure_discovery(
-                               NET_NFC_DISCOVERY_MODE_STOP,
-                               NET_NFC_ALL_DISABLE,
-                               &result) == TRUE)
+       ret = net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_STOP,
+                               NET_NFC_ALL_DISABLE, &result);
+
+       if (TRUE == ret)
        {
                /* vconf off */
                if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
@@ -157,8 +136,8 @@ static net_nfc_error_e manager_deactive(void)
 
 static void manager_handle_active_thread_func(gpointer user_data)
 {
-       ManagerActivationData *data = (ManagerActivationData *)user_data;
        net_nfc_error_e result;
+       ManagerActivationData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->manager != NULL);
@@ -169,17 +148,16 @@ static void manager_handle_active_thread_func(gpointer user_data)
        else
                result = manager_deactive();
 
-       net_nfc_gdbus_manager_complete_set_active(data->manager,
-                       data->invocation,
-                       result);
+       net_nfc_gdbus_manager_complete_set_active(data->manager, data->invocation, result);
 
-       if (result == NET_NFC_OK) {
-               NFC_INFO("nfc %s", data->is_active ?
-                               "activated" : "deactivated");
+       if (NET_NFC_OK == result)
+       {
+               NFC_INFO("nfc %s", data->is_active ? "activated" : "deactivated");
 
-               net_nfc_gdbus_manager_emit_activated(data->manager,
-                               data->is_active);
-       } else {
+               net_nfc_gdbus_manager_emit_activated(data->manager, data->is_active);
+       }
+       else
+       {
                NFC_ERR("activation change failed, [%d]", result);
        }
 
@@ -189,11 +167,8 @@ static void manager_handle_active_thread_func(gpointer user_data)
        g_free(data);
 
        /* shutdown process if it doesn't need */
-       if (data->is_active == false &&
-                       net_nfc_server_gdbus_is_server_busy() == false) {
-
+       if (data->is_active == false && net_nfc_server_gdbus_is_server_busy() == false)
                net_nfc_server_controller_deinit();
-       }
 }
 
 
@@ -203,17 +178,17 @@ static gboolean manager_handle_set_active(NetNfcGDbusManager *manager,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       ManagerActivationData *data;
+       bool ret;
        gboolean result;
+       ManagerActivationData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::admin",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                                       "nfc-manager::admin", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
@@ -222,12 +197,11 @@ static gboolean manager_handle_set_active(NetNfcGDbusManager *manager,
        NFC_DBG("is_active %d", arg_is_active);
 
        data = g_try_new0(ManagerActivationData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
                return FALSE;
        }
 
@@ -237,7 +211,7 @@ static gboolean manager_handle_set_active(NetNfcGDbusManager *manager,
 
        result = net_nfc_server_controller_async_queue_push(
                        manager_handle_active_thread_func, data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.ThreadError",
@@ -253,20 +227,18 @@ static gboolean manager_handle_set_active(NetNfcGDbusManager *manager,
 }
 
 static gboolean manager_handle_get_server_state(NetNfcGDbusManager *manager,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data)
+               GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
 {
+       bool ret;
        guint32 state;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::admin",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::admin", "r");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
@@ -274,19 +246,17 @@ static gboolean manager_handle_get_server_state(NetNfcGDbusManager *manager,
 
        state = net_nfc_server_get_state();
 
-       net_nfc_gdbus_manager_complete_get_server_state(manager,
-                       invocation,
-                       NET_NFC_OK,
+       net_nfc_gdbus_manager_complete_get_server_state(manager, invocation, NET_NFC_OK,
                        state);
+
        return TRUE;
 }
 
 /* server side */
 static void manager_active_thread_func(gpointer user_data)
 {
-       ManagerActivationData *data =
-               (ManagerActivationData *)user_data;
        net_nfc_error_e ret;
+       ManagerActivationData *data = user_data;
 
        g_assert(data != NULL);
 
@@ -294,10 +264,10 @@ static void manager_active_thread_func(gpointer user_data)
                ret = manager_active();
        else
                ret = manager_deactive();
-       if (ret == NET_NFC_OK)
+
+       if (NET_NFC_OK == ret)
        {
-               NFC_INFO("nfc %s",
-                               data->is_active ? "activated" : "deactivated");
+               NFC_INFO("nfc %s", data->is_active ? "activated" : "deactivated");
 
                net_nfc_gdbus_manager_emit_activated(data->manager, data->is_active);
        }
@@ -311,6 +281,7 @@ static void manager_active_thread_func(gpointer user_data)
 
 gboolean net_nfc_server_manager_init(GDBusConnection *connection)
 {
+       gboolean ret;
        GError *error = NULL;
 
        if (manager_skeleton)
@@ -318,21 +289,19 @@ gboolean net_nfc_server_manager_init(GDBusConnection *connection)
 
        manager_skeleton = net_nfc_gdbus_manager_skeleton_new();
 
-       g_signal_connect(manager_skeleton,
-                       "handle-set-active",
-                       G_CALLBACK(manager_handle_set_active),
-                       NULL);
+       g_signal_connect(manager_skeleton, "handle-set-active",
+                       G_CALLBACK(manager_handle_set_active), NULL);
 
-       g_signal_connect(manager_skeleton,
-                       "handle-get-server-state",
-                       G_CALLBACK(manager_handle_get_server_state),
-                       NULL);
+       g_signal_connect(manager_skeleton, "handle-get-server-state",
+                       G_CALLBACK(manager_handle_get_server_state), NULL);
 
-       if (g_dbus_interface_skeleton_export(
+       ret = g_dbus_interface_skeleton_export(
                                G_DBUS_INTERFACE_SKELETON(manager_skeleton),
                                connection,
                                "/org/tizen/NetNfcService/Manager",
-                               &error) == FALSE)
+                               &error);
+
+       if (FALSE == ret)
        {
                NFC_ERR("Can not skeleton_export %s", error->message);
 
@@ -357,9 +326,10 @@ void net_nfc_server_manager_deinit(void)
 
 void net_nfc_server_manager_set_active(gboolean is_active)
 {
+       bool ret;
        ManagerActivationData *data;
 
-       if (manager_skeleton == NULL)
+       if (NULL == manager_skeleton)
        {
                NFC_ERR("net_nfc_server_manager is not initialized");
 
@@ -369,7 +339,7 @@ void net_nfc_server_manager_set_active(gboolean is_active)
        NFC_DBG("is_active %d", is_active);
 
        data = g_try_new0(ManagerActivationData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
 
@@ -379,9 +349,8 @@ void net_nfc_server_manager_set_active(gboolean is_active)
        data->manager = g_object_ref(manager_skeleton);
        data->is_active = is_active;
 
-       if (net_nfc_server_controller_async_queue_push(
-                               manager_active_thread_func,
-                               data) == FALSE)
+       ret = net_nfc_server_controller_async_queue_push(manager_active_thread_func, data);
+       if (FALSE == ret)
        {
                NFC_ERR("can not push to controller thread");
 
index e2252e9..d6ba1cb 100644 (file)
@@ -67,50 +67,14 @@ struct _FormatData
 
 static NetNfcGDbusNdef *ndef_skeleton = NULL;
 
-static void ndef_read_thread_func(gpointer user_data);
-
-static void ndef_write_thread_func(gpointer user_data);
-
-static void ndef_make_read_only_thread_func(gpointer user_data);
-
-static void ndef_format_thread_func(gpointer user_data);
-
-/* methods */
-static gboolean ndef_handle_read(NetNfcGDbusNdef *ndef,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean ndef_handle_write(NetNfcGDbusNdef *ndef,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               GVariant *arg_data,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean ndef_handle_make_read_only(NetNfcGDbusNdef *ndef,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean ndef_handle_format(NetNfcGDbusNdef *ndef,
-               GDBusMethodInvocation *invocation,
-               guint32 arg_handle,
-               GVariant *arg_key,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
 
 static void ndef_read_thread_func(gpointer user_data)
 {
-       ReadData *data = user_data;
-
-       net_nfc_target_handle_s *handle;
        net_nfc_error_e result;
-       data_s *read_data = NULL;
        GVariant *data_variant;
+       data_s *read_data = NULL;
+       ReadData *data = user_data;
+       net_nfc_target_handle_s *handle;
 
        g_assert(data != NULL);
        g_assert(data->ndef != NULL);
@@ -118,20 +82,18 @@ static void ndef_read_thread_func(gpointer user_data)
 
        handle = GUINT_TO_POINTER(data->handle);
 
-       if (net_nfc_server_target_connected(handle) == true) {
+       if (net_nfc_server_target_connected(handle) == true)
                net_nfc_controller_read_ndef(handle, &read_data, &result);
-       } else {
+       else
                result = NET_NFC_TARGET_IS_MOVED_AWAY;
-       }
 
        data_variant = net_nfc_util_gdbus_data_to_variant(read_data);
 
-       net_nfc_gdbus_ndef_complete_read(data->ndef,
-                       data->invocation,
-                       (gint)result,
+       net_nfc_gdbus_ndef_complete_read(data->ndef, data->invocation, (gint)result,
                        data_variant);
 
-       if (read_data) {
+       if (read_data)
+       {
                net_nfc_util_free_data(read_data);
                g_free(read_data);
        }
@@ -144,10 +106,9 @@ static void ndef_read_thread_func(gpointer user_data)
 
 static void ndef_write_thread_func(gpointer user_data)
 {
+       net_nfc_error_e result;
        WriteData *data = user_data;
-
        net_nfc_target_handle_s *handle;
-       net_nfc_error_e result;
 
        g_assert(data != NULL);
        g_assert(data->ndef != NULL);
@@ -155,15 +116,12 @@ static void ndef_write_thread_func(gpointer user_data)
 
        handle = GUINT_TO_POINTER(data->handle);
 
-       if (net_nfc_server_target_connected(handle) == true) {
+       if (net_nfc_server_target_connected(handle) == true)
                net_nfc_controller_write_ndef(handle, &data->data, &result);
-       } else {
+       else
                result = NET_NFC_TARGET_IS_MOVED_AWAY;
-       }
 
-       net_nfc_gdbus_ndef_complete_write(data->ndef,
-                       data->invocation,
-                       (gint)result);
+       net_nfc_gdbus_ndef_complete_write(data->ndef, data->invocation, (gint)result);
 
        net_nfc_util_free_data(&data->data);
 
@@ -175,10 +133,9 @@ static void ndef_write_thread_func(gpointer user_data)
 
 static void ndef_make_read_only_thread_func(gpointer user_data)
 {
-       MakeReadOnlyData *data = user_data;
-
-       net_nfc_target_handle_s *handle;
        net_nfc_error_e result;
+       net_nfc_target_handle_s *handle;
+       MakeReadOnlyData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->ndef != NULL);
@@ -186,15 +143,12 @@ static void ndef_make_read_only_thread_func(gpointer user_data)
 
        handle = GUINT_TO_POINTER(data->handle);
 
-       if (net_nfc_server_target_connected(handle) == true) {
+       if (net_nfc_server_target_connected(handle) == true)
                net_nfc_controller_make_read_only_ndef(handle, &result);
-       } else {
+       else
                result = NET_NFC_TARGET_IS_MOVED_AWAY;
-       }
 
-       net_nfc_gdbus_ndef_complete_make_read_only(data->ndef,
-                       data->invocation,
-                       (gint)result);
+       net_nfc_gdbus_ndef_complete_make_read_only(data->ndef, data->invocation, (gint)result);
 
        g_object_unref(data->invocation);
        g_object_unref(data->ndef);
@@ -204,10 +158,9 @@ static void ndef_make_read_only_thread_func(gpointer user_data)
 
 static void ndef_format_thread_func(gpointer user_data)
 {
+       net_nfc_error_e result;
        FormatData *data = user_data;
-
        net_nfc_target_handle_s *handle;
-       net_nfc_error_e result;
 
        g_assert(data != NULL);
        g_assert(data->ndef != NULL);
@@ -215,15 +168,12 @@ static void ndef_format_thread_func(gpointer user_data)
 
        handle = GUINT_TO_POINTER(data->handle);
 
-       if (net_nfc_server_target_connected(handle) == true) {
+       if (net_nfc_server_target_connected(handle) == true)
                net_nfc_controller_format_ndef(handle, &data->key, &result);
-       } else {
+       else
                result = NET_NFC_TARGET_IS_MOVED_AWAY;
-       }
 
-       net_nfc_gdbus_ndef_complete_format(data->ndef,
-                       data->invocation,
-                       (gint)result);
+       net_nfc_gdbus_ndef_complete_format(data->ndef, data->invocation, (gint)result);
 
        net_nfc_util_free_data(&data->key);
 
@@ -239,29 +189,28 @@ static gboolean ndef_handle_read(NetNfcGDbusNdef *ndef,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        ReadData *data;
        gboolean result;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::tag",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::tag", "r");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_new0(ReadData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -270,10 +219,8 @@ static gboolean ndef_handle_read(NetNfcGDbusNdef *ndef,
        data->invocation = g_object_ref(invocation);
        data->handle = arg_handle;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       ndef_read_thread_func,
-                       data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(ndef_read_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Ndef.ThreadError",
@@ -295,29 +242,29 @@ static gboolean ndef_handle_write(NetNfcGDbusNdef *ndef,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        WriteData *data;
        gboolean result;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::tag",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                       "nfc-manager::tag", "w");
+
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_new0(WriteData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -328,10 +275,8 @@ static gboolean ndef_handle_write(NetNfcGDbusNdef *ndef,
 
        net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       ndef_write_thread_func,
-                       data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(ndef_write_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Ndef.ThreadError",
@@ -354,29 +299,28 @@ static gboolean ndef_handle_make_read_only(NetNfcGDbusNdef *ndef,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       MakeReadOnlyData *data;
+       bool ret;
        gboolean result;
+       MakeReadOnlyData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::tag",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::tag", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_new0(MakeReadOnlyData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -385,10 +329,9 @@ static gboolean ndef_handle_make_read_only(NetNfcGDbusNdef *ndef,
        data->invocation = g_object_ref(invocation);
        data->handle = arg_handle;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       ndef_make_read_only_thread_func,
+       result = net_nfc_server_controller_async_queue_push(ndef_make_read_only_thread_func,
                        data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Ndef.ThreadError",
@@ -410,29 +353,28 @@ static gboolean ndef_handle_format(NetNfcGDbusNdef *ndef,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       FormatData *data;
+       bool ret;
        gboolean result;
+       FormatData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::tag",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::tag", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_new0(FormatData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -442,10 +384,8 @@ static gboolean ndef_handle_format(NetNfcGDbusNdef *ndef,
        data->handle = arg_handle;
        net_nfc_util_gdbus_variant_to_data_s(arg_key, &data->key);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       ndef_format_thread_func,
-                       data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(ndef_format_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Ndef.ThreadError",
@@ -472,32 +412,19 @@ gboolean net_nfc_server_ndef_init(GDBusConnection *connection)
 
        ndef_skeleton = net_nfc_gdbus_ndef_skeleton_new();
 
-       g_signal_connect(ndef_skeleton,
-                       "handle-read",
-                       G_CALLBACK(ndef_handle_read),
-                       NULL);
-
-       g_signal_connect(ndef_skeleton,
-                       "handle-write",
-                       G_CALLBACK(ndef_handle_write),
-                       NULL);
-
-       g_signal_connect(ndef_skeleton,
-                       "handle-make-read-only",
-                       G_CALLBACK(ndef_handle_make_read_only),
-                       NULL);
-
-       g_signal_connect(ndef_skeleton,
-                       "handle-format",
-                       G_CALLBACK(ndef_handle_format),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(ndef_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/Ndef",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(ndef_skeleton, "handle-read", G_CALLBACK(ndef_handle_read), NULL);
+
+       g_signal_connect(ndef_skeleton, "handle-write", G_CALLBACK(ndef_handle_write), NULL);
+
+       g_signal_connect(ndef_skeleton, "handle-make-read-only",
+                       G_CALLBACK(ndef_handle_make_read_only), NULL);
+
+       g_signal_connect(ndef_skeleton, "handle-format",
+                       G_CALLBACK(ndef_handle_format), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(ndef_skeleton),
+                       connection, "/org/tizen/NetNfcService/Ndef", &error);
+       if (FALSE == result)
        {
                g_error_free(error);
 
index 758b2ed..3336e03 100644 (file)
@@ -37,23 +37,13 @@ struct _P2pSendData
        data_s data;
 };
 
-static void p2p_send_data_thread_func(gpointer user_data);
-
-static gboolean p2p_handle_send(NetNfcGDbusP2p *p2p,
-               GDBusMethodInvocation *invocation,
-               gint32 arg_type,
-               GVariant *arg_data,
-               guint32 handle,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
 static NetNfcGDbusP2p *p2p_skeleton = NULL;
 
 static void p2p_send_data_thread_func(gpointer user_data)
 {
-       P2pSendData *p2p_data = (P2pSendData *)user_data;
        net_nfc_error_e result;
        net_nfc_target_handle_s *handle;
+       P2pSendData *p2p_data = user_data;
 
        g_assert(p2p_data != NULL);
        g_assert(p2p_data->p2p != NULL);
@@ -65,9 +55,7 @@ static void p2p_send_data_thread_func(gpointer user_data)
                        &p2p_data->data, -1, p2p_data);
        if (result != NET_NFC_OK)
        {
-               net_nfc_gdbus_p2p_complete_send(p2p_data->p2p,
-                               p2p_data->invocation,
-                               (gint)result);
+               net_nfc_gdbus_p2p_complete_send(p2p_data->p2p, p2p_data->invocation, (gint)result);
 
                net_nfc_util_free_data(&p2p_data->data);
 
@@ -86,29 +74,28 @@ static gboolean p2p_handle_send(NetNfcGDbusP2p *p2p,
                GVariant *smack_privilege,
                gpointer user_data)
 {
+       bool ret;
        gboolean result;
        P2pSendData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_new0(P2pSendData, 1);
-       if(data == NULL)
+       if(NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -119,9 +106,9 @@ static gboolean p2p_handle_send(NetNfcGDbusP2p *p2p,
        data->p2p_handle = handle;
        net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       p2p_send_data_thread_func, data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(p2p_send_data_thread_func, data);
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.P2p.ThreadError",
@@ -149,17 +136,11 @@ gboolean net_nfc_server_p2p_init(GDBusConnection *connection)
 
        p2p_skeleton = net_nfc_gdbus_p2p_skeleton_new();
 
-       g_signal_connect(p2p_skeleton,
-                       "handle-send",
-                       G_CALLBACK(p2p_handle_send),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(p2p_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/P2p",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(p2p_skeleton, "handle-send", G_CALLBACK(p2p_handle_send), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(p2p_skeleton),
+                       connection, "/org/tizen/NetNfcService/P2p", &error);
+       if (FALSE == result)
        {
                g_error_free(error);
 
@@ -186,31 +167,28 @@ void net_nfc_server_p2p_detached(void)
        net_nfc_server_free_target_info();
 
        if (p2p_skeleton != NULL)
-       {
                net_nfc_gdbus_p2p_emit_detached(p2p_skeleton);
-       }
 }
 
 void net_nfc_server_p2p_discovered(net_nfc_target_handle_s *handle)
 {
        NFC_INFO("====== p2p target discovered ======");
 
-       if (p2p_skeleton == NULL)
+       if (NULL == p2p_skeleton)
        {
                NFC_ERR("p2p_skeleton is not initialized");
 
                return;
        }
 
-       net_nfc_gdbus_p2p_emit_discovered(p2p_skeleton,
-                       GPOINTER_TO_UINT(handle));
+       net_nfc_gdbus_p2p_emit_discovered(p2p_skeleton, GPOINTER_TO_UINT(handle));
 }
 
 void net_nfc_server_p2p_received(data_s *user_data)
 {
        GVariant *arg_data;
 
-       if (p2p_skeleton == NULL)
+       if (NULL == p2p_skeleton)
        {
                NFC_ERR("p2p_skeleton is not initialized");
 
@@ -222,18 +200,15 @@ void net_nfc_server_p2p_received(data_s *user_data)
        net_nfc_gdbus_p2p_emit_received(p2p_skeleton, arg_data);
 }
 
-void net_nfc_server_p2p_data_sent(net_nfc_error_e result,
-               gpointer user_data)
+void net_nfc_server_p2p_data_sent(net_nfc_error_e result, gpointer user_data)
 {
-       P2pSendData *data = (P2pSendData *)user_data;
+       P2pSendData *data = user_data;
 
        g_assert(data != NULL);
        g_assert(data->p2p != NULL);
        g_assert(data->invocation != NULL);
 
-       net_nfc_gdbus_p2p_complete_send(data->p2p,
-                       data->invocation,
-                       (gint)result);
+       net_nfc_gdbus_p2p_complete_send(data->p2p, data->invocation, (gint)result);
 
        net_nfc_util_free_data(&data->data);
 
index 898e770..41f158e 100755 (executable)
@@ -169,7 +169,7 @@ static void _net_nfc_server_handover_send_response(
                data_s *ac_data,
                void *user_param)
 {
-       HandoverRequestData *handover_data = (HandoverRequestData *)user_param;
+       HandoverRequestData *handover_data = user_param;
 
        g_assert(handover_data != NULL);
        g_assert(handover_data->invocation != NULL);
@@ -195,16 +195,13 @@ static void _net_nfc_server_handover_send_response(
 }
 
 static net_nfc_error_e _net_nfc_server_handover_convert_ndef_message_to_data(
-               ndef_message_s *msg,
-               data_s *data)
+               ndef_message_s *msg, data_s *data)
 {
-       net_nfc_error_e result;
        uint32_t length;
+       net_nfc_error_e result;
 
-       if (msg == NULL || data == NULL)
-       {
-               return NET_NFC_INVALID_PARAM;
-       }
+       RETV_IF(NULL == msg, NET_NFC_INVALID_PARAM);
+       RETV_IF(NULL == data, NET_NFC_INVALID_PARAM);
 
        length = net_nfc_util_get_ndef_message_length(msg);
        if (length > 0)
@@ -228,25 +225,21 @@ static void _net_nfc_server_handover_bt_get_carrier_record_cb(
                ndef_record_s *aux_data,
                void *user_param)
 {
-       net_nfc_server_handover_create_config_context_t *context =
-               (net_nfc_server_handover_create_config_context_t *)user_param;
+       net_nfc_server_handover_create_config_context_t *context = user_param;
 
        /* append record to ndef message */
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
                ndef_record_s *record;
 
                /* FIXME : copy record and append */
-               net_nfc_util_create_record(carrier->TNF,
-                               &carrier->type_s,
-                               &carrier->id_s,
-                               &carrier->payload_s,
-                               &record);
-
-               if ((result = net_nfc_util_append_carrier_config_record(
-                                               context->ndef_message,
-                                               record,
-                                               cps)) == NET_NFC_OK)
+               net_nfc_util_create_record(carrier->TNF, &carrier->type_s, &carrier->id_s,
+                               &carrier->payload_s, &record);
+
+               result = net_nfc_util_append_carrier_config_record(context->ndef_message,
+                                               record, cps);
+
+               if (NET_NFC_OK == result)
                {
                        NFC_DBG("net_nfc_util_append_carrier_config_record success");
                }
@@ -256,8 +249,7 @@ static void _net_nfc_server_handover_bt_get_carrier_record_cb(
                        net_nfc_util_free_record(record);
                }
 
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
                                (gpointer)context);
        }
 
@@ -271,38 +263,29 @@ static void _net_nfc_server_handover_bss_get_carrier_record_cb(
                ndef_record_s *aux_data,
                void *user_param)
 {
-       net_nfc_server_handover_create_config_context_t *context =
-               (net_nfc_server_handover_create_config_context_t *)user_param;
+       net_nfc_server_handover_create_config_context_t *context = user_param;
 
        /* append record to ndef message */
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
                ndef_record_s *record;
 
-               net_nfc_util_create_record(carrier->TNF,
-                               &carrier->type_s,
-                               &carrier->id_s,
-                               &carrier->payload_s,
-                               &record);
+               net_nfc_util_create_record(carrier->TNF, &carrier->type_s, &carrier->id_s,
+                               &carrier->payload_s, &record);
 
-               if ((result = net_nfc_util_append_carrier_config_record(
-                                               context->ndef_message,
-                                               record,
-                                               cps)) == NET_NFC_OK)
+               result = net_nfc_util_append_carrier_config_record(context->ndef_message,
+                                               record, cps);
+               if (NET_NFC_OK == result)
                {
-                       NFC_DBG("net_nfc_util_append_carrier"
-                                       "_config_record success");
+                       NFC_DBG("net_nfc_util_append_carrier_config_record success");
                }
                else
                {
-                       NFC_ERR("net_nfc_util_append_carrier"
-                                       "_config_record failed [%d]",
-                                       result);
+                       NFC_ERR("net_nfc_util_append_carrier_config_record failed [%d]", result);
                        net_nfc_util_free_record(record);
                }
 
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
                                (gpointer)context);
        }
 
@@ -315,20 +298,16 @@ static void _net_nfc_server_handover_bt_process_carrier_record_cb(
                data_s *data,
                void *user_param)
 {
-       net_nfc_server_handover_process_config_context_t *context =
-               (net_nfc_server_handover_process_config_context_t *)user_param;
+       net_nfc_server_handover_process_config_context_t *context = user_param;
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
                if (context->cb != NULL)
-               {
                        context->cb(result, type, data, context->user_param);
-               }
        }
        else
        {
-               NFC_ERR("_handover_bt_process_carrier_record failed [%d]",
-                               result);
+               NFC_ERR("_handover_bt_process_carrier_record failed [%d]", result);
        }
 
        _net_nfc_util_free_mem(context);
@@ -340,16 +319,12 @@ static void _net_nfc_server_handover_bss_process_carrier_record_cb(
                data_s *data,
                void *user_param)
 {
-
-       net_nfc_server_handover_process_config_context_t *context =
-               (net_nfc_server_handover_process_config_context_t *)user_param;
+       net_nfc_server_handover_process_config_context_t *context = user_param;
 
        if(context)
        {
                if (context->cb != NULL)
-               {
                        context->cb(result, type, data, context->user_param);
-               }
                else
                        NFC_ERR("Invalid Callback");
 
@@ -367,16 +342,13 @@ net_nfc_server_handover_get_carrier_record_by_priority_order(
 
        LOGD("[%s] START", __func__);
 
-       if (request == NULL || record == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == request, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
 
        *record = NULL;
 
-       if ((result = net_nfc_util_get_alternative_carrier_record_count(
-                                       request,
-                                       &carrier_count)) == NET_NFC_OK)
+       result = net_nfc_util_get_alternative_carrier_record_count(request, &carrier_count);
+       if (NET_NFC_OK == result)
        {
                int idx, priority;
                net_nfc_conn_handover_carrier_type_e carrier_type =
@@ -388,11 +360,10 @@ net_nfc_server_handover_get_carrier_record_by_priority_order(
                        /* check each carrier record and create matched record */
                        for (idx = 0; idx < carrier_count; idx++)
                        {
-                               if ((net_nfc_util_get_alternative_carrier_type(
-                                                               request,
-                                                               idx,
-                                                               &carrier_type)== NET_NFC_OK)
-                                               && (carrier_type == priority))
+                               result = net_nfc_util_get_alternative_carrier_type(request, idx,
+                                                               &carrier_type);
+
+                               if ((NET_NFC_OK == result) && (carrier_type == priority))
                                {
                                        NFC_DBG("selected carrier type = [%d]", carrier_type);
                                        net_nfc_util_get_carrier_config_record(request, idx, record);
@@ -404,8 +375,7 @@ net_nfc_server_handover_get_carrier_record_by_priority_order(
        }
        else
        {
-               NFC_ERR("net_nfc_util_get_alternative_carrier"
-                               "_record_count failed");
+               NFC_ERR("net_nfc_util_get_alternative_carrier_record_count failed");
        }
 
        LOGD("[%s] END", __func__);
@@ -414,12 +384,11 @@ net_nfc_server_handover_get_carrier_record_by_priority_order(
 }
 
 static net_nfc_error_e _net_nfc_server_handover_create_requester_from_rawdata(
-               ndef_message_s **requestor,
-               data_s *data)
+               ndef_message_s **requestor, data_s *data)
 {
        net_nfc_error_e result;
 
-       if (requestor == NULL)
+       if (NULL == requestor)
                return NET_NFC_NULL_PARAMETER;
 
        *requestor = NULL;
@@ -427,32 +396,27 @@ static net_nfc_error_e _net_nfc_server_handover_create_requester_from_rawdata(
        result = net_nfc_util_create_ndef_message(requestor);
        if (result == NET_NFC_OK)
        {
-               result = net_nfc_util_convert_rawdata_to_ndef_message(data,
-                               *requestor);
+               result = net_nfc_util_convert_rawdata_to_ndef_message(data, *requestor);
 
                if (result == NET_NFC_OK)
                {
-                       if (_net_nfc_server_handover_check_hr_record_validation(
-                                               *requestor) == true)
+                       if (_net_nfc_server_handover_check_hr_record_validation(*requestor) == true)
                        {
                                result = NET_NFC_OK;
                        }
                        else
                        {
-                               NFC_ERR("record is not valid or"
-                                               " is not available");
+                               NFC_ERR("record is not valid or is not available");
                                net_nfc_util_free_ndef_message(*requestor);
                                result = NET_NFC_INVALID_PARAM;
                        }
                }
                else
                {
-                       NFC_ERR("_net_nfc_ndef_rawdata_to_ndef"
-                                       "failed [%d]",result);
+                       NFC_ERR("_net_nfc_ndef_rawdata_to_ndef failed [%d]",result);
                }
        } else {
-               NFC_ERR("net_nfc_util_create_ndef_message failed [%d]",
-                               result);
+               NFC_ERR("net_nfc_util_create_ndef_message failed [%d]", result);
        }
 
        return result;
@@ -463,42 +427,36 @@ net_nfc_error_e net_nfc_server_handover_create_selector_from_rawdata(
 {
        net_nfc_error_e result;
 
-       if (selector == NULL)
+       if (NULL == selector)
                return NET_NFC_NULL_PARAMETER;
 
        *selector = NULL;
 
-       if ((result = net_nfc_util_create_ndef_message(selector))
-                       == NET_NFC_OK)
+       if ((result = net_nfc_util_create_ndef_message(selector)) == NET_NFC_OK)
        {
-               if ((result = net_nfc_util_convert_rawdata_to_ndef_message(data,
-                                               *selector)) == NET_NFC_OK)
+               result = net_nfc_util_convert_rawdata_to_ndef_message(data, *selector);
+               if (NET_NFC_OK == result)
                {
-
                        /* if record is not Hs record, then */
-                       if (_net_nfc_server_handover_check_hs_record_validation(
-                                               *selector) == true)
+                       if (_net_nfc_server_handover_check_hs_record_validation(*selector) == true)
                        {
                                result = NET_NFC_OK;
                        }
                        else
                        {
-                               NFC_ERR("record is not valid or is "
-                                               "not available");
+                               NFC_ERR("record is not valid or is not available");
                                net_nfc_util_free_ndef_message(*selector);
                                result = NET_NFC_INVALID_PARAM;
                        }
                }
                else
                {
-                       NFC_ERR("_net_nfc_ndef_rawdata_to_ndef"
-                                       " failed [%d]",result);
+                       NFC_ERR("_net_nfc_ndef_rawdata_to_ndef failed [%d]",result);
                }
        }
        else
        {
-               NFC_ERR("_net_nfc_util_create_ndef_message"
-                               " failed [%d]",result);
+               NFC_ERR("_net_nfc_util_create_ndef_message failed [%d]",result);
        }
 
        return result;
@@ -507,21 +465,20 @@ net_nfc_error_e net_nfc_server_handover_create_selector_from_rawdata(
 static bool _net_nfc_server_handover_check_hr_record_validation(
                ndef_message_s *message)
 {
-       unsigned int count;
        ndef_record_s *rec;
+       unsigned int count;
+       net_nfc_error_e ret;
 
        LOGD("[%s] START", __func__);
 
-       if (message == NULL)
+       if (NULL == message)
                return false;
 
        rec = (ndef_record_s *)message->records;
 
-       if (memcmp(rec->type_s.buffer, CH_REQ_RECORD_TYPE,
-                               rec->type_s.length) != 0)
+       if (memcmp(rec->type_s.buffer, CH_REQ_RECORD_TYPE, rec->type_s.length) != 0)
        {
-               NFC_ERR("This is not connection handover"
-                               " request message");
+               NFC_ERR("This is not connection handover request message");
                goto ERROR;
        }
 
@@ -531,8 +488,8 @@ static bool _net_nfc_server_handover_check_hr_record_validation(
                goto ERROR;
        }
 
-       if (net_nfc_util_get_alternative_carrier_record_count(message, &count)
-                       != NET_NFC_OK || count == 0)
+       ret = net_nfc_util_get_alternative_carrier_record_count(message, &count);
+       if (ret != NET_NFC_OK || 0 == count)
        {
                NFC_ERR("there is no carrier reference");
                goto ERROR;
@@ -551,26 +508,25 @@ ERROR :
 static bool _net_nfc_server_handover_check_hs_record_validation(
                ndef_message_s *message)
 {
-       unsigned int count;
        ndef_record_s *rec;
+       unsigned int count;
+       net_nfc_error_e ret;
 
        LOGD("[%s] START", __func__);
 
-       if (message == NULL)
+       if (NULL == message)
                return false;
 
        rec = (ndef_record_s *)message->records;
 
-       if (memcmp(rec->type_s.buffer, CH_SEL_RECORD_TYPE,
-                               rec->type_s.length) != 0)
+       if (memcmp(rec->type_s.buffer, CH_SEL_RECORD_TYPE, rec->type_s.length) != 0)
        {
-               NFC_ERR("This is not connection handover"
-                               " request message");
+               NFC_ERR("This is not connection handover request message");
                goto ERROR;
        }
 
-       if (net_nfc_util_get_alternative_carrier_record_count(
-                               message,&count)!= NET_NFC_OK || count == 0)
+       ret = net_nfc_util_get_alternative_carrier_record_count(message,&count);
+       if (ret != NET_NFC_OK || 0 == count)
        {
                NFC_ERR("there is no carrrier reference");
                goto ERROR;
@@ -579,8 +535,7 @@ static bool _net_nfc_server_handover_check_hs_record_validation(
        /*      check version */
        if (rec->payload_s.buffer[0] != CH_VERSION)
        {
-               NFC_ERR("connection handover version"
-                               " is not matched");
+               NFC_ERR("connection handover version is not matched");
                goto ERROR;
        }
 
@@ -599,21 +554,13 @@ static int _net_nfc_server_handover_iterate_carrier_configs_step(
 {
        LOGD("[%s:%d] START", __func__, __LINE__);
 
-       if (context == NULL)
-       {
-               return 0;
-       }
+       RETV_IF(NULL == context, 0);
 
        if (context->cb != NULL)
-       {
-               context->cb(NET_NFC_OK, context->ndef_message,
-                               context->user_param);
-       }
+               context->cb(NET_NFC_OK, context->ndef_message, context->user_param);
 
        if (context->ndef_message != NULL)
-       {
                net_nfc_util_free_ndef_message(context->ndef_message);
-       }
 
        _net_nfc_util_free_mem(context);
 
@@ -630,25 +577,21 @@ static int _net_nfc_server_handover_iterate_carrier_configs_to_next(
                if (context->type == NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
                {
                        if (context->current_type < NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
-                       {
                                context->current_type++;
-                       }
                }
                else
                {
                        context->current_type = NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN;
                }
 
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
                                (gpointer)context);
        }
        else
        {
                NFC_ERR("context->result is error [%d]", context->result);
 
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
                                (gpointer)context);
        }
 
@@ -666,8 +609,7 @@ static int _net_nfc_server_handover_iterate_create_carrier_configs(
        case NET_NFC_CONN_HANDOVER_CARRIER_BT :
                NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_BT]");
                net_nfc_server_handover_bt_get_carrier_record(
-                               _net_nfc_server_handover_bt_get_carrier_record_cb,
-                               context);
+                               _net_nfc_server_handover_bt_get_carrier_record_cb, context);
                break;
 
        case NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS :
@@ -678,15 +620,13 @@ static int _net_nfc_server_handover_iterate_create_carrier_configs(
                                        context->ndef_message->records->type_s.length)==0)
                {
                        result = net_nfc_server_handover_bss_wfd_get_carrier_record(
-                                       _net_nfc_server_handover_bss_get_carrier_record_cb,
-                                       context);
+                                       _net_nfc_server_handover_bss_get_carrier_record_cb, context);
                }
                else
 #endif
                {
                        result = net_nfc_server_handover_bss_get_carrier_record(
-                                       _net_nfc_server_handover_bss_get_carrier_record_cb,
-                                       context);
+                                       _net_nfc_server_handover_bss_get_carrier_record_cb, context);
                }
                NFC_DBG("[%d]",result);
                break;
@@ -700,15 +640,13 @@ static int _net_nfc_server_handover_iterate_create_carrier_configs(
 
        case NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN :
                NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN]");
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
                                (gpointer)context);
                break;
 
        default :
                NFC_DBG("[unknown : %d]", context->current_type);
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
                                (gpointer)context);
                break;
        }
@@ -720,9 +658,7 @@ static int _net_nfc_server_handover_iterate_create_carrier_configs(
 
 static net_nfc_error_e
 _net_nfc_server_handover_create_requester_carrier_configs(
-               net_nfc_conn_handover_carrier_type_e type,
-               void *cb,
-               void *user_param)
+               net_nfc_conn_handover_carrier_type_e type, void *cb, void *user_param)
 {
        net_nfc_error_e result = NET_NFC_OK;
        net_nfc_server_handover_create_config_context_t *context = NULL;
@@ -734,20 +670,16 @@ _net_nfc_server_handover_create_requester_carrier_configs(
        {
                context->type = type;
                if (type == NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
-               {
                        context->current_type = NET_NFC_CONN_HANDOVER_CARRIER_BT;
-               }
                else
                        context->current_type = context->type;
 
                context->cb = cb;
                context->user_param = user_param;
-               net_nfc_util_create_handover_request_message(
-                               &context->ndef_message);
+               net_nfc_util_create_handover_request_message(&context->ndef_message);
 
                /* append carrier record */
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
                                (gpointer)context);
        }
        else
@@ -763,9 +695,7 @@ _net_nfc_server_handover_create_requester_carrier_configs(
 
 static net_nfc_error_e
 _net_nfc_server_handover_create_selector_carrier_configs(
-               net_nfc_conn_handover_carrier_type_e type,
-               void *cb,
-               void *user_param)
+               net_nfc_conn_handover_carrier_type_e type, void *cb, void *user_param)
 {
        net_nfc_error_e result = NET_NFC_OK;
        net_nfc_server_handover_create_config_context_t *context = NULL;
@@ -783,12 +713,10 @@ _net_nfc_server_handover_create_selector_carrier_configs(
 
                context->cb = cb;
                context->user_param = user_param;
-               net_nfc_util_create_handover_select_message(
-                               &context->ndef_message);
+               net_nfc_util_create_handover_select_message(&context->ndef_message);
 
                /* append carrier record */
-               g_idle_add(
-                               (GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
+               g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
                                (gpointer)context);
        }
        else
@@ -815,9 +743,7 @@ net_nfc_error_e net_nfc_server_handover_process_carrier_record(
        {
                net_nfc_conn_handover_carrier_type_e type;
 
-               net_nfc_util_get_alternative_carrier_type_from_record(
-                               carrier,
-                               &type);
+               net_nfc_util_get_alternative_carrier_type_from_record(carrier, &type);
 
                context->type = type;
                context->user_param = user_param;
@@ -829,18 +755,14 @@ net_nfc_error_e net_nfc_server_handover_process_carrier_record(
                {
                case NET_NFC_CONN_HANDOVER_CARRIER_BT :
                        NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_BT]");
-                       net_nfc_server_handover_bt_process_carrier_record(
-                                       carrier,
-                                       _net_nfc_server_handover_bt_process_carrier_record_cb,
-                                       context);
+                       net_nfc_server_handover_bt_process_carrier_record(carrier,
+                                       _net_nfc_server_handover_bt_process_carrier_record_cb, context);
                        break;
 
                case NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS :
                        NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS]");
-                       net_nfc_server_handover_bss_process_carrier_record(
-                                       carrier,
-                                       _net_nfc_server_handover_bss_process_carrier_record_cb,
-                                       context);
+                       net_nfc_server_handover_bss_process_carrier_record(carrier,
+                                       _net_nfc_server_handover_bss_process_carrier_record_cb, context);
                        break;
 
                case NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN :
@@ -870,35 +792,30 @@ static net_nfc_error_e _net_nfc_server_handover_select_carrier_record(
                net_nfc_conn_handover_carrier_type_e *type,
                ndef_record_s **record)
 {
-       net_nfc_error_e result;
        uint32_t count;
+       net_nfc_error_e result;
 
        *record = NULL;
        *type = NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN;
 
        /* get requester message */
-       if ((result = net_nfc_util_get_alternative_carrier_record_count(request,
-                                       &count)) == NET_NFC_OK)
+       result = net_nfc_util_get_alternative_carrier_record_count(request, &count);
+       if (NET_NFC_OK == result)
        {
-               if (1/* power state */ || count == 1)
+               if (1/* power state */ || 1 == count)
                {
                        ndef_record_s *temp;
 
                        /* fill alternative carrier information */
-                       if ((result =
-                                               net_nfc_server_handover_get_carrier_record_by_priority_order(
-                                                       request,
-                                                       &temp)) == NET_NFC_OK)
+                       result = net_nfc_server_handover_get_carrier_record_by_priority_order(
+                                                       request, &temp);
+                       if (NET_NFC_OK == result)
                        {
-                               if ((result =
-                                                       net_nfc_util_get_alternative_carrier_type_from_record(
-                                                               temp,
-                                                               type)) == NET_NFC_OK)
+                               result = net_nfc_util_get_alternative_carrier_type_from_record(temp, type);
+                               if (NET_NFC_OK == result)
                                {
-                                       net_nfc_util_create_record(temp->TNF,
-                                                       &temp->type_s, &temp->id_s,
-                                                       &temp->payload_s,
-                                                       record);
+                                       net_nfc_util_create_record(temp->TNF, &temp->type_s, &temp->id_s,
+                                                       &temp->payload_s, record);
                                }
                                else
                                {
@@ -908,8 +825,7 @@ static net_nfc_error_e _net_nfc_server_handover_select_carrier_record(
                        }
                        else
                        {
-                               NFC_ERR("_handover_get_carrier_record"
-                                               "_by_priority_order failed [%d]", result);
+                               NFC_ERR("_handover_get_carrier_record_by_priority_order failed [%d]", result);
                        }
                }
                else /* low power && count > 1 */
@@ -919,8 +835,7 @@ static net_nfc_error_e _net_nfc_server_handover_select_carrier_record(
        }
        else
        {
-               NFC_ERR("net_nfc_util_get_alternative_carrier_record_count "
-                               "failed [%d]", result);
+               NFC_ERR("net_nfc_util_get_alternative_carrier_record_count failed [%d]", result);
        }
 
        return result;
@@ -931,20 +846,17 @@ static void _net_nfc_server_handover_create_carrier_configs_2_cb(
 {
        net_nfc_handover_context_t *context = user_param;
 
+       RET_IF(NULL == context);
+
        NFC_DBG("_net_nfc_server_handover_server_create_carrier_config_cb result [%d]",
                        result);
 
-       if (context == NULL)
-       {
-               return;
-       }
-
        context->result = result;
 
-       if (result == NET_NFC_OK) {
+       if (NET_NFC_OK == result)
+       {
                result = _net_nfc_server_handover_convert_ndef_message_to_data(
-                               selector,
-                               &context->data);
+                               selector, &context->data);
 
                NFC_DBG("selector message created, length [%d]", context->data.length);
 
@@ -952,8 +864,7 @@ static void _net_nfc_server_handover_create_carrier_configs_2_cb(
        }
        else
        {
-               NFC_ERR("_net_nfc_server_handover_create_selector_msg failed [%d]",
-                               result);
+               NFC_ERR("_net_nfc_server_handover_create_selector_msg failed [%d]", result);
                context->state = NET_NFC_MESSAGE_LLCP_ERROR;
        }
 
@@ -966,21 +877,16 @@ static void _net_nfc_server_handover_process_carrier_record_2_cb(
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = (net_nfc_handover_context_t *)user_param;
 
        NFC_DBG("_net_nfc_server_handover_server_process_carrier_record_cb result [%d]",
                        result);
 
        context->result = result;
-       if (result == NET_NFC_OK)
-       {
+       if (NET_NFC_OK == result)
                context->state = NET_NFC_LLCP_STEP_04;
-       }
        else
-       {
                context->state = NET_NFC_MESSAGE_LLCP_ERROR;
-       }
 
        context->data.length = data->length;
        _net_nfc_util_alloc_mem(context->data.buffer, context->data.length);
@@ -995,10 +901,7 @@ static void _net_nfc_server_handover_get_response_process(
 {
        net_nfc_error_e result;
 
-       if (context == NULL)
-       {
-               return;
-       }
+       RET_IF(NULL == context);
 
        switch (context->state)
        {
@@ -1006,9 +909,7 @@ static void _net_nfc_server_handover_get_response_process(
                NFC_DBG("NET_NFC_LLCP_STEP_02");
 
                result = _net_nfc_server_handover_create_selector_carrier_configs(
-                               context->type,
-                               _net_nfc_server_handover_create_carrier_configs_2_cb,
-                               context);
+                               context->type, _net_nfc_server_handover_create_carrier_configs_2_cb, context);
 
                if (result != NET_NFC_OK)
                {
@@ -1027,8 +928,7 @@ static void _net_nfc_server_handover_get_response_process(
 
                if (result != NET_NFC_OK)
                {
-                       NFC_ERR("net_nfc_server_handover_process_carrier_record"
-                                       "failed [%d]",result);
+                       NFC_ERR("net_nfc_server_handover_process_carrier_record failed [%d]",result);
                }
                break;
 
@@ -1038,8 +938,7 @@ static void _net_nfc_server_handover_get_response_process(
                /* response select message */
                // TODO: context->handle may is not valid type. we should find a right function or parameter
                result = net_nfc_server_snep_server_send_get_response(
-                               (net_nfc_snep_handle_h)context->handle,
-                               &context->data);
+                               (net_nfc_snep_handle_h)context->handle, &context->data);
                break;
 
        case NET_NFC_STATE_ERROR :
@@ -1063,26 +962,21 @@ static bool _net_nfc_server_handover_get_response_cb(
        net_nfc_error_e result;
        ndef_message_s *request;
 
-       NFC_DBG("type [%d], data [%p], user_param [%p]", type, data, user_param);
+       RETV_IF(NULL == data, false);
+       RETV_IF(NULL == data->buffer, false);
 
-       if (data == NULL || data->buffer == NULL)
-       {
-               /* restart */
-               return false;
-       }
+       NFC_DBG("type [%d], data [%p], user_param [%p]", type, data, user_param);
 
        /* TODO : send select response to requester */
        result = _net_nfc_server_handover_create_requester_from_rawdata(&request, data);
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
-               net_nfc_conn_handover_carrier_type_e type;
                ndef_record_s *record;
+               net_nfc_conn_handover_carrier_type_e type;
 
-               if (_net_nfc_server_handover_select_carrier_record(
-                                       request,
-                                       &type,
-                                       &record) == NET_NFC_OK)
+               result = _net_nfc_server_handover_select_carrier_record(request, &type, &record);
+               if (NET_NFC_OK == result)
                {
                        net_nfc_handover_context_t *context = NULL;
 
@@ -1095,11 +989,8 @@ static bool _net_nfc_server_handover_get_response_cb(
                                context->user_param = user_param;
                                context->state = NET_NFC_LLCP_STEP_02;
 
-                               net_nfc_util_create_record(record->TNF,
-                                               &record->type_s,
-                                               &record->id_s,
-                                               &record->payload_s,
-                                               &context->record);
+                               net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+                                               &record->payload_s, &context->record);
 
                                _net_nfc_server_handover_get_response_process(context);
                        }
@@ -1121,7 +1012,7 @@ static bool _net_nfc_server_handover_get_response_cb(
                NFC_ERR("it is not handover requester message, [%d]", result);
        }
 
-       return (result == NET_NFC_OK);
+       return (NET_NFC_OK == result);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1131,15 +1022,14 @@ static void _net_nfc_server_handover_server_process_carrier_record_cb(
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
        NFC_DBG("_net_nfc_server_handover_server_process_carrier_record_cb result [%d]",
                        result);
 
        context->result = result;
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
                context->state = NET_NFC_LLCP_STEP_04;
        else
                context->state = NET_NFC_MESSAGE_LLCP_ERROR;
@@ -1148,33 +1038,23 @@ static void _net_nfc_server_handover_server_process_carrier_record_cb(
 }
 
 static void _net_nfc_server_handover_server_create_carrier_config_cb(
-               net_nfc_error_e result,
-               ndef_message_s *selector,
-               void *user_param)
+               net_nfc_error_e result, ndef_message_s *selector, void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_conn_handover_carrier_type_e type;
+       net_nfc_handover_context_t *context = user_param;
+
+       RET_IF(NULL == context);
 
        NFC_DBG("_net_nfc_server_handover_server_create_carrier_config_cb,result [%d]",
                        result);
 
-       if (context == NULL)
-       {
-               return;
-       }
-
        context->result = result;
 
-       net_nfc_conn_handover_carrier_type_e type;
-
-       net_nfc_util_get_alternative_carrier_type_from_record(
-                       context->record,
-                       &type);
-       if (result == NET_NFC_OK)
+       net_nfc_util_get_alternative_carrier_type_from_record(context->record, &type);
+       if (NET_NFC_OK == result)
        {
                result = _net_nfc_server_handover_convert_ndef_message_to_data(
-                               selector,
-                               &context->data);
+                               selector, &context->data);
                NFC_DBG("selector message created, length [%d]", context->data.length);
                if(type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
                        context->state = NET_NFC_LLCP_STEP_04;
@@ -1183,8 +1063,7 @@ static void _net_nfc_server_handover_server_create_carrier_config_cb(
        }
        else
        {
-               NFC_ERR("_net_nfc_server_handover_create_selector_msg"
-                               " failed [%d]", result);
+               NFC_ERR("_net_nfc_server_handover_create_selector_msg failed [%d]", result);
                context->state = NET_NFC_MESSAGE_LLCP_ERROR;
        }
 
@@ -1198,34 +1077,30 @@ static void _net_nfc_server_handover_server_recv_cb(
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_error_e ret;
        ndef_message_s *request;
+       net_nfc_handover_context_t *context = user_param;
 
        NFC_DBG("_net_nfc_server_handover_server_recv_cb, socket [%x], result [%d]",
                        socket, result);
 
        context->result = result;
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
-               result = _net_nfc_server_handover_create_requester_from_rawdata(
-                               &request,
-                               data);
+               result = _net_nfc_server_handover_create_requester_from_rawdata(&request, data);
 
-               if (result == NET_NFC_OK)
+               if (NET_NFC_OK == result)
                {
                        ndef_record_s *record;
 
-                       if (_net_nfc_server_handover_select_carrier_record(
-                                               request,
-                                               &context->type,
-                                               &record) == NET_NFC_OK)
+                       ret = _net_nfc_server_handover_select_carrier_record(request,
+                                               &context->type, &record);
+
+                       if (NET_NFC_OK == ret)
                        {
-                               net_nfc_util_create_record(record->TNF,
-                                               &record->type_s, &record->id_s,
-                                               &record->payload_s,
-                                               &context->record);
+                               net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+                                               &record->payload_s, &context->record);
 
                                context->state = NET_NFC_LLCP_STEP_02;
                        }
@@ -1246,8 +1121,7 @@ static void _net_nfc_server_handover_server_recv_cb(
        }
        else
        {
-               NFC_ERR("net_nfc_server_llcp_simple_receive failed [%d]",
-                               result);
+               NFC_ERR("net_nfc_server_llcp_simple_receive failed [%d]", result);
                context->state = NET_NFC_MESSAGE_LLCP_ERROR;
        }
 
@@ -1260,15 +1134,14 @@ static void _net_nfc_server_handover_server_send_cb(net_nfc_error_e result,
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
        NFC_DBG("_net_nfc_server_handover_server_send_cb socket[%x], result[%d]",
                        socket, result);
 
        context->result = result;
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
                context->state = NET_NFC_LLCP_STEP_01;
                net_nfc_util_free_data(&context->data);
@@ -1277,8 +1150,7 @@ static void _net_nfc_server_handover_server_send_cb(net_nfc_error_e result,
        }
        else
        {
-               NFC_ERR("net_nfc_server_llcp_simple_send failed [%d]",
-                               result);
+               NFC_ERR("net_nfc_server_llcp_simple_send failed [%d]", result);
                context->state = NET_NFC_MESSAGE_LLCP_ERROR;
        }
 
@@ -1288,10 +1160,7 @@ static void _net_nfc_server_handover_server_send_cb(net_nfc_error_e result,
 static void _net_nfc_server_handover_server_process(
                net_nfc_handover_context_t *context)
 {
-       if (context == NULL)
-       {
-               return;
-       }
+       RET_IF(NULL == context);
 
        switch (context->state)
        {
@@ -1299,10 +1168,8 @@ static void _net_nfc_server_handover_server_process(
                NFC_DBG("NET_NFC_LLCP_STEP_01");
 
                /* receive request message */
-               net_nfc_server_llcp_simple_receive(context->handle,
-                               context->socket,
-                               _net_nfc_server_handover_server_recv_cb,
-                               context);
+               net_nfc_server_llcp_simple_receive(context->handle, context->socket,
+                               _net_nfc_server_handover_server_recv_cb, context);
                break;
 
        case NET_NFC_LLCP_STEP_02 :
@@ -1316,7 +1183,7 @@ static void _net_nfc_server_handover_server_process(
                if (context->result != NET_NFC_OK)
                {
                        NFC_ERR("_net_nfc_server_handover_create_selector"
-                                       "_carrier_configs failed [%d]", context->result);
+                                       "_carrier_configs failed [%d]", context->result);
                }
                break;
 
@@ -1327,6 +1194,7 @@ static void _net_nfc_server_handover_server_process(
                                context->record,
                                _net_nfc_server_handover_server_process_carrier_record_cb,
                                context);
+
                if (context->result != NET_NFC_OK)
                {
                        NFC_ERR("_net_nfc_server_handover_process_carrier_"
@@ -1338,20 +1206,15 @@ static void _net_nfc_server_handover_server_process(
                NFC_DBG("NET_NFC_LLCP_STEP_04");
 
                /* send select message */
-               net_nfc_server_llcp_simple_send(
-                               context->handle,
-                               context->socket,
-                               &context->data,
-                               _net_nfc_server_handover_server_send_cb,
-                               context);
+               net_nfc_server_llcp_simple_send(context->handle, context->socket, &context->data,
+                               _net_nfc_server_handover_server_send_cb, context);
                break;
 
        case NET_NFC_STATE_ERROR :
                NFC_DBG("NET_NFC_STATE_ERROR");
 
                /* error, invoke callback */
-               NFC_ERR("handover_server failed, [%d]",
-                               context->result);
+               NFC_ERR("handover_server failed, [%d]", context->result);
 
                /* restart?? */
                break;
@@ -1370,16 +1233,11 @@ static void _net_nfc_server_handover_server_error_cb(
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
-       NFC_ERR("result [%d], socket [%x], user_param [%p]",
-                       result, socket, user_param);
+       NFC_ERR("result [%d], socket [%x], user_param [%p]", result, socket, user_param);
 
-       if (context == NULL)
-       {
-               return;
-       }
+       RET_IF(NULL == context);
 
        net_nfc_controller_llcp_socket_close(socket, &result);
 
@@ -1395,12 +1253,12 @@ static void _net_nfc_server_handover_server_incomming_cb(
                data_s *data,
                void *user_param)
 {
-       NFC_DBG("result[%d], socket[%x], user_param[%p]", result, socket, user_param);
-
        net_nfc_handover_context_t *accept_context = NULL;
 
+       NFC_DBG("result[%d], socket[%x], user_param[%p]", result, socket, user_param);
+
        _net_nfc_util_alloc_mem(accept_context, sizeof(*accept_context));
-       if (accept_context == NULL)
+       if (NULL == accept_context)
        {
                NFC_ERR("_net_nfc_util_alloc_mem failed");
 
@@ -1412,16 +1270,12 @@ static void _net_nfc_server_handover_server_incomming_cb(
        accept_context->socket = socket;
        accept_context->state = NET_NFC_LLCP_STEP_01;
 
-       result = net_nfc_server_llcp_simple_accept(
-                       handle,
-                       socket,
-                       _net_nfc_server_handover_server_error_cb,
-                       accept_context);
+       result = net_nfc_server_llcp_simple_accept(handle, socket,
+                       _net_nfc_server_handover_server_error_cb, accept_context);
 
        if (result != NET_NFC_OK)
        {
-               NFC_ERR("net_nfc_server_llcp_simple_accept failed, [%d]",
-                               result);
+               NFC_ERR("net_nfc_server_llcp_simple_accept failed, [%d]", result);
 
                goto ERROR;
        }
@@ -1432,9 +1286,7 @@ static void _net_nfc_server_handover_server_incomming_cb(
 
 ERROR :
        if (accept_context != NULL)
-       {
                _net_nfc_util_free_mem(accept_context);
-       }
 
        net_nfc_controller_llcp_socket_close(socket, &result);
 
@@ -1447,9 +1299,8 @@ net_nfc_error_e net_nfc_server_handover_default_server_start(
        net_nfc_error_e result;
 
        /* start default handover server using snep */
-       result =
-               net_nfc_server_snep_default_server_register_get_response_cb(
-                               _net_nfc_server_handover_get_response_cb, NULL);
+       result = net_nfc_server_snep_default_server_register_get_response_cb(
+                                       _net_nfc_server_handover_get_response_cb, NULL);
 
        /* start default handover server */
        result = net_nfc_server_llcp_simple_server(
@@ -1460,7 +1311,7 @@ net_nfc_error_e net_nfc_server_handover_default_server_start(
                        _net_nfc_server_handover_server_error_cb,
                        NULL);
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
                NFC_DBG("start handover server, san[%s], sap[%d]", CH_SAN, CH_SAP);
        else
                NFC_ERR("net_nfc_server_llcp_simple_server failed, [%d]", result);
@@ -1475,7 +1326,8 @@ static void _handover_default_activate_cb(int event,
 
        NFC_DBG("event [%d], handle [%p], sap [%d], san [%s]", event, handle, sap, san);
 
-       if (event == NET_NFC_LLCP_START) {
+       if (NET_NFC_LLCP_START == event)
+       {
                /* start default handover server using snep */
                result = net_nfc_server_snep_default_server_register_get_response_cb(
                                _net_nfc_server_handover_get_response_cb, NULL);
@@ -1486,12 +1338,14 @@ static void _handover_default_activate_cb(int event,
                                _net_nfc_server_handover_server_incomming_cb,
                                _net_nfc_server_handover_server_error_cb, NULL);
 
-               if (result == NET_NFC_OK)
+               if (NET_NFC_OK == result)
                        NFC_DBG("start handover server, san [%s], sap [%d]", CH_SAN, CH_SAP);
                else
                        NFC_ERR("net_nfc_service_llcp_server failed, [%d]", result);
 
-       } else if (event == NET_NFC_LLCP_UNREGISTERED) {
+       }
+       else if (NET_NFC_LLCP_UNREGISTERED == event)
+       {
                /* unregister server, do nothing */
        }
 }
@@ -1504,11 +1358,8 @@ net_nfc_error_e net_nfc_server_handover_default_server_register()
        snprintf(id, sizeof(id), "%d", getpid());
 
        /* start default snep server */
-       return net_nfc_server_llcp_register_service(id,
-                       CH_SAP,
-                       CH_SAN,
-                       _handover_default_activate_cb,
-                       NULL);
+       return net_nfc_server_llcp_register_service(id, CH_SAP, CH_SAN,
+                       _handover_default_activate_cb, NULL);
 }
 
 net_nfc_error_e net_nfc_server_handover_default_server_unregister()
@@ -1519,9 +1370,7 @@ net_nfc_error_e net_nfc_server_handover_default_server_unregister()
        snprintf(id, sizeof(id), "%d", getpid());
 
        /* start default snep server */
-       return net_nfc_server_llcp_unregister_service(id,
-                       CH_SAP,
-                       CH_SAN);
+       return net_nfc_server_llcp_unregister_service(id, CH_SAP, CH_SAN);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1532,13 +1381,9 @@ static void _net_nfc_server_handover_client_post_process_cb(
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
-       if (context == NULL)
-       {
-               return;
-       }
+       RET_IF(NULL == context);
 
        context->state = NET_NFC_LLCP_STEP_RETURN;
 
@@ -1551,8 +1396,7 @@ static void _net_nfc_server_handover_client_process_carrier_record_cb(
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
        NFC_DBG("_net_nfc_server_handover_server_process_carrier_record_cb, result[%d]",
                        result);
@@ -1561,10 +1405,12 @@ static void _net_nfc_server_handover_client_process_carrier_record_cb(
 
        net_nfc_util_free_data(&context->data);
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
                if(context->type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
+               {
                        context->state = NET_NFC_LLCP_STEP_RETURN;
+               }
                else
                {
                        net_nfc_util_alloc_data(&context->data, data->length);
@@ -1587,46 +1433,34 @@ static void _net_nfc_server_handover_client_recv_cb(net_nfc_error_e result,
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
-       if (context == NULL)
-       {
-               return;
-       }
+       RET_IF(NULL == context);
 
        context->result = result;
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
-               ndef_message_s *selector;
                ndef_record_s *record;
+               ndef_message_s *selector;
 
-               result = net_nfc_server_handover_create_selector_from_rawdata(
-                               &selector,
-                               data);
+               result = net_nfc_server_handover_create_selector_from_rawdata(&selector, data);
 
-               if (result == NET_NFC_OK)
+               if (NET_NFC_OK == result)
                {
-                       result =
-                               net_nfc_server_handover_get_carrier_record_by_priority_order(
-                                               selector,
-                                               &record);
+                       result = net_nfc_server_handover_get_carrier_record_by_priority_order(
+                                               selector, &record);
 
-                       if (result == NET_NFC_OK)
+                       if (NET_NFC_OK == result)
                        {
-                               net_nfc_util_create_record(
-                                               record->TNF,
-                                               &record->type_s, &record->id_s,
-                                               &record->payload_s,
-                                               &context->record);
+                               net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+                                               &record->payload_s, &context->record);
 
                                context->state = NET_NFC_LLCP_STEP_04;
                        }
                        else
                        {
-                               NFC_ERR("_get_carrier_record_by_priority_order"
-                                               " failed, [%d]",result);
+                               NFC_ERR("_get_carrier_record_by_priority_order failed, [%d]",result);
                                context->state = NET_NFC_STATE_ERROR;
                        }
                }
@@ -1639,8 +1473,7 @@ static void _net_nfc_server_handover_client_recv_cb(net_nfc_error_e result,
        }
        else
        {
-               NFC_ERR("net_nfc_server_llcp_simple_receive failed, [%d]",
-                               result);
+               NFC_ERR("net_nfc_server_llcp_simple_receive failed, [%d]", result);
                context->state = NET_NFC_STATE_ERROR;
        }
 
@@ -1653,26 +1486,21 @@ static void _net_nfc_server_handover_client_send_cb(net_nfc_error_e result,
                data_s *data,
                void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
-       if (context == NULL)
-       {
-               return;
-       }
+       RET_IF(NULL == context);
 
        context->result = result;
 
        net_nfc_util_free_data(&context->data);
 
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
                context->state = NET_NFC_LLCP_STEP_03;
        }
        else
        {
-               NFC_ERR("net_nfc_server_llcp_simple_client failed, [%d]",
-                               result);
+               NFC_ERR("net_nfc_server_llcp_simple_client failed, [%d]", result);
                context->state = NET_NFC_STATE_ERROR;
        }
 
@@ -1680,25 +1508,18 @@ static void _net_nfc_server_handover_client_send_cb(net_nfc_error_e result,
 }
 
 static void _net_nfc_server_handover_client_create_carrier_configs_cb(
-               net_nfc_error_e result,
-               ndef_message_s *msg,
-               void *user_param)
+               net_nfc_error_e result, ndef_message_s *msg, void *user_param)
 {
-       net_nfc_handover_context_t *context =
-               (net_nfc_handover_context_t *)user_param;
+       net_nfc_handover_context_t *context = user_param;
 
-       if (context == NULL) {
-               return;
-       }
+       RET_IF(NULL == context);
 
        context->result = result;
 
        if (msg != NULL)
        {
-               if ((result =
-                                       _net_nfc_server_handover_convert_ndef_message_to_data(
-                                               msg,
-                                               &context->data)) == NET_NFC_OK)
+               result = _net_nfc_server_handover_convert_ndef_message_to_data(msg, &context->data);
+               if (NET_NFC_OK == result)
                {
                        context->state = NET_NFC_LLCP_STEP_02;
                }
@@ -1727,20 +1548,18 @@ static void _net_nfc_server_handover_client_process(
 {
        net_nfc_error_e result;
 
-       if (context == NULL)
-       {
-               return;
-       }
+       RET_IF(NULL == context);
 
        switch (context->state)
        {
        case NET_NFC_LLCP_STEP_01 :
                NFC_DBG("NET_NFC_LLCP_STEP_01");
 
-               if ((result = _net_nfc_server_handover_create_requester_carrier_configs(
+               result = _net_nfc_server_handover_create_requester_carrier_configs(
                                                context->type,
                                                _net_nfc_server_handover_client_create_carrier_configs_cb,
-                                               context)) != NET_NFC_OK)
+                                               context);
+               if (result != NET_NFC_OK)
                {
                        NFC_ERR("_net_nfc_server_handover_create_requester"
                                        "_carrier_configs failed [%d]",result);
@@ -1751,48 +1570,36 @@ static void _net_nfc_server_handover_client_process(
                NFC_DBG("NET_NFC_LLCP_STEP_02");
 
                /* send request */
-               net_nfc_server_llcp_simple_send(
-                               context->handle,
-                               context->socket,
-                               &context->data,
-                               _net_nfc_server_handover_client_send_cb,
-                               context);
+               net_nfc_server_llcp_simple_send(context->handle, context->socket, &context->data,
+                               _net_nfc_server_handover_client_send_cb, context);
                break;
 
        case NET_NFC_LLCP_STEP_03 :
                NFC_DBG("NET_NFC_LLCP_STEP_03");
 
                /* receive response */
-               net_nfc_server_llcp_simple_receive(context->handle,
-                               context->socket,
-                               _net_nfc_server_handover_client_recv_cb,
-                               context);
+               net_nfc_server_llcp_simple_receive(context->handle, context->socket,
+                               _net_nfc_server_handover_client_recv_cb, context);
                break;
 
        case NET_NFC_LLCP_STEP_04 :
                NFC_DBG("NET_NFC_LLCP_STEP_04");
 
-               result = net_nfc_server_handover_process_carrier_record(
-                               context->record,
-                               _net_nfc_server_handover_client_process_carrier_record_cb,
-                               context);
+               result = net_nfc_server_handover_process_carrier_record(context->record,
+                               _net_nfc_server_handover_client_process_carrier_record_cb, context);
 
                if (result != NET_NFC_OK)
-               {
                        NFC_ERR("net_nfc_server_handover_process_carrier_record failed [%d]",result);
-               }
                break;
 
        case NET_NFC_LLCP_STEP_05 :
                NFC_DBG("NET_NFC_LLCP_STEP_05");
 
                /* start post process */
-               if (context->type == NET_NFC_CONN_HANDOVER_CARRIER_BT)
+               if (NET_NFC_CONN_HANDOVER_CARRIER_BT == context->type)
                {
-                       net_nfc_server_handover_bt_post_process(
-                                       &context->data,
-                                       _net_nfc_server_handover_client_post_process_cb,
-                                       context);
+                       net_nfc_server_handover_bt_post_process(&context->data,
+                                       _net_nfc_server_handover_client_post_process_cb, context);
                }
                else
                {
@@ -1804,11 +1611,8 @@ static void _net_nfc_server_handover_client_process(
                NFC_DBG("NET_NFC_LLCP_STEP_RETURN");
 
                /* complete and invoke callback */
-               _net_nfc_server_handover_send_response(
-                               context->result,
-                               context->type,
-                               &context->data,
-                               context->user_param);
+               _net_nfc_server_handover_send_response(context->result, context->type,
+                               &context->data, context->user_param);
 
                net_nfc_util_free_data(&context->data);
                net_nfc_util_free_record(context->record);
@@ -1819,11 +1623,8 @@ static void _net_nfc_server_handover_client_process(
        default :
                NFC_ERR("NET_NFC_STATE_ERROR");
 
-               _net_nfc_server_handover_send_response(
-                               context->result,
-                               context->type,
-                               NULL,
-                               context->user_param);
+               _net_nfc_server_handover_send_response(context->result, context->type,
+                               NULL, context->user_param);
                break;
        }
 }
@@ -1841,7 +1642,7 @@ static void _net_nfc_server_handover_client_connected_cb(
 
        HandoverRequestData *handover_data = NULL;
        handover_data = (HandoverRequestData *)user_param;
-       if (result == NET_NFC_OK)
+       if (NET_NFC_OK == result)
        {
                net_nfc_handover_context_t *context = NULL;
                _net_nfc_util_alloc_mem(context, sizeof(*context));
@@ -1875,17 +1676,12 @@ static void _net_nfc_server_handover_client_error_cb(
                data_s *data,
                void *user_param)
 {
-
-       NFC_ERR("result [%d], socket [%x], user_param [%p]",
-                       result, socket, user_param);
+       NFC_ERR("result [%d], socket [%x], user_param [%p]", result, socket, user_param);
 
        if (false)
        {
-               _net_nfc_server_handover_send_response(
-                               result,
-                               NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN,
-                               NULL,
-                               user_param);
+               _net_nfc_server_handover_send_response(result,
+                               NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN, NULL, user_param);
        }
 
        net_nfc_controller_llcp_socket_close(socket, &result);
@@ -1906,10 +1702,7 @@ net_nfc_error_e net_nfc_server_handover_default_client_start(
                        user_data);
 
        if (result != NET_NFC_OK)
-       {
-               NFC_ERR("net_nfc_server_llcp_simple_client"
-                               " failed, [%d]",result);
-       }
+               NFC_ERR("net_nfc_server_llcp_simple_client failed, [%d]",result);
 
        return result;
 }
index 642bf7d..3d7eaae 100644 (file)
@@ -72,55 +72,16 @@ struct _NppClientStartData
 #define NPP_NDEF_ENTRY                 0x00000001
 #define NPP_ACTION_CODE                        0x01
 
-static net_nfc_error_e npp_create_message(data_s *data,
-               data_s *message);
-
-/* server */
-static void npp_server_receive_cb(net_nfc_error_e result,
-               net_nfc_target_handle_s *handle,
-               net_nfc_llcp_socket_t socket,
-               data_s *data,
-               gpointer user_data);
-
-static void npp_server_process(NppData *npp_data);
-
-static void npp_listen_cb(net_nfc_error_e result, net_nfc_target_handle_s *handle,
-               net_nfc_llcp_socket_t socket, data_s *data, gpointer user_data);
-
-/* client */
-static void npp_client_disconnected_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result, data_s *data, void *extra, void *user_param);
-
-static void npp_client_send_cb(net_nfc_error_e result,
-               net_nfc_target_handle_s *handle,
-               net_nfc_llcp_socket_t socket,
-               data_s *data,
-               gpointer user_data);
-
-static void npp_client_process(NppData *npp_data);
-
-static void npp_connected_cb(net_nfc_error_e result,
-               net_nfc_target_handle_s *handle,
-               net_nfc_llcp_socket_t socket,
-               data_s *data,
-               gpointer user_data);
-
 static void npp_socket_error_cb(net_nfc_error_e result,
                net_nfc_target_handle_s *handle,
                net_nfc_llcp_socket_t socket,
                data_s *data,
                gpointer user_data);
 
-static void npp_default_server_cb(net_nfc_error_e result, data_s *data,
-               gpointer user_data);
-
-static void npp_default_client_cb(net_nfc_error_e result, data_s *data,
-               gpointer user_data);
-
 static net_nfc_error_e npp_create_message(data_s *data, data_s *message)
 {
-       uint32_t length = NPP_HEADER_LEN;
        net_nfc_npp_msg_t *msg;
+       uint32_t length = NPP_HEADER_LEN;
 
        if (data != NULL)
                length += NPP_ENTITY_HEADER_LEN + data->length;
@@ -160,21 +121,17 @@ static void npp_server_receive_cb(net_nfc_error_e result,
                data_s *data,
                gpointer user_data)
 {
+       uint32_t i;
+       uint32_t length;
        NppData *npp_data;
-
+       uint32_t entity_count;
        net_nfc_npp_msg_t *message;
        net_nfc_npp_entity_t *entity;
-
        data_s ndef_msg = { NULL, 0 };
 
-       uint32_t length;
-       uint32_t entity_count;
-       uint32_t i;
+       RET_IF(NULL == user_data);
 
-       npp_data = (NppData *)user_data;
-
-       if (npp_data == NULL)
-               return;
+       npp_data = user_data;
 
        if (result != NET_NFC_OK)
        {
@@ -187,31 +144,23 @@ static void npp_server_receive_cb(net_nfc_error_e result,
                return;
        }
 
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("data is NULL");
 
                if(npp_data->callback)
-               {
-                       npp_data->callback(NET_NFC_INVALID_PARAM,
-                                       NULL,
-                                       npp_data->user_data);
-               }
+                       npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
 
                g_free(npp_data);
                return;
        }
 
-       if (data->buffer == NULL || data->length == 0)
+       if (NULL == data->buffer || 0 == data->length)
        {
                NFC_ERR("Wrong data");
 
                if(npp_data->callback)
-               {
-                       npp_data->callback(NET_NFC_INVALID_PARAM,
-                                       NULL,
-                                       npp_data->user_data);
-               }
+                       npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
 
                g_free(npp_data);
                return;
@@ -221,15 +170,10 @@ static void npp_server_receive_cb(net_nfc_error_e result,
 
        if (data->length < NPP_HEADER_LEN)
        {
-               NFC_ERR("too short data, length [%d]",
-                               data->length);
+               NFC_ERR("too short data, length [%d]", data->length);
                /* FIXME!!! what should I do. */
                if(npp_data->callback)
-               {
-                       npp_data->callback(NET_NFC_INVALID_PARAM,
-                                       NULL,
-                                       npp_data->user_data);
-               }
+                       npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
 
                g_free(npp_data);
                return;
@@ -238,15 +182,10 @@ static void npp_server_receive_cb(net_nfc_error_e result,
        if (GET_MAJOR_VER(message->version) > NPP_MAJOR_VER ||
                        GET_MINOR_VER(message->version > NPP_MINOR_VER))
        {
-               NFC_ERR("not supported version, version [0x%02x]",
-                               message->version);
+               NFC_ERR("not supported version, version [0x%02x]", message->version);
 
                if(npp_data->callback)
-               {
-                       npp_data->callback(NET_NFC_NOT_SUPPORTED,
-                                       NULL,
-                                       npp_data->user_data);
-               }
+                       npp_data->callback(NET_NFC_NOT_SUPPORTED, NULL, npp_data->user_data);
 
                g_free(npp_data);
                return;
@@ -256,15 +195,10 @@ static void npp_server_receive_cb(net_nfc_error_e result,
 
        if (entity_count > NPP_NDEF_ENTRY)
        {
-               NFC_ERR("too many entities, [%d]",
-                               message->entity_count);
+               NFC_ERR("too many entities, [%d]", message->entity_count);
 
                if(npp_data->callback)
-               {
-                       npp_data->callback(NET_NFC_INVALID_PARAM,
-                                       NULL,
-                                       npp_data->user_data);
-               }
+                       npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
 
                g_free(npp_data);
                return;
@@ -274,16 +208,12 @@ static void npp_server_receive_cb(net_nfc_error_e result,
        {
                entity = (message->entity + i);
 
-               if (entity->op != NPP_ACTION_CODE) {
-                       NFC_ERR("not supported action code, [0x%02x]",
-                                       entity->op);
+               if (entity->op != NPP_ACTION_CODE)
+               {
+                       NFC_ERR("not supported action code, [0x%02x]", entity->op);
 
                        if(npp_data->callback)
-                       {
-                               npp_data->callback(NET_NFC_INVALID_PARAM,
-                                               NULL,
-                                               npp_data->user_data);
-                       }
+                               npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
 
                        g_free(npp_data);
                        return;
@@ -314,14 +244,12 @@ static void npp_server_receive_cb(net_nfc_error_e result,
 static void npp_server_process(NppData *npp_data)
 {
        net_nfc_error_e result;
-       if (npp_data == NULL)
-               return;
+
+       RET_IF(NULL == npp_data);
 
        /* receive request */
-       result = net_nfc_server_llcp_simple_receive(npp_data->handle,
-                       npp_data->socket,
-                       npp_server_receive_cb,
-                       npp_data);
+       result = net_nfc_server_llcp_simple_receive(npp_data->handle, npp_data->socket,
+                       npp_server_receive_cb, npp_data);
        if (result != NET_NFC_OK)
        {
                if (npp_data->callback)
@@ -337,9 +265,9 @@ static void npp_listen_cb(net_nfc_error_e result, net_nfc_target_handle_s *handl
        NppData *npp_data;
        NppData *accept_data;
 
-       npp_data = (NppData *)user_data;
-       if (npp_data == NULL)
-               return;
+       RET_IF(NULL == user_data);
+
+       npp_data = user_data;
 
        NFC_DBG("npp_listen_cb, incoming socket [%#x], result [%d]", socket, result);
 
@@ -362,14 +290,11 @@ static void npp_listen_cb(net_nfc_error_e result, net_nfc_target_handle_s *handl
        accept_data->callback = npp_data->callback;
        accept_data->user_data = npp_data->user_data;
 
-       result = net_nfc_server_llcp_simple_accept(handle,
-                       socket,
-                       npp_socket_error_cb,
+       result = net_nfc_server_llcp_simple_accept(handle, socket, npp_socket_error_cb,
                        accept_data);
        if (result != NET_NFC_OK)
        {
-               NFC_ERR("%s failed",
-                               "net_nfc_server_llcp_simple_accept");
+               NFC_ERR("%s failed net_nfc_server_llcp_simple_accept");
 
                if (npp_data->callback)
                        npp_data->callback(result, NULL, npp_data->user_data);
@@ -388,10 +313,7 @@ static void npp_listen_cb(net_nfc_error_e result, net_nfc_target_handle_s *handl
 
 /* client */
 static void npp_client_disconnected_cb(net_nfc_llcp_socket_t socket,
-               net_nfc_error_e result,
-               data_s *data,
-               void *extra,
-               void *user_param)
+               net_nfc_error_e result, data_s *data, void *extra, void *user_param)
 {
        NFC_INFO("disconnected! [%d]", result);
 }
@@ -404,22 +326,17 @@ static void npp_client_send_cb(net_nfc_error_e result,
 {
        NppData *npp_data;
 
-       npp_data = (NppData *)user_data;
-       if (npp_data == NULL)
-               return;
+       RET_IF(NULL == user_data);
+
+       npp_data = user_data;
 
        NFC_DBG("send complete... [%d]", result);
 
        if (npp_data->callback)
-       {
                npp_data->callback(result, NULL, npp_data->user_data);
-       }
 
-       net_nfc_controller_llcp_disconnect(npp_data->handle,
-                       npp_data->socket,
-                       &result,
-                       npp_client_disconnected_cb,
-                       NULL);
+       net_nfc_controller_llcp_disconnect(npp_data->handle, npp_data->socket,
+                       &result, npp_client_disconnected_cb, NULL);
 
        g_free(npp_data->data.buffer);
        g_free(npp_data);
@@ -428,11 +345,10 @@ static void npp_client_send_cb(net_nfc_error_e result,
 
 static void npp_client_process(NppData *npp_data)
 {
-       net_nfc_error_e result;
        data_s data;
+       net_nfc_error_e result;
 
-       if (npp_data == NULL)
-               return;
+       RET_IF(NULL == npp_data);
 
        result = npp_create_message(&npp_data->data, &data);
        if (result != NET_NFC_OK)
@@ -449,16 +365,11 @@ static void npp_client_process(NppData *npp_data)
        }
 
        /* send request */
-       result = net_nfc_server_llcp_simple_send(npp_data->handle,
-                       npp_data->socket,
-                       &data,
-                       npp_client_send_cb,
-                       npp_data);
+       result = net_nfc_server_llcp_simple_send(npp_data->handle, npp_data->socket,
+                       &data, npp_client_send_cb, npp_data);
        if (result != NET_NFC_OK)
        {
-               NFC_ERR("%s failed [%d]",
-                               "net_nfc_server_llcp_simple_send",
-                               result);
+               NFC_ERR("%s failed [%d] net_nfc_server_llcp_simple_send", result);
 
                if (npp_data->callback)
                        npp_data->callback(result, NULL, npp_data->user_data);
@@ -479,9 +390,9 @@ static void npp_connected_cb(net_nfc_error_e result,
 {
        NppData *npp_data;
 
-       npp_data = (NppData *)user_data;
-       if (npp_data == NULL)
-               return;
+       RET_IF(NULL == user_data);
+
+       npp_data = user_data;
 
        if (result != NET_NFC_OK)
        {
@@ -514,9 +425,8 @@ static void npp_socket_error_cb(net_nfc_error_e result,
 
        NFC_DBG("socket [%x], result [%d]", socket, result);
 
-       npp_data = (NppData *)user_data;
-       if (npp_data == NULL)
-               return;
+       RET_IF(NULL == user_data);
+       npp_data = user_data;
 
        if (npp_data->callback)
                npp_data->callback(result, NULL, npp_data->user_data);
@@ -525,23 +435,13 @@ static void npp_socket_error_cb(net_nfc_error_e result,
        g_free(npp_data);
 }
 
-static void npp_default_server_cb(net_nfc_error_e result,
-               data_s *data,
+static void npp_default_server_cb(net_nfc_error_e result, data_s *data,
                gpointer user_data)
 {
        NFC_DBG("result [%d], data [%p], user_data [%p]", result, data, user_data);
 
-       if (data == NULL)
-       {
-               NFC_ERR("npp server receive failed, [%d]", result);
-               return;
-       }
-
-       if (data->buffer == NULL)
-       {
-               NFC_ERR("npp server receive failed, [%d]", result);
-               return;
-       }
+       RET_IF(NULL == data);
+       RET_IF(NULL == data->buffer);
 
        net_nfc_server_p2p_received(data);
        net_nfc_app_util_process_ndef(data);
@@ -555,10 +455,9 @@ static void npp_default_client_cb(net_nfc_error_e result,
 
        NFC_DBG("result [%d], data [%p], user_data [%p]", result, data, user_data);
 
-       if (user_data == NULL)
-               return;
+       RET_IF(NULL == user_data);
 
-       npp_client_data = (NppClientStartData *)user_data;
+       npp_client_data = user_data;
 
        net_nfc_server_p2p_data_sent(result, npp_client_data->user_data);
 
@@ -569,21 +468,11 @@ static void npp_default_client_cb(net_nfc_error_e result,
 net_nfc_error_e net_nfc_server_npp_server(net_nfc_target_handle_s *handle,
                char *san, sap_t sap, net_nfc_server_npp_callback callback, gpointer user_data)
 {
-       net_nfc_error_e result = NET_NFC_OK;
-
        NppData *npp_data = NULL;
+       net_nfc_error_e result = NET_NFC_OK;
 
-       if (handle == NULL)
-       {
-               NFC_ERR("handle is NULL");
-               return FALSE;
-       }
-
-       if (san == NULL)
-       {
-               NFC_ERR("san is NULL");
-               return FALSE;
-       }
+       RETV_IF(NULL == san, FALSE);
+       RETV_IF(NULL == handle, FALSE);
 
        npp_data = g_new0(NppData, 1);
 
@@ -591,16 +480,11 @@ net_nfc_error_e net_nfc_server_npp_server(net_nfc_target_handle_s *handle,
        npp_data->callback = callback;
        npp_data->user_data = user_data;
 
-       result = net_nfc_server_llcp_simple_server(handle,
-                       san,
-                       sap,
-                       npp_listen_cb,
-                       npp_socket_error_cb,
-                       npp_data);
+       result = net_nfc_server_llcp_simple_server(handle, san, sap, npp_listen_cb,
+                       npp_socket_error_cb, npp_data);
        if (result != NET_NFC_OK)
        {
-               NFC_ERR("%s failed",
-                               "net_nfc_server_llcp_simple_server");
+               NFC_ERR("net_nfc_server_llcp_simple_server failed");
 
                if (npp_data->callback)
                        npp_data->callback(result, NULL, npp_data->user_data);
@@ -622,34 +506,22 @@ net_nfc_error_e net_nfc_server_npp_client(net_nfc_target_handle_s *handle,
                net_nfc_server_npp_callback callback,
                gpointer user_data)
 {
-       net_nfc_error_e result = NET_NFC_OK;;
-       net_nfc_llcp_config_info_s config;
-
        NppData *npp_data;
+       net_nfc_llcp_config_info_s config;
+       net_nfc_error_e result = NET_NFC_OK;;
 
-       if (handle == NULL)
-       {
-               NFC_ERR("handle is NULL");
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
 
-       if(net_nfc_controller_llcp_get_remote_config(handle,
-                               &config,
-                               &result) == false)
+       if(net_nfc_controller_llcp_get_remote_config(handle, &config, &result) == false)
        {
-               NFC_ERR("%s failed [%d]",
-                               "net_nfc_controller_llcp_get_remote_config",
-                               result);
-
+               NFC_ERR("net_nfc_controller_llcp_get_remote_config failed [%d]", result);
                return result;
        }
 
-       if (config.miu <
-                       data->length + NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN)
+       if (config.miu < data->length + NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN)
        {
                NFC_ERR("too large message, max [%d], request [%d]",
-                               config.miu - (NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN),
-                               data->length);
+                               config.miu - (NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN), data->length);
 
                return NET_NFC_INSUFFICIENT_STORAGE;
        }
@@ -663,23 +535,14 @@ net_nfc_error_e net_nfc_server_npp_client(net_nfc_target_handle_s *handle,
        npp_data->data.buffer = g_new0(uint8_t, data->length);
        npp_data->data.length = data->length;
 
-       result = net_nfc_server_llcp_simple_client(handle,
-                       san,
-                       sap,
-                       npp_connected_cb,
-                       npp_socket_error_cb,
-                       npp_data);
+       result = net_nfc_server_llcp_simple_client(handle, san, sap,
+                       npp_connected_cb, npp_socket_error_cb, npp_data);
        if (result != NET_NFC_OK)
        {
-               NFC_ERR("%s failed",
-                               "net_nfc_server_llcp_simple_client");
+               NFC_ERR("net_nfc_server_llcp_simple_client failed");
 
                if (npp_data->callback)
-               {
-                       npp_data->callback(NET_NFC_UNKNOWN_ERROR,
-                                       NULL,
-                                       npp_data->user_data);
-               }
+                       npp_data->callback(NET_NFC_UNKNOWN_ERROR, NULL, npp_data->user_data);
 
                g_free(npp_data->data.buffer);
                g_free(npp_data);
@@ -699,10 +562,7 @@ net_nfc_error_e net_nfc_server_npp_default_server_start(
                net_nfc_target_handle_s *handle)
 {
        /* start default npp server */
-       return net_nfc_server_npp_server(handle,
-                       NPP_SAN,
-                       NPP_SAP,
-                       npp_default_server_cb,
+       return net_nfc_server_npp_server(handle, NPP_SAN, NPP_SAP, npp_default_server_cb,
                        (gpointer)1234);
 }
 
@@ -717,11 +577,12 @@ static void _npp_default_activate_cb(int event, net_nfc_target_handle_s *handle,
                /* start default npp server */
                result = net_nfc_server_npp_server(handle, (char *)san, sap,
                                npp_default_server_cb, user_param);
-               if (result != NET_NFC_OK) {
-                       NFC_ERR("net_nfc_server_npp_server failed, [%d]",
-                                       result);
-               }
-       } else if (event == NET_NFC_LLCP_UNREGISTERED) {
+               if (result != NET_NFC_OK)
+                       NFC_ERR("net_nfc_server_npp_server failed, [%d]", result);
+
+       }
+       else if (event == NET_NFC_LLCP_UNREGISTERED)
+       {
                /* unregister server, do nothing */
        }
 }
@@ -734,11 +595,8 @@ net_nfc_error_e net_nfc_server_npp_default_server_register()
        snprintf(id, sizeof(id), "%d", getpid());
 
        /* start default npp server */
-       return net_nfc_server_llcp_register_service(id,
-                       NPP_SAP,
-                       NPP_SAN,
-                       _npp_default_activate_cb,
-                       NULL);
+       return net_nfc_server_llcp_register_service(id, NPP_SAP, NPP_SAN,
+                       _npp_default_activate_cb, NULL);
 }
 
 net_nfc_error_e net_nfc_server_npp_default_server_unregister()
@@ -749,35 +607,18 @@ net_nfc_error_e net_nfc_server_npp_default_server_unregister()
        snprintf(id, sizeof(id), "%d", getpid());
 
        /* start default npp server */
-       return net_nfc_server_llcp_unregister_service(id,
-                       NPP_SAP,
-                       NPP_SAN);
+       return net_nfc_server_llcp_unregister_service(id, NPP_SAP, NPP_SAN);
 }
 
 net_nfc_error_e net_nfc_server_npp_default_client_start(
                net_nfc_target_handle_s *handle, data_s *data, int client, gpointer user_data)
 {
-       NppClientStartData *npp_client_data;
-
        net_nfc_error_e result = NET_NFC_OK;
+       NppClientStartData *npp_client_data;
 
-       if (handle == NULL)
-       {
-               NFC_ERR("handle is NULL");
-               return NET_NFC_NULL_PARAMETER;
-       }
-
-       if (data == NULL)
-       {
-               NFC_ERR("data is NULL");
-               return NET_NFC_NULL_PARAMETER;
-       }
-
-       if (data->buffer == NULL)
-       {
-               NFC_ERR("data->buffer is NULL");
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == data->buffer, NET_NFC_NULL_PARAMETER);
 
        npp_client_data = g_new0(NppClientStartData, 1);
 
@@ -785,12 +626,8 @@ net_nfc_error_e net_nfc_server_npp_default_client_start(
        npp_client_data->client = client;
        npp_client_data->user_data = user_data;
 
-       result = net_nfc_server_npp_client(handle,
-                       NPP_SAN,
-                       NPP_SAP,
-                       data,
-                       npp_default_client_cb,
-                       npp_client_data);
+       result = net_nfc_server_npp_client(handle, NPP_SAN, NPP_SAP, data,
+                       npp_default_client_cb, npp_client_data);
 
        if (result != NET_NFC_OK)
        {
index 3cf3918..d16fb45 100644 (file)
@@ -116,50 +116,6 @@ struct _ChangeCardEmulMode
        gint mode;
 };
 
-static void se_close_secure_element_thread_func(gpointer user_data);
-
-static void se_get_atr_thread_func(gpointer user_data);
-
-static void se_open_secure_element_thread_func(gpointer user_data);
-
-static void se_send_apdu_thread_func(gpointer user_data);
-
-static void se_set_data_thread_func(gpointer user_data);
-
-static gboolean se_handle_close_secure_element(
-               NetNfcGDbusSecureElement *object,
-               GDBusMethodInvocation *invocation,
-               guint arg_handle,
-               GVariant *smack_privilege);
-
-static gboolean se_handle_get_atr(
-               NetNfcGDbusSecureElement *object,
-               GDBusMethodInvocation *invocation,
-               guint arg_handle,
-               GVariant *smack_privilege);
-
-
-static gboolean se_handle_open_secure_element(
-               NetNfcGDbusSecureElement *object,
-               GDBusMethodInvocation *invocation,
-               gint arg_type,
-               GVariant *smack_privilege);
-
-
-static gboolean se_handle_send_apdu(
-               NetNfcGDbusSecureElement *object,
-               GDBusMethodInvocation *invocation,
-               guint arg_handle,
-               GVariant* apdudata,
-               GVariant *smack_privilege);
-
-static gboolean se_handle_set(
-               NetNfcGDbusSecureElement *object,
-               GDBusMethodInvocation *invocation,
-               gint arg_type,
-               GVariant *smack_privilege);
-
-
 uint8_t net_nfc_server_se_get_se_type()
 {
        return gdbus_se_setting.type;
@@ -201,13 +157,16 @@ static void net_nfc_server_se_set_current_ese_handle(
 
 static net_nfc_target_handle_s *net_nfc_server_se_open_ese()
 {
-       if (gdbus_ese_handle == NULL) {
+       bool ret;
+
+       if (NULL == gdbus_ese_handle)
+       {
                net_nfc_error_e result = NET_NFC_OK;
                net_nfc_target_handle_s *handle = NULL;
 
-               if (net_nfc_controller_secure_element_open(
-                                       SECURE_ELEMENT_TYPE_ESE,
-                                       &handle, &result) == true)
+               ret = net_nfc_controller_secure_element_open(SECURE_ELEMENT_TYPE_ESE,
+                                       &handle, &result);
+               if (true == ret)
                {
                        net_nfc_server_se_set_current_ese_handle(handle);
 
@@ -215,8 +174,7 @@ static net_nfc_target_handle_s *net_nfc_server_se_open_ese()
                }
                else
                {
-                       NFC_ERR("net_nfc_controller_secure_element_open failed [%d]",
-                                       result);
+                       NFC_ERR("net_nfc_controller_secure_element_open failed [%d]", result);
                }
        }
 
@@ -227,16 +185,13 @@ static net_nfc_error_e net_nfc_server_se_close_ese()
 {
        net_nfc_error_e result = NET_NFC_OK;
 
-       if (gdbus_ese_handle != NULL &&
-                       net_nfc_server_gdbus_is_server_busy() == false) {
-               if (net_nfc_controller_secure_element_close(
-                                       gdbus_ese_handle,
-                                       &result) == false)
-               {
+       if (gdbus_ese_handle != NULL && net_nfc_server_gdbus_is_server_busy() == false)
+       {
+               if (net_nfc_controller_secure_element_close(gdbus_ese_handle, &result) == false)
                        net_nfc_controller_exception_handler();
-               }
+
                net_nfc_server_se_set_current_ese_handle(NULL);
-       }
+        }
 
        return result;
 }
@@ -246,29 +201,26 @@ static void _se_uicc_enable_card_emulation()
        net_nfc_error_e result;
 
        /*turn off ESE*/
-       net_nfc_controller_set_secure_element_mode(
-                       SECURE_ELEMENT_TYPE_ESE,
-                       SECURE_ELEMENT_OFF_MODE,
-                       &result);
+       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+                       SECURE_ELEMENT_OFF_MODE, &result);
 
        /*turn on UICC*/
-       net_nfc_controller_set_secure_element_mode(
-                       SECURE_ELEMENT_TYPE_UICC,
-                       SECURE_ELEMENT_VIRTUAL_MODE,
-                       &result);
-       if (result == NET_NFC_OK) {
+       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                       SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+       if (NET_NFC_OK == result)
+       {
                NFC_INFO("card emulation changed to SECURE_ELEMENT_TYPE_UICC");
 
                net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
                net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
 
-               if (vconf_set_int(VCONFKEY_NFC_SE_TYPE,
-                                       VCONFKEY_NFC_SE_TYPE_UICC) < 0) {
+               if (vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_TYPE_UICC) < 0)
                        NFC_ERR("vconf_set_int failed");
-               }
-       } else {
-               NFC_ERR("net_nfc_controller_set_secure_element_mode failed, [%d]",
-                               result);
+       }
+       else
+       {
+               NFC_ERR("net_nfc_controller_set_secure_element_mode failed, [%d]", result);
        }
 }
 
@@ -277,35 +229,36 @@ static void _se_uicc_prepare(void)
        char **cpList;
 
        cpList = tel_get_cp_name_list();
-       if (cpList != NULL) {
+       if (cpList != NULL)
+       {
                gdbus_uicc_handle = tel_init(cpList[0]);
-               if (gdbus_uicc_handle != NULL) {
-               } else {
+               if (NULL == gdbus_uicc_handle)
                        NFC_ERR("tel_init() failed");
-               }
-       } else {
+
+       }
+       else
+       {
                NFC_ERR("tel_get_cp_name_list() failed");
        }
 }
 
 static void _se_uicc_status_noti_cb(TapiHandle *handle,
-               const char *noti_id,
-               void *data,
-               void *user_data)
+               const char *noti_id, void *data, void *user_data)
 {
-       TelSimCardStatus_t *status = (TelSimCardStatus_t *)data;
+       TelSimCardStatus_t *status = data;
 
        NFC_DBG("_se_uicc_status_noti_cb");
 
-       switch (*status) {
+       switch (*status)
+       {
        case TAPI_SIM_STATUS_SIM_INIT_COMPLETED :
                gdbus_uicc_ready = SE_UICC_READY;
 
                _se_uicc_prepare();
 
                if (gdbus_se_setting.busy == true &&
-                               net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC) {
-
+                               net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC)
+               {
                        gdbus_se_setting.busy = false;
 
                        _se_uicc_enable_card_emulation();
@@ -316,14 +269,13 @@ static void _se_uicc_status_noti_cb(TapiHandle *handle,
                NFC_DBG("TAPI_SIM_STATUS_CARD_REMOVED");
                gdbus_uicc_ready = SE_UICC_UNAVAILABLE;
 
-               if (net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC) {
+               if (net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC)
+               {
                        net_nfc_error_e result;
 
                        /*turn off UICC*/
-                       net_nfc_controller_set_secure_element_mode(
-                                       SECURE_ELEMENT_TYPE_UICC,
-                                       SECURE_ELEMENT_OFF_MODE,
-                                       &result);
+                       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                                       SECURE_ELEMENT_OFF_MODE, &result);
 
                        net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_INVALID);
                        net_nfc_server_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
@@ -338,17 +290,15 @@ static void _se_uicc_status_noti_cb(TapiHandle *handle,
 static void _se_uicc_init(void)
 {
        _se_uicc_prepare();
-       tel_register_noti_event(gdbus_uicc_handle,
-                       TAPI_NOTI_SIM_STATUS,
-                       _se_uicc_status_noti_cb,
-                       NULL);
+       tel_register_noti_event(gdbus_uicc_handle, TAPI_NOTI_SIM_STATUS,
+                       _se_uicc_status_noti_cb, NULL);
 }
 
 static void _se_uicc_deinit()
 {
-       if (gdbus_uicc_handle != NULL) {
-               tel_deregister_noti_event(gdbus_uicc_handle,
-                               TAPI_NOTI_SIM_STATUS);
+       if (gdbus_uicc_handle != NULL)
+       {
+               tel_deregister_noti_event(gdbus_uicc_handle, TAPI_NOTI_SIM_STATUS);
 
                tel_deinit(gdbus_uicc_handle);
 
@@ -360,17 +310,15 @@ static net_nfc_target_handle_s* _se_uicc_open()
 {
        net_nfc_target_handle_s *result = NULL;
 
-       if (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL) {
+       if (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL)
                result = (net_nfc_target_handle_s *)gdbus_uicc_handle;
-       }
 
        return result;
 }
 
 static bool _se_is_uicc_handle(net_nfc_target_handle_s *handle)
 {
-       return (gdbus_uicc_ready == SE_UICC_READY &&
-                       gdbus_uicc_handle != NULL &&
+       return (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL &&
                        (TapiHandle *)handle == gdbus_uicc_handle);
 }
 
@@ -387,16 +335,12 @@ net_nfc_error_e net_nfc_server_se_disable_card_emulation()
        net_nfc_server_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
 
        /*turn off ESE*/
-       net_nfc_controller_set_secure_element_mode(
-                       SECURE_ELEMENT_TYPE_ESE,
-                       SECURE_ELEMENT_OFF_MODE,
-                       &result);
+       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+                       SECURE_ELEMENT_OFF_MODE, &result);
 
        /*turn off UICC*/
-       net_nfc_controller_set_secure_element_mode(
-                       SECURE_ELEMENT_TYPE_UICC,
-                       SECURE_ELEMENT_OFF_MODE,
-                       &result);
+       net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                       SECURE_ELEMENT_OFF_MODE, &result);
 
        return NET_NFC_OK;
 }
@@ -405,22 +349,31 @@ net_nfc_error_e net_nfc_server_se_change_se(uint8_t type)
 {
        net_nfc_error_e result = NET_NFC_OK;
 
-       switch (type) {
+       switch (type)
+       {
        case SECURE_ELEMENT_TYPE_UICC :
-               if (gdbus_se_setting.busy == false) {
-                       if (gdbus_uicc_ready == SE_UICC_READY) {
+               if (false == gdbus_se_setting.busy)
+               {
+                       if (SE_UICC_READY == gdbus_uicc_ready)
+                       {
                                _se_uicc_enable_card_emulation();
-                       } else if (gdbus_uicc_ready == SE_UICC_ON_PROGRESS) {
+                       }
+                       else if (SE_UICC_ON_PROGRESS == gdbus_uicc_ready)
+                       {
                                NFC_INFO("waiting for uicc initializing complete...");
 
                                net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
                                net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
 
                                gdbus_se_setting.busy = true;
-                       } else {
+                       }
+                       else
+                       {
                                result = NET_NFC_NOT_SUPPORTED;
                        }
-               } else {
+               }
+               else
+               {
                        NFC_DBG("Previous request is processing.");
 
                        result = NET_NFC_BUSY;
@@ -429,41 +382,37 @@ net_nfc_error_e net_nfc_server_se_change_se(uint8_t type)
 
        case SECURE_ELEMENT_TYPE_ESE :
                /*turn off UICC*/
-               net_nfc_controller_set_secure_element_mode(
-                               SECURE_ELEMENT_TYPE_UICC,
-                               SECURE_ELEMENT_OFF_MODE,
-                               &result);
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+                               SECURE_ELEMENT_OFF_MODE, &result);
 
                /*turn on ESE*/
-               net_nfc_controller_set_secure_element_mode(
-                               SECURE_ELEMENT_TYPE_ESE,
-                               SECURE_ELEMENT_VIRTUAL_MODE,
-                               &result);
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+                               SECURE_ELEMENT_VIRTUAL_MODE, &result);
 
-               if (result == NET_NFC_OK) {
+               if (NET_NFC_OK == result)
+               {
                        NFC_INFO("card emulation changed to SECURE_ELEMENT_TYPE_ESE");
 
                        net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_ESE);
                        net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
 
-                       if (vconf_set_int(VCONFKEY_NFC_SE_TYPE,
-                                               VCONFKEY_NFC_SE_TYPE_ESE) != 0) {
+                       if (vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_TYPE_ESE) != 0)
                                NFC_ERR("vconf_set_int failed");
-                       }
-               } else {
+               }
+               else
+               {
                        NFC_ERR("net_nfc_controller_set_secure_element_mode failed, [%d]", result);
                }
                break;
 
        default:
                result = net_nfc_server_se_disable_card_emulation();
-               if (result == NET_NFC_OK){
+               if (NET_NFC_OK == result)
+               {
                        NFC_INFO("card emulation turned off");
 
-                       if (vconf_set_int(VCONFKEY_NFC_SE_TYPE,
-                                               VCONFKEY_NFC_SE_TYPE_NONE) != 0) {
+                       if (vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_TYPE_NONE) != 0)
                                NFC_ERR("vconf_set_int failed");
-                       }
                }
                break;
        }
@@ -473,8 +422,8 @@ net_nfc_error_e net_nfc_server_se_change_se(uint8_t type)
 
 static void se_close_secure_element_thread_func(gpointer user_data)
 {
-       SeDataHandle *detail = (SeDataHandle *)user_data;
        net_nfc_error_e result;
+       SeDataHandle *detail = user_data;
 
        g_assert(detail != NULL);
        g_assert(detail->object != NULL);
@@ -490,8 +439,7 @@ static void se_close_secure_element_thread_func(gpointer user_data)
        {
                /* decrease client reference count */
                net_nfc_server_gdbus_decrease_se_count(
-                               g_dbus_method_invocation_get_sender(
-                                       detail->invocation));
+                               g_dbus_method_invocation_get_sender(detail->invocation));
 
                result = net_nfc_server_se_close_ese();
        }
@@ -521,7 +469,8 @@ static void se_close_secure_element_thread_func(gpointer user_data)
 
        /* shutdown process if it doesn't need */
        if (net_nfc_server_manager_get_active() == false &&
-                       net_nfc_server_gdbus_is_server_busy() == false) {
+                       net_nfc_server_gdbus_is_server_busy() == false)
+       {
                net_nfc_server_controller_deinit();
        }
 }
@@ -532,29 +481,28 @@ static gboolean se_handle_close_secure_element(
                guint arg_handle,
                GVariant *smack_privilege)
 {
-       SeDataHandle *data;
+       bool ret;
        gboolean result;
+       SeDataHandle *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(SeDataHandle, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -565,7 +513,7 @@ static gboolean se_handle_close_secure_element(
 
        result = net_nfc_server_controller_async_queue_push(
                        se_close_secure_element_thread_func, data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -582,10 +530,10 @@ static gboolean se_handle_close_secure_element(
 
 static void se_get_atr_thread_func(gpointer user_data)
 {
-       SeDataHandle *detail = (SeDataHandle *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
-       data_s *atr = NULL;
        GVariant *data;
+       data_s *atr = NULL;
+       SeDataHandle *detail = user_data;
+       net_nfc_error_e result = NET_NFC_OK;
 
        g_assert(detail != NULL);
        g_assert(detail->object != NULL);
@@ -597,8 +545,7 @@ static void se_get_atr_thread_func(gpointer user_data)
        }
        else if (net_nfc_server_se_is_ese_handle(detail->handle) == true)
        {
-               net_nfc_controller_secure_element_get_atr(detail->handle, &atr,
-                               &result);
+               net_nfc_controller_secure_element_get_atr(detail->handle, &atr, &result);
        }
        else
        {
@@ -609,13 +556,11 @@ static void se_get_atr_thread_func(gpointer user_data)
 
        data = net_nfc_util_gdbus_data_to_variant(atr);
 
-       net_nfc_gdbus_secure_element_complete_get_atr(
-                       detail->object,
-                       detail->invocation,
-                       result,
-                       data);
+       net_nfc_gdbus_secure_element_complete_get_atr(detail->object, detail->invocation,
+                       result, data);
 
-       if (atr != NULL) {
+       if (atr != NULL)
+       {
                net_nfc_util_free_data(atr);
                g_free(atr);
        }
@@ -632,29 +577,28 @@ static gboolean se_handle_get_atr(
                guint arg_handle,
                GVariant *smack_privilege)
 {
-       SeDataHandle *data;
+       bool ret;
        gboolean result;
+       SeDataHandle *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "r");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(SeDataHandle, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -663,9 +607,8 @@ static gboolean se_handle_get_atr(
        data->invocation = g_object_ref(invocation);
        data->handle = GUINT_TO_POINTER(arg_handle);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       se_get_atr_thread_func, data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(se_get_atr_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -682,9 +625,9 @@ static gboolean se_handle_get_atr(
 
 static void se_open_secure_element_thread_func(gpointer user_data)
 {
-       SeDataSeType *detail = (SeDataSeType *)user_data;
-       net_nfc_target_handle_s *handle = NULL;
+       SeDataSeType *detail = user_data;
        net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_target_handle_s *handle = NULL;
 
        g_assert(detail != NULL);
        g_assert(detail->object != NULL);
@@ -699,8 +642,7 @@ static void se_open_secure_element_thread_func(gpointer user_data)
        {
 #if 0 /* opening SE doesn't affect card emulation */
                /*off ESE*/
-               net_nfc_controller_set_secure_element_mode(
-                               SECURE_ELEMENT_TYPE_ESE,
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
                                SECURE_ELEMENT_OFF_MODE, &result);
 
                /*Off UICC. UICC SHOULD not be detected by external reader when
@@ -726,8 +668,7 @@ static void se_open_secure_element_thread_func(gpointer user_data)
        {
 #if 0 /* opening SE doesn't affect card emulation */
                /*off UICC*/
-               net_nfc_controller_set_secure_element_mode(
-                               SECURE_ELEMENT_TYPE_UICC,
+               net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
                                SECURE_ELEMENT_OFF_MODE, &result);
 #endif
                handle = net_nfc_server_se_open_ese();
@@ -744,8 +685,7 @@ static void se_open_secure_element_thread_func(gpointer user_data)
 
                        /* increase client reference count */
                        net_nfc_server_gdbus_increase_se_count(
-                                       g_dbus_method_invocation_get_sender(
-                                               detail->invocation));
+                                       g_dbus_method_invocation_get_sender(detail->invocation));
                }
                else
                {
@@ -759,11 +699,8 @@ static void se_open_secure_element_thread_func(gpointer user_data)
                handle = NULL;
        }
 
-       net_nfc_gdbus_secure_element_complete_open_secure_element(
-                       detail->object,
-                       detail->invocation,
-                       result,
-                       (guint)handle);
+       net_nfc_gdbus_secure_element_complete_open_secure_element(detail->object,
+                       detail->invocation, result, (guint)handle);
 
        g_object_unref(detail->invocation);
        g_object_unref(detail->object);
@@ -777,29 +714,28 @@ static gboolean se_handle_open_secure_element(
                gint arg_type,
                GVariant *smack_privilege)
 {
-       SeDataSeType *data;
+       bool ret;
        gboolean result;
+       SeDataSeType *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(SeDataSeType, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -810,7 +746,7 @@ static gboolean se_handle_open_secure_element(
 
        result = net_nfc_server_controller_async_queue_push(
                        se_open_secure_element_thread_func, data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -827,11 +763,11 @@ static gboolean se_handle_open_secure_element(
 
 static void se_send_apdu_thread_func(gpointer user_data)
 {
-       SeDataApdu *detail = (SeDataApdu *)user_data;
-       data_s apdu_data = { NULL, 0 };
        data_s *response = NULL;
-       net_nfc_error_e result = NET_NFC_OK;
        GVariant *rspdata = NULL;
+       SeDataApdu *detail = user_data;
+       data_s apdu_data = { NULL, 0 };
+       net_nfc_error_e result = NET_NFC_OK;
 
        g_assert(detail != NULL);
        g_assert(detail->object != NULL);
@@ -855,11 +791,8 @@ static void se_send_apdu_thread_func(gpointer user_data)
 
        rspdata = net_nfc_util_gdbus_data_to_variant(response);
 
-       net_nfc_gdbus_secure_element_complete_send_apdu(
-                       detail->object,
-                       detail->invocation,
-                       result,
-                       rspdata);
+       net_nfc_gdbus_secure_element_complete_send_apdu(detail->object, detail->invocation,
+                       result, rspdata);
 
        if (response != NULL)
        {
@@ -884,29 +817,28 @@ static gboolean se_handle_send_apdu(
                GVariant *apdudata,
                GVariant *smack_privilege)
 {
-       SeDataApdu *data;
+       bool ret;
        gboolean result;
+       SeDataApdu *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(SeDataApdu, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -916,9 +848,8 @@ static gboolean se_handle_send_apdu(
        data->handle = GUINT_TO_POINTER(arg_handle);
        data->data = g_variant_ref(apdudata);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       se_send_apdu_thread_func, data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(se_send_apdu_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -937,7 +868,7 @@ static gboolean se_handle_send_apdu(
 
 static void _se_set_card_emulation_thread_func(gpointer user_data)
 {
-       SeSetCardEmul *data = (SeSetCardEmul *)user_data;
+       SeSetCardEmul *data = user_data;
        net_nfc_error_e result = NET_NFC_OK;
 
        g_assert(data != NULL);
@@ -946,16 +877,14 @@ static void _se_set_card_emulation_thread_func(gpointer user_data)
 
        if (data->mode == NET_NFC_CARD_EMELATION_ENABLE)
        {
-               net_nfc_controller_set_secure_element_mode(
-                               net_nfc_server_se_get_se_mode(),
-                               SECURE_ELEMENT_VIRTUAL_MODE,
-                               &result);
-               if (result == NET_NFC_OK)
+               net_nfc_controller_set_secure_element_mode(net_nfc_server_se_get_se_mode(),
+                               SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+               if (NET_NFC_OK == result)
                {
                        NFC_DBG("changed to CARD EMULATION ON");
 
-                       net_nfc_server_se_set_se_mode(
-                                       SECURE_ELEMENT_VIRTUAL_MODE);
+                       net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
                }
                else
                {
@@ -964,11 +893,9 @@ static void _se_set_card_emulation_thread_func(gpointer user_data)
        }
        else if (data->mode == NET_NFC_CARD_EMULATION_DISABLE)
        {
-               net_nfc_controller_set_secure_element_mode(
-                               net_nfc_server_se_get_se_mode(),
-                               SECURE_ELEMENT_OFF_MODE,
-                               &result);
-               if (result == NET_NFC_OK)
+               net_nfc_controller_set_secure_element_mode(net_nfc_server_se_get_se_mode(),
+                               SECURE_ELEMENT_OFF_MODE, &result);
+               if (NET_NFC_OK == result)
                {
                        NFC_DBG("changed to CARD EMULATION OFF");
 
@@ -999,29 +926,28 @@ static gboolean _se_handle_set_card_emulation(
                gint arg_mode,
                GVariant *smack_privilege)
 {
-       SeSetCardEmul *data;
+       bool ret;
        gboolean result;
+       SeSetCardEmul *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(SeSetCardEmul, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1032,7 +958,7 @@ static gboolean _se_handle_set_card_emulation(
 
        result = net_nfc_server_controller_async_queue_push(
                        _se_set_card_emulation_thread_func, data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -1049,7 +975,7 @@ static gboolean _se_handle_set_card_emulation(
 
 static void se_set_data_thread_func(gpointer user_data)
 {
-       SeDataSeType *data = (SeDataSeType *)user_data;
+       SeDataSeType *data = user_data;
        gboolean isTypeChanged = FALSE;
        net_nfc_error_e result = NET_NFC_OK;
 
@@ -1063,12 +989,10 @@ static void se_set_data_thread_func(gpointer user_data)
                isTypeChanged = TRUE;
        }
 
-       net_nfc_gdbus_secure_element_complete_set(data->object,
-                       data->invocation, result);
+       net_nfc_gdbus_secure_element_complete_set(data->object, data->invocation, result);
 
        if (isTypeChanged)
-               net_nfc_gdbus_secure_element_emit_se_type_changed(data->object,
-                               data->se_type);
+               net_nfc_gdbus_secure_element_emit_se_type_changed(data->object, data->se_type);
 
        g_object_unref(data->invocation);
        g_object_unref(data->object);
@@ -1076,35 +1000,31 @@ static void se_set_data_thread_func(gpointer user_data)
        g_free(data);
 }
 
-static gboolean se_handle_set(
-               NetNfcGDbusSecureElement *object,
-               GDBusMethodInvocation *invocation,
-               gint arg_type,
-               GVariant *smack_privilege)
+static gboolean se_handle_set(NetNfcGDbusSecureElement *object,
+               GDBusMethodInvocation *invocation, gint arg_type, GVariant *smack_privilege)
 {
-       SeDataSeType *data;
+       bool ret;
        gboolean result;
+       SeDataSeType *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(SeDataSeType, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1113,9 +1033,9 @@ static gboolean se_handle_set(
        data->invocation = g_object_ref(invocation);
        data->se_type = arg_type;
 
-       result = net_nfc_server_controller_async_queue_push(
-                       se_set_data_thread_func, data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(se_set_data_thread_func, data);
+
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -1132,17 +1052,15 @@ static gboolean se_handle_set(
 
 static void se_get_data_thread_func(gpointer user_data)
 {
-       SeDataSeType *data = (SeDataSeType *)user_data;
+       SeDataSeType *data = user_data;
        net_nfc_error_e result = NET_NFC_OK;
 
        g_assert(data != NULL);
        g_assert(data->object != NULL);
        g_assert(data->invocation != NULL);
 
-       net_nfc_gdbus_secure_element_complete_get(data->object,
-                       data->invocation,
-                       net_nfc_server_se_get_se_type(),
-                       result);
+       net_nfc_gdbus_secure_element_complete_get(data->object, data->invocation,
+                       net_nfc_server_se_get_se_type(), result);
 
        g_object_unref(data->invocation);
        g_object_unref(data->object);
@@ -1150,34 +1068,31 @@ static void se_get_data_thread_func(gpointer user_data)
        g_free(data);
 }
 
-static gboolean se_handle_get(
-               NetNfcGDbusSecureElement *object,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege)
+static gboolean se_handle_get(NetNfcGDbusSecureElement *object,
+               GDBusMethodInvocation *invocation, GVariant *smack_privilege)
 {
-       SeDataSeType *data;
+       bool ret;
        gboolean result;
+       SeDataSeType *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "r");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(SeDataSeType, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -1185,9 +1100,8 @@ static gboolean se_handle_get(
        data->object = g_object_ref(object);
        data->invocation = g_object_ref(invocation);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       se_get_data_thread_func, data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(se_get_data_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -1204,10 +1118,10 @@ static gboolean se_handle_get(
 
 static void _se_change_card_emulation_mode_thread_func(gpointer user_data)
 {
-       ChangeCardEmulMode *data = (ChangeCardEmulMode *)user_data;
+       bool isChanged = false;
        net_nfc_error_e result = NET_NFC_OK;
        uint8_t current_mode, return_mode;
-       bool isChanged = false;
+       ChangeCardEmulMode *data = (ChangeCardEmulMode *)user_data;
 
        g_assert(data != NULL);
        g_assert(data->object != NULL);
@@ -1215,13 +1129,15 @@ static void _se_change_card_emulation_mode_thread_func(gpointer user_data)
 
        current_mode = net_nfc_server_se_get_se_mode();
 
-       if(data->mode == SECURE_ELEMENT_ACTIVE_STATE && current_mode == SECURE_ELEMENT_TYPE_INVALID)
+       if(data->mode == SECURE_ELEMENT_ACTIVE_STATE
+                       && current_mode == SECURE_ELEMENT_TYPE_INVALID)
        {
                return_mode = net_nfc_server_se_get_return_se_mode();
                result = net_nfc_server_se_change_se(return_mode);
                isChanged = true;
        }
-       else if(data->mode == SECURE_ELEMENT_INACTIVE_STATE && current_mode != SECURE_ELEMENT_TYPE_INVALID)
+       else if(data->mode == SECURE_ELEMENT_INACTIVE_STATE
+                       && current_mode != SECURE_ELEMENT_TYPE_INVALID)
        {
                result = net_nfc_server_se_disable_card_emulation();
                isChanged = true;
@@ -1232,7 +1148,8 @@ static void _se_change_card_emulation_mode_thread_func(gpointer user_data)
 
        if(isChanged)
        {
-               net_nfc_gdbus_secure_element_emit_card_emulation_mode_changed(data->object, data->mode);
+               net_nfc_gdbus_secure_element_emit_card_emulation_mode_changed(data->object,
+                       data->mode);
        }
 
        g_object_unref(data->invocation);
@@ -1248,24 +1165,24 @@ static gboolean se_handle_change_card_emulation_mode(
                gint arg_mode,
                GVariant *smack_privilege)
 {
-       SeSetCardEmul *data;
+       bool ret;
        gboolean result;
+       SeSetCardEmul *data;
 
-       NFC_DBG(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_DBG(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_try_new0(ChangeCardEmulMode, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
@@ -1281,7 +1198,7 @@ static gboolean se_handle_change_card_emulation_mode(
 
        result = net_nfc_server_controller_async_queue_push(
                        _se_change_card_emulation_mode_thread_func, data);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Se.ThreadError",
@@ -1298,8 +1215,8 @@ static gboolean se_handle_change_card_emulation_mode(
 
 gboolean net_nfc_server_se_init(GDBusConnection *connection)
 {
-       GError *error = NULL;
        gboolean result;
+       GError *error = NULL;
 
        if (se_skeleton)
                g_object_unref(se_skeleton);
@@ -1309,52 +1226,30 @@ gboolean net_nfc_server_se_init(GDBusConnection *connection)
 
        se_skeleton = net_nfc_gdbus_secure_element_skeleton_new();
 
-       g_signal_connect(se_skeleton,
-                       "handle-set",
-                       G_CALLBACK(se_handle_set),
-                       NULL);
-
-       g_signal_connect(se_skeleton,
-                       "handle-get",
-                       G_CALLBACK(se_handle_get),
-                       NULL);
-
-       g_signal_connect(se_skeleton,
-                       "handle-set-card-emulation",
-                       G_CALLBACK(_se_handle_set_card_emulation),
-                       NULL);
-
-       g_signal_connect(se_skeleton,
-                       "handle-open-secure-element",
-                       G_CALLBACK(se_handle_open_secure_element),
-                       NULL);
-
-       g_signal_connect(se_skeleton,
-                       "handle-close-secure-element",
-                       G_CALLBACK(se_handle_close_secure_element),
-                       NULL);
-
-       g_signal_connect(se_skeleton,
-                       "handle-get-atr",
-                       G_CALLBACK(se_handle_get_atr),
-                       NULL);
-
-       g_signal_connect(se_skeleton,
-                       "handle-send-apdu",
-                       G_CALLBACK(se_handle_send_apdu),
-                       NULL);
-
-       g_signal_connect(se_skeleton,
-                       "handle-change-card-emulation-mode",
-                       G_CALLBACK(se_handle_change_card_emulation_mode),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(se_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/SecureElement",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(se_skeleton, "handle-set", G_CALLBACK(se_handle_set), NULL);
+
+       g_signal_connect(se_skeleton, "handle-get", G_CALLBACK(se_handle_get), NULL);
+
+       g_signal_connect(se_skeleton, "handle-set-card-emulation",
+                       G_CALLBACK(_se_handle_set_card_emulation), NULL);
+
+       g_signal_connect(se_skeleton, "handle-open-secure-element",
+                       G_CALLBACK(se_handle_open_secure_element), NULL);
+
+       g_signal_connect(se_skeleton, "handle-close-secure-element",
+                       G_CALLBACK(se_handle_close_secure_element), NULL);
+
+       g_signal_connect(se_skeleton,   "handle-get-atr", G_CALLBACK(se_handle_get_atr), NULL);
+
+       g_signal_connect(se_skeleton, "handle-send-apdu",
+                       G_CALLBACK(se_handle_send_apdu), NULL);
+
+       g_signal_connect(se_skeleton, "handle-change-card-emulation-mode",
+                       G_CALLBACK(se_handle_change_card_emulation_mode), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(se_skeleton),
+                       connection, "/org/tizen/NetNfcService/SecureElement", &error);
+       if (FALSE == result)
        {
                NFC_ERR("can not skeleton_export %s", error->message);
 
@@ -1380,14 +1275,14 @@ void net_nfc_server_se_deinit(void)
 
 static void se_detected_thread_func(gpointer user_data)
 {
-       net_nfc_target_handle_s *handle = NULL;
        uint32_t devType = 0;
        GVariant *data = NULL;
        net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_target_handle_s *handle = NULL;
 
        g_assert(user_data != NULL);
 
-       if (se_skeleton == NULL)
+       if (NULL == se_skeleton)
        {
                NFC_ERR("se skeleton is not initialized");
 
@@ -1396,35 +1291,27 @@ static void se_detected_thread_func(gpointer user_data)
                return;
        }
 
-       g_variant_get((GVariant *)user_data,
-                       "uu@a(y)",
-                       (guint *)&handle,
-                       &devType,
-                       &data);
+       g_variant_get((GVariant *)user_data, "uu@a(y)", (guint *)&handle, &devType, &data);
 
        net_nfc_server_se_set_current_ese_handle(handle);
 
        NFC_DBG("trying to connect to ESE = [0x%p]", handle);
 
        if (!net_nfc_controller_connect(handle, &result))
-       {
                NFC_DBG("connect failed = [%d]", result);
-       }
 
-       net_nfc_gdbus_secure_element_emit_ese_detected(
-                       se_skeleton,
-                       GPOINTER_TO_UINT(handle),
-                       devType,
-                       data);
+       net_nfc_gdbus_secure_element_emit_ese_detected(se_skeleton, GPOINTER_TO_UINT(handle),
+                       devType, data);
 
        g_variant_unref((GVariant *)user_data);
 }
 
 static void se_transcation_thread_func(gpointer user_data)
 {
-       ServerSeData *detail = (ServerSeData *)user_data;
        bool fg_dispatch;
        pid_t focus_app_pid;
+       ServerSeData *detail = user_data;
+
 
        g_assert(user_data != NULL);
 
@@ -1469,28 +1356,30 @@ static void se_transcation_thread_func(gpointer user_data)
 
 void net_nfc_server_se_detected(void *info)
 {
+       gboolean ret;
+       GVariant *data;
+       GVariant *parameter;
        net_nfc_request_target_detected_t *se_target =
                (net_nfc_request_target_detected_t *)info;
-       GVariant *parameter;
-       GVariant *data;
 
-       data = net_nfc_util_gdbus_buffer_to_variant(
-                       se_target->target_info_values.buffer,
+       data = net_nfc_util_gdbus_buffer_to_variant(se_target->target_info_values.buffer,
                        se_target->target_info_values.length);
 
-       parameter = g_variant_new("uu@a(y)",
-                       GPOINTER_TO_UINT(se_target->handle),
-                       se_target->devType,
-                       data);
-       if (parameter != NULL) {
-               if (net_nfc_server_controller_async_queue_push(
-                                       se_detected_thread_func,
-                                       parameter) == FALSE) {
+       parameter = g_variant_new("uu@a(y)", GPOINTER_TO_UINT(se_target->handle),
+                       se_target->devType, data);
+       if (parameter != NULL)
+       {
+               ret = net_nfc_server_controller_async_queue_push(se_detected_thread_func,
+                                       parameter);
+               if (FALSE == ret)
+               {
                        NFC_ERR("can not push to controller thread");
 
                        g_variant_unref(parameter);
                }
-       } else {
+       }
+       else
+       {
                NFC_ERR("g_variant_new failed");
        }
 
@@ -1500,34 +1389,31 @@ void net_nfc_server_se_detected(void *info)
 
 void net_nfc_server_se_transaction_received(void *info)
 {
-       net_nfc_request_se_event_t *se_event =
-               (net_nfc_request_se_event_t *)info;
+       gboolean ret;
        ServerSeData *detail;
+       net_nfc_request_se_event_t *se_event = (net_nfc_request_se_event_t *)info;
 
        detail = g_try_new0(ServerSeData, 1);
-       if (detail != NULL) {
+       if (detail != NULL)
+       {
                detail->event = se_event->request_type;
 
-               if (se_event->aid.buffer != NULL && se_event->aid.length > 0) {
-                       if (net_nfc_util_alloc_data(&detail->aid,
-                                               se_event->aid.length) == true) {
-                               memcpy(detail->aid.buffer, se_event->aid.buffer,
-                                               se_event->aid.length);
-                       }
+               if (se_event->aid.buffer != NULL && se_event->aid.length > 0)
+               {
+                       if (net_nfc_util_alloc_data(&detail->aid, se_event->aid.length) == true)
+                               memcpy(detail->aid.buffer, se_event->aid.buffer, se_event->aid.length);
                }
 
-               if (se_event->param.buffer != NULL &&
-                               se_event->param.length > 0) {
-                       if (net_nfc_util_alloc_data(&detail->param,
-                                               se_event->param.length) == true) {
-                               memcpy(detail->param.buffer,
-                                               se_event->param.buffer,
-                                               se_event->param.length);
-                       }
+               if (se_event->param.buffer != NULL && se_event->param.length > 0)
+               {
+                       if (net_nfc_util_alloc_data(&detail->param, se_event->param.length) == true)
+                               memcpy(detail->param.buffer, se_event->param.buffer, se_event->param.length);
                }
 
-               if (net_nfc_server_controller_async_queue_push(
-                                       se_transcation_thread_func, detail) == FALSE) {
+               ret = net_nfc_server_controller_async_queue_push(
+                                       se_transcation_thread_func, detail);
+               if (FALSE == ret)
+               {
                        NFC_ERR("can not push to controller thread");
 
                        net_nfc_util_free_data(&detail->param);
@@ -1535,7 +1421,9 @@ void net_nfc_server_se_transaction_received(void *info)
 
                        g_free(detail);
                }
-       } else {
+       }
+       else
+       {
                NFC_ERR("g_new0 failed");
        }
 
index c631a46..663382e 100644 (file)
 #include "net_nfc_util_gdbus_internal.h"
 #include "net_nfc_server_context.h"
 
-/* declaration */
-static gboolean _handle_start_server(
-               NetNfcGDbusSnep *object,
-               GDBusMethodInvocation *invocation,
-               guint arg_handle,
-               guint arg_sap,
-               const gchar *arg_san,
-               guint arg_user_data,
-               GVariant *arg_privilege);
-
-static gboolean _handle_start_client(
-               NetNfcGDbusSnep *object,
-               GDBusMethodInvocation *invocation,
-               guint arg_handle,
-               guint arg_sap,
-               const gchar *arg_san,
-               guint arg_user_data,
-               GVariant *arg_privilege);
-
-static gboolean _handle_client_send_request(
-               NetNfcGDbusSnep *object,
-               GDBusMethodInvocation *invocation,
-               guint arg_snep_handle,
-               guint arg_type,
-               GVariant *arg_ndef_msg,
-               GVariant *arg_privilege);
-
-static gboolean _handle_stop_snep(
-               NetNfcGDbusSnep *object,
-               GDBusMethodInvocation *invocation,
-               guint arg_handle,
-               guint arg_snep_handle,
-               GVariant *arg_privilege);
-
-static void snep_server_start_thread_func(gpointer user_data);
-
-static void snep_client_start_thread_func(gpointer user_data);
-
-static void snep_client_send_request_thread_func(gpointer user_data);
-
-static void snep_stop_service_thread_func(gpointer user_data);
-
 /* definition */
 static NetNfcGDbusSnep *snep_skeleton =  NULL;
 
 static void _emit_snep_event_signal(GVariant *parameter,
-               net_nfc_snep_handle_h handle,
-               net_nfc_error_e result,
-               uint32_t type,
-               data_s *data)
+               net_nfc_snep_handle_h handle, net_nfc_error_e result, uint32_t type, data_s *data)
 {
-       GDBusConnection *connection;
+       gboolean ret;
        char *client_id;
        void *user_data;
        GVariant *arg_data;
        GError *error = NULL;
+       GDBusConnection *connection;
 
-       g_variant_get(parameter, "(usu)",
-                       (guint *)&connection,
-                       &client_id,
+       g_variant_get(parameter, "(usu)", (guint *)&connection, &client_id,
                        (guint *)&user_data);
 
        arg_data = net_nfc_util_gdbus_data_to_variant(data);
 
-       if (g_dbus_connection_emit_signal(
+       ret = g_dbus_connection_emit_signal(
                                connection,
                                client_id,
                                "/org/tizen/NetNfcService/Snep",
@@ -99,27 +53,23 @@ static void _emit_snep_event_signal(GVariant *parameter,
                                "SnepEvent",
                                g_variant_new("(uui@a(y)u)", GPOINTER_TO_UINT(handle), type, (gint)result,
                                        arg_data, GPOINTER_TO_UINT(user_data)),
-                               &error) == false)
+                               &error);
+       if (false == ret)
        {
-               if (error != NULL && error->message != NULL) {
+               if (error != NULL && error->message != NULL)
                        NFC_ERR("g_dbus_connection_emit_signal failed : %s", error->message);
-               } else {
+               else
                        NFC_ERR("g_dbus_connection_emit_signal failed");
-               }
        }
 
        g_free(client_id);
 }
 
 static net_nfc_error_e _snep_server_cb(net_nfc_snep_handle_h handle,
-               net_nfc_error_e result,
-               uint32_t type,
-               data_s *data,
-               void *user_param)
+               net_nfc_error_e result, uint32_t type, data_s *data, void *user_param)
 {
-       GVariant *parameter = (GVariant *)user_param;
-
        data_s *temp = data;
+       GVariant *parameter = (GVariant *)user_param;
 
        NFC_DBG("type [%d], result [%d], data [%p], user_param [%p]",
                        type, result, data, user_param);
@@ -130,8 +80,7 @@ static net_nfc_error_e _snep_server_cb(net_nfc_snep_handle_h handle,
                {
                        uint32_t max_len = 0;
 
-                       net_nfc_server_snep_parse_get_request(data, &max_len,
-                                       temp);
+                       net_nfc_server_snep_parse_get_request(data, &max_len, temp);
                }
                break;
 
@@ -143,39 +92,30 @@ static net_nfc_error_e _snep_server_cb(net_nfc_snep_handle_h handle,
                break;
        }
 
-       if (result < NET_NFC_OK) {
+       if (result < NET_NFC_OK)
                type = NET_NFC_LLCP_STOP;
-       }
 
-       _emit_snep_event_signal(parameter, handle,
-                       result, type, data);
+       _emit_snep_event_signal(parameter, handle, result, type, data);
 
-       if (type == NET_NFC_LLCP_STOP) {
+       if (NET_NFC_LLCP_STOP == type)
                g_object_unref(parameter);
-       }
 
        return result;
 }
 
 static void snep_server_start_thread_func(gpointer user_data)
 {
-       NetNfcGDbusSnep *object;
-       GDBusMethodInvocation *invocation;
-       net_nfc_target_handle_s *arg_handle;
        guint arg_sap;
        gchar *arg_san;
+       GVariant *parameter;
        void *arg_user_data;
        net_nfc_error_e result;
-
-       GVariant *parameter;
+       NetNfcGDbusSnep *object;
        GDBusConnection *connection;
+       GDBusMethodInvocation *invocation;
+       net_nfc_target_handle_s *arg_handle;
 
-       if (user_data == NULL)
-       {
-               NFC_ERR("cannot get SNEP client data");
-
-               return;
-       }
+       RET_IF(NULL == user_data);
 
        g_variant_get((GVariant *)user_data,
                        "(uuuusu)",
@@ -195,20 +135,21 @@ static void snep_server_start_thread_func(gpointer user_data)
                        GPOINTER_TO_UINT(g_object_ref(connection)),
                        g_dbus_method_invocation_get_sender(invocation),
                        GPOINTER_TO_UINT(arg_user_data));
-       if (parameter != NULL) {
-               result = net_nfc_server_snep_server(arg_handle,
-                               arg_san,
-                               arg_sap,
-                               _snep_server_cb,
-                               parameter);
-               if (result != NET_NFC_OK) {
-                       NFC_ERR("net_nfc_server_snep_server failed, [%d]",
-                                       result);
+
+       if (parameter != NULL)
+       {
+               result = net_nfc_server_snep_server(arg_handle, arg_san, arg_sap,
+                               _snep_server_cb, parameter);
+               if (result != NET_NFC_OK)
+               {
+                       NFC_ERR("net_nfc_server_snep_server failed, [%d]", result);
                        g_object_unref(connection);
 
                        g_variant_unref(parameter);
                }
-       } else {
+       }
+       else
+       {
                NFC_ERR("g_variant_new failed");
 
                g_object_unref(connection);
@@ -232,17 +173,17 @@ static gboolean _handle_start_server(
                guint arg_user_data,
                GVariant *arg_privilege)
 {
-       GVariant *parameter;
+       bool ret;
        gboolean result;
+       GVariant *parameter;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               arg_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+                               "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
@@ -258,8 +199,9 @@ static gboolean _handle_start_server(
 
        if (parameter != NULL)
        {
-               if ((result = net_nfc_server_controller_async_queue_push(
-                                               snep_server_start_thread_func, parameter)) == FALSE)
+               result = net_nfc_server_controller_async_queue_push(
+                                               snep_server_start_thread_func, parameter);
+               if (FALSE == result)
                {
                        NFC_ERR("net_nfc_server_controller_async_queue_push failed");
 
@@ -278,8 +220,7 @@ static gboolean _handle_start_server(
                NFC_ERR("g_variant_new failed");
 
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Snep.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
 
                result = FALSE;
        }
@@ -301,32 +242,25 @@ static net_nfc_error_e _snep_start_client_cb(
 
        _emit_snep_event_signal(parameter, handle, result, type, data);
 
-       if (type == NET_NFC_LLCP_STOP) {
+       if (NET_NFC_LLCP_STOP == type)
                g_variant_unref(parameter);
-       }
 
        return result;
 }
 
 static void snep_client_start_thread_func(gpointer user_data)
 {
-       NetNfcGDbusSnep *object;
-       GDBusMethodInvocation *invocation;
-       net_nfc_target_handle_s *arg_handle;
        guint arg_sap;
        gchar *arg_san;
+       GVariant *parameter;
        void *arg_user_data;
        net_nfc_error_e result;
-
-       GVariant *parameter;
+       NetNfcGDbusSnep *object;
        GDBusConnection *connection;
+       GDBusMethodInvocation *invocation;
+       net_nfc_target_handle_s *arg_handle;
 
-       if (user_data == NULL)
-       {
-               NFC_ERR("cannot get SNEP client data");
-
-               return;
-       }
+       RET_IF(NULL == user_data);
 
        g_variant_get((GVariant *)user_data,
                        "(uuuusu)",
@@ -346,20 +280,21 @@ static void snep_client_start_thread_func(gpointer user_data)
                        GPOINTER_TO_UINT(g_object_ref(connection)),
                        g_dbus_method_invocation_get_sender(invocation),
                        GPOINTER_TO_UINT(arg_user_data));
-       if (parameter != NULL) {
-               result = net_nfc_server_snep_client(arg_handle,
-                               arg_san,
-                               arg_sap,
-                               _snep_start_client_cb,
-                               parameter);
-               if (result != NET_NFC_OK) {
-                       NFC_ERR("net_nfc_server_snep_client failed, [%d]",
-                                       result);
+
+       if (parameter != NULL)
+       {
+               result = net_nfc_server_snep_client(arg_handle, arg_san, arg_sap,
+                               _snep_start_client_cb, parameter);
+               if (result != NET_NFC_OK)
+               {
+                       NFC_ERR("net_nfc_server_snep_client failed, [%d]", result);
                        g_object_unref(connection);
 
                        g_variant_unref(parameter);
                }
-       } else {
+       }
+       else
+       {
                NFC_ERR("g_variant_new failed");
 
                g_object_unref(connection);
@@ -383,17 +318,17 @@ static gboolean _handle_start_client(
                guint arg_user_data,
                GVariant *arg_privilege)
 {
-       GVariant *parameter;
+       bool ret;
        gboolean result;
+       GVariant *parameter;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               arg_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+                               "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
@@ -409,8 +344,9 @@ static gboolean _handle_start_client(
 
        if (parameter != NULL)
        {
-               if ((result = net_nfc_server_controller_async_queue_push(
-                                               snep_client_start_thread_func, parameter)) == FALSE)
+               result = net_nfc_server_controller_async_queue_push(
+                                               snep_client_start_thread_func, parameter);
+               if (FALSE == result)
                {
                        NFC_ERR("net_nfc_server_controller_async_queue_push failed");
 
@@ -429,8 +365,7 @@ static gboolean _handle_start_client(
                NFC_ERR("g_variant_new failed");
 
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Snep.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
 
                result = FALSE;
        }
@@ -450,13 +385,14 @@ static net_nfc_error_e _snep_client_request_cb(
        NFC_DBG("type [%d], result [%d], data [%p], user_param [%p]",
                        type, result, data, user_param);
 
-       if (parameter != NULL) {
+       if (parameter != NULL)
+       {
+               GVariant *arg_ndef_msg;
                NetNfcGDbusSnep *object;
+               GVariant *arg_data = NULL;
+               net_nfc_snep_type_t arg_type;
                GDBusMethodInvocation *invocation;
                net_nfc_snep_handle_h arg_snep_handle;
-               net_nfc_snep_type_t arg_type;
-               GVariant *arg_ndef_msg;
-               GVariant *arg_data = NULL;
 
                g_variant_get(parameter,
                                "(uuuu@a(y))",
@@ -466,17 +402,13 @@ static net_nfc_error_e _snep_client_request_cb(
                                (guint *)&arg_type,
                                &arg_ndef_msg);
 
-               if (data != NULL && data->buffer != NULL && data->length > 0) {
+               if (data != NULL && data->buffer != NULL && data->length > 0)
                        arg_data = net_nfc_util_gdbus_data_to_variant(data);
-               } else {
+               else
                        arg_data = net_nfc_util_gdbus_buffer_to_variant(NULL, 0);
-               }
 
-               net_nfc_gdbus_snep_complete_client_request(object,
-                               invocation,
-                               result,
-                               type,
-                               arg_data);
+               net_nfc_gdbus_snep_complete_client_request(object, invocation, result,
+                               type, arg_data);
 
                g_variant_unref(arg_ndef_msg);
 
@@ -486,7 +418,9 @@ static net_nfc_error_e _snep_client_request_cb(
                g_variant_unref(parameter);
 
                result = NET_NFC_OK;
-       } else {
+       }
+       else
+       {
                result = NET_NFC_NULL_PARAMETER;
        }
 
@@ -495,20 +429,15 @@ static net_nfc_error_e _snep_client_request_cb(
 
 static void snep_client_send_request_thread_func(gpointer user_data)
 {
+       net_nfc_error_e result;
+       GVariant *arg_ndef_msg;
        NetNfcGDbusSnep *object;
+       data_s data = { NULL, };
+       net_nfc_snep_type_t arg_type;
        GDBusMethodInvocation *invocation;
        net_nfc_server_snep_context_t *arg_snep_handle;
-       net_nfc_snep_type_t arg_type;
-       GVariant *arg_ndef_msg;
-       data_s data = { NULL, };
-       net_nfc_error_e result;
 
-       if (user_data == NULL)
-       {
-               NFC_ERR("cannot get SNEP client data");
-
-               return;
-       }
+       RET_IF(NULL == user_data);
 
        g_variant_get((GVariant *)user_data,
                        "(uuuu@a(y))",
@@ -523,17 +452,13 @@ static void snep_client_send_request_thread_func(gpointer user_data)
 
        net_nfc_util_gdbus_variant_to_data_s(arg_ndef_msg, &data);
 
-       result = net_nfc_server_snep_client_request(arg_snep_handle,
-                       arg_type,
-                       &data,
-                       _snep_client_request_cb,
-                       user_data);
+       result = net_nfc_server_snep_client_request(arg_snep_handle, arg_type,
+                       &data, _snep_client_request_cb, user_data);
        if (result != NET_NFC_OK)
        {
                GVariant *resp;
 
-               NFC_ERR("net_nfc_server_snep_client_request  "
-                               "failed, [%d]",result);
+               NFC_ERR("net_nfc_server_snep_client_request failed, [%d]",result);
 
                resp = net_nfc_util_gdbus_buffer_to_variant(NULL, 0);
 
@@ -559,17 +484,17 @@ static gboolean _handle_client_send_request(
                GVariant *arg_ndef_msg,
                GVariant *arg_privilege)
 {
-       GVariant *parameter;
+       bool ret;
        gboolean result;
+       GVariant *parameter;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               arg_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+                               "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
@@ -584,8 +509,9 @@ static gboolean _handle_client_send_request(
 
        if (parameter != NULL)
        {
-               if ((result = net_nfc_server_controller_async_queue_push(
-                                               snep_client_send_request_thread_func, parameter)) == FALSE)
+               result = net_nfc_server_controller_async_queue_push(
+                                               snep_client_send_request_thread_func, parameter);
+               if (FALSE == result)
                {
                        NFC_ERR("net_nfc_server_controller_async_queue_push failed");
 
@@ -604,8 +530,7 @@ static gboolean _handle_client_send_request(
                NFC_ERR("g_variant_new failed");
 
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Snep.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
 
                result = FALSE;
        }
@@ -616,37 +541,24 @@ static gboolean _handle_client_send_request(
 static void snep_stop_service_thread_func(gpointer user_data)
 {
        NetNfcGDbusSnep *object;
-       GDBusMethodInvocation *invocation;
        net_nfc_target_handle_s *handle;
+       GDBusMethodInvocation *invocation;
        net_nfc_snep_handle_h snep_handle;
 
-       if (user_data == NULL)
-       {
-               NFC_ERR("cannot get SNEP client data");
+       RET_IF(NULL == user_data);
 
-               return;
-       }
-
-       g_variant_get((GVariant *)user_data,
-                       "(uuuu)",
-                       (guint *)&object,
-                       (guint *)&invocation,
-                       (guint *)&handle,
-                       (guint *)&snep_handle);
+       g_variant_get((GVariant *)user_data, "(uuuu)", (guint *)&object, (guint *)&invocation,
+                       (guint *)&handle, (guint *)&snep_handle);
 
        g_assert(object != NULL);
        g_assert(invocation != NULL);
 
        /* TODO :
-          g_dbus_method_invocation_return_dbus_error(
-          invocation,
-          "org.tizen.NetNfcService.Snep.DataError",
-          "Cannot stop SNEP service");
-          */
+          g_dbus_method_invocation_return_dbus_error(invocation,
+          "org.tizen.NetNfcService.Snep.DataError", "Cannot stop SNEP service");
+       */
 
-       net_nfc_gdbus_snep_complete_stop_snep(object,
-                       invocation,
-                       NET_NFC_OK);
+       net_nfc_gdbus_snep_complete_stop_snep(object, invocation, NET_NFC_OK);
 
        g_object_unref(invocation);
        g_object_unref(object);
@@ -661,32 +573,30 @@ static gboolean _handle_stop_snep(
                guint arg_snep_handle,
                GVariant *arg_privilege)
 {
-       GVariant *parameter;
+       bool ret;
        gboolean result;
+       GVariant *parameter;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               arg_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+                               "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
-       parameter = g_variant_new("(uuuu)",
-                       GPOINTER_TO_UINT(g_object_ref(object)),
-                       GPOINTER_TO_UINT(g_object_ref(invocation)),
-                       arg_handle,
-                       arg_snep_handle);
+       parameter = g_variant_new("(uuuu)", GPOINTER_TO_UINT(g_object_ref(object)),
+                       GPOINTER_TO_UINT(g_object_ref(invocation)), arg_handle, arg_snep_handle);
 
        if (parameter != NULL)
        {
-               if ((result = net_nfc_server_controller_async_queue_push(
-                                               snep_stop_service_thread_func, parameter)) == FALSE)
+               result = net_nfc_server_controller_async_queue_push(
+                                               snep_stop_service_thread_func, parameter);
+               if (FALSE == result)
                {
                        NFC_ERR("net_nfc_server_controller_async_queue_push failed");
 
@@ -705,8 +615,7 @@ static gboolean _handle_stop_snep(
                NFC_ERR("g_variant_new failed");
 
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Snep.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
 
                result = FALSE;
        }
@@ -717,45 +626,43 @@ static gboolean _handle_stop_snep(
 static void _snep_activate_cb(int event, net_nfc_target_handle_s *handle,
                uint32_t sap, const char *san, void *user_param)
 {
-       GVariant *parameter = (GVariant *)user_param;
        net_nfc_error_e result = NET_NFC_OK;
+       GVariant *parameter = (GVariant *)user_param;
 
-       NFC_DBG("event [%d], handle [%p], sap [%d], san [%s]",
-                       event, handle, sap, san);
+       NFC_DBG("event [%d], handle [%p], sap [%d], san [%s]", event, handle, sap, san);
 
-       if (event == NET_NFC_LLCP_START) {
-               GDBusConnection *connection;
-               GVariant *param = NULL;
+       if (NET_NFC_LLCP_START == event)
+       {
                char *client_id;
                void *user_data;
+               GVariant *param = NULL;
+               GDBusConnection *connection;
 
                /* start server */
-               g_variant_get(parameter, "(usu)",
-                               (guint *)&connection,
-                               &client_id,
+               g_variant_get(parameter, "(usu)", (guint *)&connection, &client_id,
                                (guint *)&user_data);
 
-               param = g_variant_new("(usu)",
-                               GPOINTER_TO_UINT(g_object_ref(connection)),
-                               client_id,
-                               GPOINTER_TO_UINT(user_data));
+               param = g_variant_new("(usu)", GPOINTER_TO_UINT(g_object_ref(connection)),
+                               client_id, GPOINTER_TO_UINT(user_data));
 
                g_free(client_id);
 
                result = net_nfc_server_snep_server(handle, (char *)san, sap,
                                _snep_server_cb, param);
-               if (result == NET_NFC_OK) {
-                       _emit_snep_event_signal(parameter, handle,
-                                       result, event, NULL);
-               } else {
-                       NFC_ERR("net_nfc_server_snep_server failed, [%d]",
-                                       result);
+               if (NET_NFC_OK == result)
+               {
+                       _emit_snep_event_signal(parameter, handle, result, event, NULL);
+               }
+               else
+               {
+                       NFC_ERR("net_nfc_server_snep_server failed, [%d]", result);
 
                        g_variant_unref(param);
                }
-       } else {
-               _emit_snep_event_signal(parameter, handle,
-                               result, NET_NFC_LLCP_UNREGISTERED, NULL);
+       }
+       else
+       {
+               _emit_snep_event_signal(parameter, handle, result, NET_NFC_LLCP_UNREGISTERED, NULL);
 
                /* unregister server */
                g_variant_unref(parameter);
@@ -764,36 +671,28 @@ static void _snep_activate_cb(int event, net_nfc_target_handle_s *handle,
 
 static void snep_register_server_thread_func(gpointer user_data)
 {
-       NetNfcGDbusSnep *object;
-       GDBusMethodInvocation *invocation;
        guint arg_sap;
        gchar *arg_san;
        guint arg_user_data;
-
        net_nfc_error_e result;
+       NetNfcGDbusSnep *object;
+       g_assert(user_data != NULL);
        GVariant *parameter = NULL;
        GDBusConnection *connection;
+       GDBusMethodInvocation *invocation;
 
-       g_assert(user_data != NULL);
-
-       g_variant_get((GVariant *)user_data,
-                       "(uuusu)",
-                       (guint *)&object,
-                       (guint *)&invocation,
-                       &arg_sap,
-                       &arg_san,
-                       &arg_user_data);
+       g_variant_get((GVariant *)user_data, "(uuusu)", (guint *)&object, (guint *)&invocation,
+                       &arg_sap, &arg_san, &arg_user_data);
 
        g_assert(object != NULL);
        g_assert(invocation != NULL);
 
        connection = g_dbus_method_invocation_get_connection(invocation);
 
-       parameter = g_variant_new("(usu)",
-                       GPOINTER_TO_UINT(g_object_ref(connection)),
-                       g_dbus_method_invocation_get_sender(invocation),
-                       arg_user_data);
-       if (parameter != NULL) {
+       parameter = g_variant_new("(usu)", GPOINTER_TO_UINT(g_object_ref(connection)),
+                       g_dbus_method_invocation_get_sender(invocation), arg_user_data);
+       if (parameter != NULL)
+       {
                /* register default snep server */
                result = net_nfc_server_llcp_register_service(
                                g_dbus_method_invocation_get_sender(invocation),
@@ -801,19 +700,20 @@ static void snep_register_server_thread_func(gpointer user_data)
                                arg_san,
                                _snep_activate_cb,
                                parameter);
-               if (result != NET_NFC_OK) {
+               if (result != NET_NFC_OK)
+               {
                        NFC_ERR("net_nfc_service_llcp_register_service failed, [%d]", result);
                        g_object_unref(connection);
                        g_variant_unref(parameter);
                }
-       } else {
+       }
+       else
+       {
                result = NET_NFC_ALLOC_FAIL;
                g_object_unref(connection);
        }
 
-       net_nfc_gdbus_snep_complete_server_register(object,
-                       invocation,
-                       result);
+       net_nfc_gdbus_snep_complete_server_register(object, invocation, result);
 
        g_free(arg_san);
 
@@ -831,33 +731,30 @@ static gboolean _handle_register_server(
                guint arg_user_data,
                GVariant *arg_privilege)
 {
-       GVariant *parameter;
+       bool ret;
        gboolean result;
+       GVariant *parameter;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               arg_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+                               "nfc-manager::p2p", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
-       parameter = g_variant_new("(uuusu)",
-                       GPOINTER_TO_UINT(g_object_ref(object)),
-                       GPOINTER_TO_UINT(g_object_ref(invocation)),
-                       arg_sap,
-                       arg_san,
-                       arg_user_data);
+       parameter = g_variant_new("(uuusu)", GPOINTER_TO_UINT(g_object_ref(object)),
+                       GPOINTER_TO_UINT(g_object_ref(invocation)), arg_sap, arg_san, arg_user_data);
 
        if (parameter != NULL)
        {
-               if ((result = net_nfc_server_controller_async_queue_push(
-                                               snep_register_server_thread_func, parameter)) == FALSE)
+               result = net_nfc_server_controller_async_queue_push(
+                                               snep_register_server_thread_func, parameter);
+               if (FALSE == result)
                {
                        NFC_ERR("net_nfc_server_controller_async_queue_push failed");
 
@@ -876,8 +773,7 @@ static gboolean _handle_register_server(
                NFC_ERR("g_variant_new failed");
 
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Snep.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
 
                result = FALSE;
        }
@@ -887,33 +783,24 @@ static gboolean _handle_register_server(
 
 static void snep_unregister_server_thread_func(gpointer user_data)
 {
-       NetNfcGDbusSnep *object;
-       GDBusMethodInvocation *invocation;
        guint arg_sap;
        gchar *arg_san;
-
        net_nfc_error_e result;
+       NetNfcGDbusSnep *object;
+       GDBusMethodInvocation *invocation;
 
        g_assert(user_data != NULL);
 
-       g_variant_get((GVariant *)user_data,
-                       "(uuus)",
-                       (guint *)&object,
-                       (guint *)&invocation,
-                       &arg_sap,
-                       &arg_san);
+       g_variant_get((GVariant *)user_data, "(uuus)", (guint *)&object, (guint *)&invocation,
+                       &arg_sap, &arg_san);
 
        g_assert(object != NULL);
        g_assert(invocation != NULL);
 
        result = net_nfc_server_llcp_unregister_service(
-                       g_dbus_method_invocation_get_sender(invocation),
-                       arg_sap,
-                       arg_san);
+                       g_dbus_method_invocation_get_sender(invocation), arg_sap, arg_san);
 
-       net_nfc_gdbus_snep_complete_server_unregister(object,
-                       invocation,
-                       result);
+       net_nfc_gdbus_snep_complete_server_unregister(object, invocation, result);
 
        g_free(arg_san);
 
@@ -930,32 +817,31 @@ static gboolean _handle_unregister_server(
                const gchar *arg_san,
                GVariant *arg_privilege)
 {
-       GVariant *parameter;
+       bool ret;
        gboolean result;
+       GVariant *parameter;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               arg_privilege,
-                               "nfc-manager::p2p",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+                               "nfc-manager::p2p", "rw");
+
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
-       parameter = g_variant_new("(uuus)",
-                       GPOINTER_TO_UINT(g_object_ref(object)),
-                       GPOINTER_TO_UINT(g_object_ref(invocation)),
-                       arg_sap,
-                       arg_san);
+       parameter = g_variant_new("(uuus)", GPOINTER_TO_UINT(g_object_ref(object)),
+                       GPOINTER_TO_UINT(g_object_ref(invocation)), arg_sap, arg_san);
 
        if (parameter != NULL)
        {
-               if ((result = net_nfc_server_controller_async_queue_push(
-                                               snep_unregister_server_thread_func, parameter)) == FALSE)
+               result = net_nfc_server_controller_async_queue_push(
+                                               snep_unregister_server_thread_func, parameter);
+               if (FALSE == result)
                {
                        NFC_ERR("net_nfc_server_controller_async_queue_push failed");
 
@@ -974,8 +860,7 @@ static gboolean _handle_unregister_server(
                NFC_ERR("g_variant_new failed");
 
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.Snep.MemoryError",
-                               "Out of memory");
+                               "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
 
                result = FALSE;
        }
@@ -985,50 +870,35 @@ static gboolean _handle_unregister_server(
 
 gboolean net_nfc_server_snep_init(GDBusConnection *connection)
 {
-       GError *error = NULL;
        gboolean result;
+       GError *error = NULL;
 
        if (snep_skeleton)
                g_object_unref(snep_skeleton);
 
        snep_skeleton = net_nfc_gdbus_snep_skeleton_new();
 
-       g_signal_connect(snep_skeleton,
-                       "handle-server-register",
-                       G_CALLBACK(_handle_register_server),
-                       NULL);
-
-       g_signal_connect(snep_skeleton,
-                       "handle-server-unregister",
-                       G_CALLBACK(_handle_unregister_server),
-                       NULL);
-
-       g_signal_connect(snep_skeleton,
-                       "handle-server-start",
-                       G_CALLBACK(_handle_start_server),
-                       NULL);
-
-       g_signal_connect(snep_skeleton,
-                       "handle-client-start",
-                       G_CALLBACK(_handle_start_client),
-                       NULL);
-
-       g_signal_connect(snep_skeleton,
-                       "handle-client-request",
-                       G_CALLBACK(_handle_client_send_request),
-                       NULL);
-
-       g_signal_connect(snep_skeleton,
-                       "handle-stop-snep",
-                       G_CALLBACK(_handle_stop_snep),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(snep_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/Snep",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(snep_skeleton, "handle-server-register",
+                       G_CALLBACK(_handle_register_server), NULL);
+
+       g_signal_connect(snep_skeleton, "handle-server-unregister",
+                       G_CALLBACK(_handle_unregister_server), NULL);
+
+       g_signal_connect(snep_skeleton, "handle-server-start",
+                       G_CALLBACK(_handle_start_server), NULL);
+
+       g_signal_connect(snep_skeleton, "handle-client-start",
+                       G_CALLBACK(_handle_start_client), NULL);
+
+       g_signal_connect(snep_skeleton, "handle-client-request",
+                       G_CALLBACK(_handle_client_send_request), NULL);
+
+       g_signal_connect(snep_skeleton, "handle-stop-snep",
+                       G_CALLBACK(_handle_stop_snep), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(snep_skeleton),
+                       connection, "/org/tizen/NetNfcService/Snep", &error);
+       if (FALSE == result)
        {
                g_error_free(error);
 
index 32fa5ee..9cdf65f 100644 (file)
@@ -24,38 +24,25 @@ static NetNfcGDbusPopup *popup_skeleton = NULL;
 
 static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
                GDBusMethodInvocation *invocation,
-               int state,
-               gint focus_state,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
-               GDBusMethodInvocation *invocation,
                gint state,
                gint focus_state,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       bool ret;
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "w") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "w");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
-       net_nfc_server_gdbus_set_launch_state(
-                       g_dbus_method_invocation_get_sender(invocation),
+       net_nfc_server_gdbus_set_launch_state(g_dbus_method_invocation_get_sender(invocation),
                        state, focus_state);
 
        net_nfc_gdbus_popup_complete_set(popup_manager, invocation, NET_NFC_OK);
@@ -64,20 +51,18 @@ static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
 }
 
 static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data)
+               GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
 {
+       bool ret;
        gboolean state;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "r");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
@@ -86,44 +71,34 @@ static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
        state = net_nfc_server_gdbus_get_launch_state(
                        g_dbus_method_invocation_get_sender(invocation));
 
-       net_nfc_gdbus_popup_complete_get(popup_manager, invocation,
-                       NET_NFC_OK, state);
+       net_nfc_gdbus_popup_complete_get(popup_manager, invocation, NET_NFC_OK, state);
 
        return TRUE;
 }
 
 gboolean net_nfc_server_system_handler_init(GDBusConnection *connection)
 {
-       GError *error = NULL;
        gboolean result;
+       GError *error = NULL;
 
        if (popup_skeleton)
                g_object_unref(popup_skeleton);
 
        popup_skeleton = net_nfc_gdbus_popup_skeleton_new();
-       if (popup_skeleton == NULL)
+       if (NULL == popup_skeleton)
        {
                NFC_ERR("Failed to allocate popup skeleton");
 
                return FALSE;
        }
 
-       g_signal_connect(popup_skeleton,
-                       "handle-set",
-                       G_CALLBACK(popup_handle_set),
-                       NULL);
-
-       g_signal_connect(popup_skeleton,
-                       "handle-get",
-                       G_CALLBACK(popup_handle_get),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(popup_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/Popup",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(popup_skeleton, "handle-set", G_CALLBACK(popup_handle_set), NULL);
+
+       g_signal_connect(popup_skeleton, "handle-get", G_CALLBACK(popup_handle_get), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(popup_skeleton),
+                       connection, "/org/tizen/NetNfcService/Popup", &error);
+       if (FALSE == result)
        {
                NFC_ERR("Can not skeleton_export %s", error->message);
 
index a849a25..d3a0335 100644 (file)
@@ -43,36 +43,6 @@ struct _WatchDogData
        net_nfc_target_handle_s *handle;
 };
 
-
-static gboolean tag_is_isp_dep_ndef_formatable(net_nfc_target_handle_s *handle,
-               int dev_type);
-
-static gboolean tag_read_ndef_message(net_nfc_target_handle_s *handle,
-               int dev_type,data_s **read_ndef);
-
-static void tag_watchdog_thread_func(gpointer user_data);
-
-static void tag_get_current_tag_info_thread_func(gpointer user_data);
-
-static void tag_slave_target_detected_thread_func(gpointer user_data);
-
-
-/* methods */
-static gboolean tag_handle_is_tag_connected(NetNfcGDbusTag *tag,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean tag_handle_get_current_tag_info(NetNfcGDbusTag *tag,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean tag_handle_get_current_target_handle(NetNfcGDbusTag *tag,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
 static NetNfcGDbusTag *tag_skeleton = NULL;
 
 static net_nfc_current_target_info_s *current_target_info = NULL;
@@ -80,21 +50,18 @@ static net_nfc_current_target_info_s *current_target_info = NULL;
 static gboolean tag_is_isp_dep_ndef_formatable(net_nfc_target_handle_s *handle,
                int dev_type)
 {
-       uint8_t cmd[] = { 0x90, 0x60, 0x00, 0x00, 0x00 };
 
-       net_nfc_transceive_info_s info;
+       gboolean result = false;
        data_s *response = NULL;
+       net_nfc_transceive_info_s info;
        net_nfc_error_e error = NET_NFC_OK;
-       gboolean result = false;
+       uint8_t cmd[] = { 0x90, 0x60, 0x00, 0x00, 0x00 };
 
        info.dev_type = dev_type;
        info.trans_data.buffer = cmd;
        info.trans_data.length = sizeof(cmd);
 
-       if (net_nfc_controller_transceive(handle,
-                               &info,
-                               &response,
-                               &error) == false)
+       if (net_nfc_controller_transceive(handle, &info, &response, &error) == false)
        {
                NFC_ERR("net_nfc_controller_transceive is failed");
 
@@ -103,8 +70,7 @@ static gboolean tag_is_isp_dep_ndef_formatable(net_nfc_target_handle_s *handle,
 
        if (response != NULL)
        {
-               if (response->length == 9 &&
-                               response->buffer[7] == (uint8_t)0x91 &&
+               if (response->length == 9 && response->buffer[7] == (uint8_t)0x91 &&
                                response->buffer[8] == (uint8_t)0xAF)
                {
                        result =  TRUE;
@@ -124,23 +90,19 @@ static gboolean tag_is_isp_dep_ndef_formatable(net_nfc_target_handle_s *handle,
 static gboolean tag_read_ndef_message(net_nfc_target_handle_s *handle,
                int dev_type, data_s **read_ndef)
 {
-       net_nfc_error_e result = NET_NFC_OK;
        data_s *temp = NULL;
+       net_nfc_error_e result = NET_NFC_OK;
 
-       if (handle == NULL)
-               return FALSE;
-
-       if (read_ndef == NULL)
-               return FALSE;
+       RETV_IF(NULL == handle, FALSE);
+       RETV_IF(NULL == read_ndef, FALSE);
 
        *read_ndef = NULL;
 
-       if (dev_type == NET_NFC_MIFARE_DESFIRE_PICC)
+       if (NET_NFC_MIFARE_DESFIRE_PICC == dev_type)
        {
                if (tag_is_isp_dep_ndef_formatable(handle, dev_type) == FALSE)
                {
-                       NFC_ERR(
-                                       "DESFIRE : ISO-DEP ndef not formatable");
+                       NFC_ERR("DESFIRE : ISO-DEP ndef not formatable");
                        return FALSE;
                }
 
@@ -148,13 +110,10 @@ static gboolean tag_read_ndef_message(net_nfc_target_handle_s *handle,
 
                if (net_nfc_controller_connect(handle, &result) == false)
                {
-                       NFC_ERR("%s failed, & retry polling!!",
-                                       "net_nfc_controller_connect");
+                       NFC_ERR("net_nfc_controller_connect failed & retry polling!!");
 
-                       if (net_nfc_controller_configure_discovery(
-                                               NET_NFC_DISCOVERY_MODE_RESUME,
-                                               NET_NFC_ALL_ENABLE,
-                                               &result) == false)
+                       if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+                                               NET_NFC_ALL_ENABLE, &result) == false)
                        {
                                net_nfc_controller_exception_handler();
                        }
@@ -170,17 +129,14 @@ static gboolean tag_read_ndef_message(net_nfc_target_handle_s *handle,
 
        NFC_DBG("net_nfc_controller_read_ndef success");
 
-       if (dev_type == NET_NFC_MIFARE_DESFIRE_PICC)
+       if (NET_NFC_MIFARE_DESFIRE_PICC == dev_type)
        {
                if (net_nfc_controller_connect(handle, &result) == false)
                {
-                       NFC_ERR("%s failed, & retry polling!!",
-                                       "net_nfc_controller_connect");
+                       NFC_ERR("net_nfc_controller_connect failed, & retry polling!!");
 
-                       if (net_nfc_controller_configure_discovery(
-                                               NET_NFC_DISCOVERY_MODE_RESUME,
-                                               NET_NFC_ALL_ENABLE,
-                                               &result) == false)
+                       if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+                                               NET_NFC_ALL_ENABLE, &result) == false)
                        {
                                net_nfc_controller_exception_handler();
                        }
@@ -202,23 +158,14 @@ static gboolean tag_read_ndef_message(net_nfc_target_handle_s *handle,
 
 static void tag_watchdog_thread_func(gpointer user_data)
 {
-       WatchDogData *watch_dog = (WatchDogData *)user_data;
+       gboolean ret;
        net_nfc_target_handle_s *handle;
-       net_nfc_error_e result = NET_NFC_OK;
        bool is_present_target = false;
+       net_nfc_error_e result = NET_NFC_OK;
+       WatchDogData *watch_dog = user_data;
 
-       if (watch_dog == NULL)
-       {
-               NFC_ERR("can not get WatchDogData");
-               return;
-       }
-
-       if (watch_dog->handle == NULL)
-       {
-               NFC_ERR("can not get WatchDogData->handle");
-               return;
-       }
-
+       RET_IF(NULL == watch_dog);
+       RET_IF(NULL == watch_dog->handle);
 
        /* IMPORTANT, TEMPORARY : switching context to another thread
           for give CPU time */
@@ -228,15 +175,14 @@ static void tag_watchdog_thread_func(gpointer user_data)
        if (handle->connection_type == NET_NFC_P2P_CONNECTION_TARGET ||
                        handle->connection_type == NET_NFC_TAG_CONNECTION)
        {
-               is_present_target = net_nfc_controller_check_target_presence(
-                               handle, &result);
+               is_present_target = net_nfc_controller_check_target_presence(handle, &result);
        }
 
-       if (is_present_target == true)
+       if (true == is_present_target)
        {
-               if(net_nfc_server_controller_async_queue_push(
-                                       tag_watchdog_thread_func,
-                                       watch_dog) == FALSE)
+               ret = net_nfc_server_controller_async_queue_push(tag_watchdog_thread_func,
+                                       watch_dog);
+               if(FALSE == ret)
                {
                        NFC_ERR("can not create watch dog");
                        g_free(watch_dog);
@@ -244,8 +190,7 @@ static void tag_watchdog_thread_func(gpointer user_data)
                return;
        }
 
-       if (result != NET_NFC_NOT_INITIALIZED &&
-                       result != NET_NFC_INVALID_HANDLE)
+       if (result != NET_NFC_NOT_INITIALIZED && result != NET_NFC_INVALID_HANDLE)
        {
                if(net_nfc_controller_disconnect(handle, &result) == false)
                {
@@ -256,8 +201,7 @@ static void tag_watchdog_thread_func(gpointer user_data)
 
        net_nfc_server_set_state(NET_NFC_SERVER_IDLE);
 
-       net_nfc_gdbus_tag_emit_tag_detached(tag_skeleton,
-                       GPOINTER_TO_UINT(handle),
+       net_nfc_gdbus_tag_emit_tag_detached(tag_skeleton, GPOINTER_TO_UINT(handle),
                        watch_dog->dev_type);
 
        g_free(watch_dog);
@@ -265,29 +209,28 @@ static void tag_watchdog_thread_func(gpointer user_data)
 
 static void tag_get_current_tag_info_thread_func(gpointer user_data)
 {
-       CurrentTagInfoData *info_data =
-               (CurrentTagInfoData *)user_data;
 
        /* FIXME : net_nfc_current_target_info_s should be removed */
-       net_nfc_current_target_info_s *target_info;
-       net_nfc_error_e result = NET_NFC_OPERATION_FAIL;
-       net_nfc_target_handle_s *handle = NULL;
-       net_nfc_target_type_e dev_type = NET_NFC_UNKNOWN_TARGET;
-       gboolean is_ndef_supported = FALSE;
-       guint8 ndef_card_state = 0;
+       bool ret;
+       data_s *raw_data = NULL;
+       gint number_of_keys = 0;
        guint32 max_data_size = 0;
+       guint8 ndef_card_state = 0;
        guint32 actual_data_size = 0;
-       gint number_of_keys = 0;
+       gboolean is_ndef_supported = FALSE;
+       net_nfc_target_handle_s *handle = NULL;
        data_s target_info_values = { NULL, 0 };
-       data_s *raw_data = NULL;
+       CurrentTagInfoData *info_data = user_data;
+       net_nfc_current_target_info_s *target_info;
+       net_nfc_error_e result = NET_NFC_OPERATION_FAIL;
+       net_nfc_target_type_e dev_type = NET_NFC_UNKNOWN_TARGET;
 
        g_assert(info_data != NULL);
        g_assert(info_data->tag != NULL);
        g_assert(info_data->invocation != NULL);
 
        target_info = net_nfc_server_get_target_info();
-       if (target_info != NULL &&
-                       target_info->devType != NET_NFC_NFCIP1_TARGET &&
+       if (target_info != NULL && target_info->devType != NET_NFC_NFCIP1_TARGET &&
                        target_info->devType != NET_NFC_NFCIP1_INITIATOR)
        {
                handle = target_info->handle;
@@ -298,22 +241,16 @@ static void tag_get_current_tag_info_thread_func(gpointer user_data)
 
                dev_type = target_info->devType ;
 
-               if (net_nfc_controller_check_ndef(target_info->handle,
-                                       &ndef_card_state,
-                                       (int *)&max_data_size,
-                                       (int *)&actual_data_size,
-                                       &result) == true)
-               {
+               ret = net_nfc_controller_check_ndef(target_info->handle, &ndef_card_state,
+                                       (int *)&max_data_size, (int *)&actual_data_size, &result);
+               if (true == ret)
                        is_ndef_supported = TRUE;
-               }
 
                if (is_ndef_supported)
                {
-                       if (net_nfc_controller_read_ndef(target_info->handle,
-                                               &raw_data, &result) == true)
-                       {
+                       ret = net_nfc_controller_read_ndef(target_info->handle, &raw_data, &result);
+                       if (true == ret)
                                NFC_DBG("net_nfc_controller_read_ndef is success");
-                       }
                }
        }
 
@@ -331,7 +268,8 @@ static void tag_get_current_tag_info_thread_func(gpointer user_data)
                        net_nfc_util_gdbus_data_to_variant(&target_info_values),
                        net_nfc_util_gdbus_data_to_variant(raw_data));
 
-       if (raw_data != NULL) {
+       if (raw_data != NULL)
+       {
                net_nfc_util_free_data(raw_data);
                g_free(raw_data);
        }
@@ -344,42 +282,32 @@ static void tag_get_current_tag_info_thread_func(gpointer user_data)
 
 static void tag_slave_target_detected_thread_func(gpointer user_data)
 {
-       net_nfc_current_target_info_s *target;
-       net_nfc_error_e result = NET_NFC_OK;
-
+       bool ret;
+       GVariant *raw_data = NULL;
        guint32 max_data_size = 0;
-       guint32 actual_data_size = 0;
        guint8 ndef_card_state = 0;
-       gboolean is_ndef_supported = FALSE;
-
-       GVariant *target_info_values = NULL;
-       GVariant *raw_data = NULL;
-
+       guint32 actual_data_size = 0;
        WatchDogData *watch_dog = NULL;
        bool isHandoverMessage = false;
+       net_nfc_error_e result = NET_NFC_OK;
+       gboolean is_ndef_supported = FALSE;
+       net_nfc_current_target_info_s *target;
+       GVariant *target_info_values = NULL;
 
        target = net_nfc_server_get_target_info();
 
        g_assert(target != NULL); /* raise exception!!! what;s wrong?? */
 
-       if (tag_skeleton == NULL)
-       {
-               NFC_ERR("tag skeleton is not initialized");
-
-               return;
-       }
+       RET_IF(NULL == tag_skeleton);
 
        if (net_nfc_controller_connect(target->handle, &result) == false)
        {
                NFC_ERR("connect failed & Retry Polling!!");
 
-               if (net_nfc_controller_configure_discovery(
-                                       NET_NFC_DISCOVERY_MODE_RESUME,
-                                       NET_NFC_ALL_ENABLE,
-                                       &result) == false)
-               {
+               ret = net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+                                       NET_NFC_ALL_ENABLE, &result);
+               if (false == ret)
                        net_nfc_controller_exception_handler();
-               }
 
                return;
        }
@@ -389,17 +317,12 @@ static void tag_slave_target_detected_thread_func(gpointer user_data)
        NFC_DBG("tag is connected");
 
        target_info_values = net_nfc_util_gdbus_buffer_to_variant(
-                       target->target_info_values.buffer,
-                       target->target_info_values.length);
+                       target->target_info_values.buffer, target->target_info_values.length);
 
-       if (net_nfc_controller_check_ndef(target->handle,
-                               &ndef_card_state,
-                               (int *)&max_data_size,
-                               (int *)&actual_data_size,
-                               &result) == true)
-       {
+       ret = net_nfc_controller_check_ndef(target->handle, &ndef_card_state,
+                               (int *)&max_data_size, (int *)&actual_data_size, &result);
+       if (true == ret)
                is_ndef_supported = TRUE;
-       }
 
        if (is_ndef_supported)
        {
@@ -407,38 +330,31 @@ static void tag_slave_target_detected_thread_func(gpointer user_data)
 
                NFC_DBG("support NDEF");
 
-               if (tag_read_ndef_message(target->handle,
-                                       target->devType,
-                                       &recv_data) == TRUE)
+               if (tag_read_ndef_message(target->handle, target->devType, &recv_data) == TRUE)
                {
-                       ndef_message_s *selector;
                        ndef_record_s *record;
+                       ndef_message_s *selector;
                        ndef_record_s *recordasperpriority;
-                       result = net_nfc_server_handover_create_selector_from_rawdata(
-                                       &selector,
+
+                       result = net_nfc_server_handover_create_selector_from_rawdata(&selector,
                                        recv_data);
 
-                       if (result == NET_NFC_OK)
+                       if (NET_NFC_OK == result)
                        {
-                               result =
-                                       net_nfc_server_handover_get_carrier_record_by_priority_order(
-                                                       selector,
-                                                       &record);
+                               result = net_nfc_server_handover_get_carrier_record_by_priority_order(
+                                                       selector, &record);
                                isHandoverMessage = true;
-                               if (result == NET_NFC_OK)
+                               if (NET_NFC_OK == result)
                                {
-                                       net_nfc_util_create_record(
-                                                       record->TNF,
-                                                       &record->type_s, &record->id_s,
-                                                       &record->payload_s,
-                                                       &recordasperpriority);
+                                       net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+                                                       &record->payload_s, &recordasperpriority);
 
-                                       net_nfc_server_handover_process_carrier_record(recordasperpriority, NULL, NULL);
+                                       net_nfc_server_handover_process_carrier_record(recordasperpriority,
+                                                       NULL, NULL);
                                }
                                else
                                {
-                                       NFC_ERR("_get_carrier_record_by_priority_order"
-                                                       " failed, [%d]",result);
+                                       NFC_ERR("_get_carrier_record_by_priority_order failed, [%d]",result);
                                }
                        }
                        else
@@ -484,7 +400,7 @@ static void tag_slave_target_detected_thread_func(gpointer user_data)
        NFC_DBG("turn on watch dog");
 
        watch_dog = g_new0(WatchDogData, 1);
-       if(watch_dog == NULL)
+       if(NULL == watch_dog)
        {
                NFC_ERR("Memory allocation failed");
                return;
@@ -494,8 +410,7 @@ static void tag_slave_target_detected_thread_func(gpointer user_data)
        watch_dog->handle = target->handle;
 
        if (net_nfc_server_controller_async_queue_push(
-                               tag_watchdog_thread_func,
-                               watch_dog) == FALSE)
+                               tag_watchdog_thread_func, watch_dog) == FALSE)
        {
                NFC_ERR("can not create watch dog");
                g_free(watch_dog);
@@ -505,24 +420,23 @@ static void tag_slave_target_detected_thread_func(gpointer user_data)
 
 
 static gboolean tag_handle_is_tag_connected(NetNfcGDbusTag *tag,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data)
+               GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
 {
        /* FIXME : net_nfc_current_target_info_s should be removed */
+       bool ret;
+       gint result;
+       gboolean is_connected = FALSE;
        net_nfc_current_target_info_s *target_info;
        net_nfc_target_type_e dev_type = NET_NFC_UNKNOWN_TARGET;
-       gboolean is_connected = FALSE;
-       gint result;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::tag",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::tag", "r");
+
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
                result = NET_NFC_SECURITY_FAIL;
 
@@ -539,43 +453,37 @@ static gboolean tag_handle_is_tag_connected(NetNfcGDbusTag *tag,
        result = NET_NFC_OK;
 
 END :
-       net_nfc_gdbus_tag_complete_is_tag_connected(tag,
-                       invocation,
-                       result,
-                       is_connected,
+       net_nfc_gdbus_tag_complete_is_tag_connected(tag, invocation, result, is_connected,
                        (gint32)dev_type);
 
        return TRUE;
 }
 
 static gboolean tag_handle_get_current_tag_info(NetNfcGDbusTag *tag,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data)
+               GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
 {
-       CurrentTagInfoData *info_data;
+       bool ret;
        gboolean result;
+       CurrentTagInfoData *info_data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::tag",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::tag", "r");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        info_data = g_new0(CurrentTagInfoData, 1);
-       if (info_data == NULL)
+       if (NULL == info_data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -584,9 +492,8 @@ static gboolean tag_handle_get_current_tag_info(NetNfcGDbusTag *tag,
        info_data->invocation = g_object_ref(invocation);
 
        result = net_nfc_server_controller_async_queue_push(
-                       tag_get_current_tag_info_thread_func,
-                       info_data);
-       if (result == FALSE)
+                       tag_get_current_tag_info_thread_func, info_data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.ThreadError",
@@ -602,24 +509,22 @@ static gboolean tag_handle_get_current_tag_info(NetNfcGDbusTag *tag,
 }
 
 static gboolean tag_handle_get_current_target_handle(NetNfcGDbusTag *tag,
-               GDBusMethodInvocation *invocation,
-               GVariant *smack_privilege,
-               gpointer user_data)
+               GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
 {
        /* FIXME : net_nfc_current_target_info_s should be removed */
-       net_nfc_current_target_info_s *target_info;
+       gint result;
+       gboolean ret;
        net_nfc_target_handle_s *handle = NULL;
        uint32_t devType = NET_NFC_UNKNOWN_TARGET;
-       gint result;
+       net_nfc_current_target_info_s *target_info;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager::p2p",
-                               "r") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager::p2p", "r");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
                result = NET_NFC_SECURITY_FAIL;
 
@@ -636,12 +541,8 @@ static gboolean tag_handle_get_current_target_handle(NetNfcGDbusTag *tag,
        result = NET_NFC_OK;
 
 END :
-       net_nfc_gdbus_tag_complete_get_current_target_handle(tag,
-                       invocation,
-                       result,
-                       (handle != NULL),
-                       GPOINTER_TO_UINT(handle),
-                       devType);
+       net_nfc_gdbus_tag_complete_get_current_target_handle(tag, invocation, result,
+                       (handle != NULL), GPOINTER_TO_UINT(handle), devType);
 
        return TRUE;
 }
@@ -649,35 +550,26 @@ END :
 
 gboolean net_nfc_server_tag_init(GDBusConnection *connection)
 {
-       GError *error = NULL;
        gboolean result;
+       GError *error = NULL;
 
        if (tag_skeleton)
                net_nfc_server_tag_deinit();
 
        tag_skeleton = net_nfc_gdbus_tag_skeleton_new();
 
-       g_signal_connect(tag_skeleton,
-                       "handle-is-tag-connected",
-                       G_CALLBACK(tag_handle_is_tag_connected),
-                       NULL);
-
-       g_signal_connect(tag_skeleton,
-                       "handle-get-current-tag-info",
-                       G_CALLBACK(tag_handle_get_current_tag_info),
-                       NULL);
-
-       g_signal_connect(tag_skeleton,
-                       "handle-get-current-target-handle",
-                       G_CALLBACK(tag_handle_get_current_target_handle),
-                       NULL);
-
-       result = g_dbus_interface_skeleton_export(
-                       G_DBUS_INTERFACE_SKELETON(tag_skeleton),
-                       connection,
-                       "/org/tizen/NetNfcService/Tag",
-                       &error);
-       if (result == FALSE)
+       g_signal_connect(tag_skeleton, "handle-is-tag-connected",
+                       G_CALLBACK(tag_handle_is_tag_connected), NULL);
+
+       g_signal_connect(tag_skeleton, "handle-get-current-tag-info",
+                       G_CALLBACK(tag_handle_get_current_tag_info), NULL);
+
+       g_signal_connect(tag_skeleton, "handle-get-current-target-handle",
+                       G_CALLBACK(tag_handle_get_current_target_handle), NULL);
+
+       result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(tag_skeleton),
+                       connection, "/org/tizen/NetNfcService/Tag", &error);
+       if (FALSE == result)
        {
                NFC_ERR("can not skeleton_export %s", error->message);
 
@@ -707,8 +599,7 @@ void net_nfc_server_set_target_info(void *info)
 
        target = (net_nfc_request_target_detected_t *)info;
 
-       current_target_info = g_malloc0(
-                       sizeof(net_nfc_current_target_info_s) +
+       current_target_info = g_malloc0(sizeof(net_nfc_current_target_info_s) +
                        target->target_info_values.length);
 
        current_target_info->handle = target->handle;
@@ -734,7 +625,7 @@ net_nfc_current_target_info_s *net_nfc_server_get_target_info(void)
 
 gboolean net_nfc_server_target_connected(net_nfc_target_handle_s *handle)
 {
-       if (current_target_info == NULL)
+       if (NULL == current_target_info)
                return FALSE;
 
        if (current_target_info->handle != handle)
@@ -751,10 +642,11 @@ void net_nfc_server_free_target_info(void)
 
 void net_nfc_server_tag_target_detected(void *info)
 {
-       if (net_nfc_server_controller_async_queue_push(
-                               tag_slave_target_detected_thread_func,
-                               NULL) == FALSE)
-       {
+       gboolean ret;
+
+       ret = net_nfc_server_controller_async_queue_push(
+                               tag_slave_target_detected_thread_func, NULL);
+
+       if (FALSE == ret)
                NFC_ERR("can not push to controller thread");
-       }
 }
index 573becc..7359f7f 100644 (file)
 
 static NetNfcGDbusTransceive *transceive_skeleton = NULL;
 
-static void transceive_thread_func(gpointer user_data);
-
-static void transceive_data_thread_func(gpointer user_data);
-
-static gboolean transceive_handle(NetNfcGDbusTransceive *transceive,
-               GDBusMethodInvocation *invocation,
-               guint handle,
-               guint dev_type,
-               GVariant *arg_data,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
-static gboolean transceive_data_handle(NetNfcGDbusTransceive *transceive,
-               GDBusMethodInvocation *invocation,
-               guint handle,
-               guint dev_type,
-               GVariant *arg_data,
-               GVariant *smack_privilege,
-               gpointer user_data);
-
 
 typedef struct _TransceiveSendData TransceiveSendData;
 
@@ -61,12 +41,13 @@ struct _TransceiveSendData
 
 static void transceive_data_thread_func(gpointer user_data)
 {
+       bool ret;
+       data_s *data = NULL;
+       GVariant *resp_data = NULL;
+       net_nfc_error_e result = NET_NFC_OK;
        TransceiveSendData *transceive_data = user_data;
        net_nfc_target_handle_s *handle =
                (net_nfc_target_handle_s *)transceive_data->transceive_handle;
-       net_nfc_error_e result = NET_NFC_OK;
-       data_s *data = NULL;
-       GVariant *resp_data = NULL;
 
        /* use assert because it was checked in handle function */
        g_assert(transceive_data != NULL);
@@ -77,10 +58,10 @@ static void transceive_data_thread_func(gpointer user_data)
        {
                NFC_DBG("call transceive");
 
-               if (net_nfc_controller_transceive(handle,
-                                       &transceive_data->transceive_info,
-                                       &data,
-                                       &result) == true)
+               ret = net_nfc_controller_transceive(handle, &transceive_data->transceive_info,
+                                       &data, &result);
+
+               if (true == ret)
                {
                        if (data != NULL)
                                NFC_DBG("Transceive data received [%d]", data->length);
@@ -95,11 +76,8 @@ static void transceive_data_thread_func(gpointer user_data)
 
        resp_data = net_nfc_util_gdbus_data_to_variant(data);
 
-       net_nfc_gdbus_transceive_complete_transceive_data(
-                       transceive_data->transceive,
-                       transceive_data->invocation,
-                       (gint)result,
-                       resp_data);
+       net_nfc_gdbus_transceive_complete_transceive_data(transceive_data->transceive,
+                       transceive_data->invocation, (gint)result, resp_data);
 
        if (data)
        {
@@ -123,29 +101,28 @@ static gboolean transceive_data_handle(NetNfcGDbusTransceive *transceive,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       TransceiveSendData *data;
+       bool ret;
        gboolean result;
+       TransceiveSendData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_new0(TransceiveSendData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -154,12 +131,10 @@ static gboolean transceive_data_handle(NetNfcGDbusTransceive *transceive,
        data->invocation = g_object_ref(invocation);
        data->transceive_handle = handle;
        data->transceive_info.dev_type = dev_type;
-       net_nfc_util_gdbus_variant_to_data_s(arg_data,
-                       &data->transceive_info.trans_data);
+       net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->transceive_info.trans_data);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       transceive_data_thread_func, data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(transceive_data_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Transceive.ThreadError",
@@ -178,11 +153,12 @@ static gboolean transceive_data_handle(NetNfcGDbusTransceive *transceive,
 
 static void transceive_thread_func(gpointer user_data)
 {
+       bool ret;
+       data_s *data = NULL;
+       net_nfc_error_e result = NET_NFC_OK;
        TransceiveSendData *transceive_data = user_data;
        net_nfc_target_handle_s *handle =
                (net_nfc_target_handle_s *)transceive_data->transceive_handle;
-       net_nfc_error_e result = NET_NFC_OK;
-       data_s *data = NULL;
 
        /* use assert because it was checked in handle function */
        g_assert(transceive_data != NULL);
@@ -192,11 +168,9 @@ static void transceive_thread_func(gpointer user_data)
        if (net_nfc_server_target_connected(handle) == true)
        {
                NFC_DBG("call transceive");
-
-               if (net_nfc_controller_transceive(handle,
-                                       &transceive_data->transceive_info,
-                                       &data,
-                                       &result) == true)
+               ret = net_nfc_controller_transceive(handle, &transceive_data->transceive_info,
+                                       &data, &result);
+               if (true == ret)
                {
                        if (data != NULL)
                        {
@@ -217,10 +191,8 @@ static void transceive_thread_func(gpointer user_data)
 
        NFC_DBG("transceive result : %d", result);
 
-       net_nfc_gdbus_transceive_complete_transceive(
-                       transceive_data->transceive,
-                       transceive_data->invocation,
-                       (gint)result);
+       net_nfc_gdbus_transceive_complete_transceive(transceive_data->transceive,
+                       transceive_data->invocation, (gint)result);
 
        net_nfc_util_free_data(&transceive_data->transceive_info.trans_data);
 
@@ -238,29 +210,28 @@ static gboolean transceive_handle(NetNfcGDbusTransceive *transceive,
                GVariant *smack_privilege,
                gpointer user_data)
 {
-       TransceiveSendData *data;
+       bool ret;
        gboolean result;
+       TransceiveSendData *data;
 
-       NFC_INFO(">>> REQUEST from [%s]",
-                       g_dbus_method_invocation_get_sender(invocation));
+       NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
 
        /* check privilege and update client context */
-       if (net_nfc_server_gdbus_check_privilege(invocation,
-                               smack_privilege,
-                               "nfc-manager",
-                               "rw") == false) {
+       ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+                               "nfc-manager", "rw");
+       if (false == ret)
+       {
                NFC_ERR("permission denied, and finished request");
 
                return FALSE;
        }
 
        data = g_new0(TransceiveSendData, 1);
-       if (data == NULL)
+       if (NULL == data)
        {
                NFC_ERR("Memory allocation failed");
                g_dbus_method_invocation_return_dbus_error(invocation,
-                               "org.tizen.NetNfcService.AllocationError",
-                               "Can not allocate memory");
+                               "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
 
                return FALSE;
        }
@@ -272,9 +243,8 @@ static gboolean transceive_handle(NetNfcGDbusTransceive *transceive,
        net_nfc_util_gdbus_variant_to_data_s(arg_data,
                        &data->transceive_info.trans_data);
 
-       result = net_nfc_server_controller_async_queue_push(
-                       transceive_thread_func, data);
-       if (result == FALSE)
+       result = net_nfc_server_controller_async_queue_push(transceive_thread_func, data);
+       if (FALSE == result)
        {
                g_dbus_method_invocation_return_dbus_error(invocation,
                                "org.tizen.NetNfcService.Transceive.ThreadError",
@@ -294,30 +264,26 @@ static gboolean transceive_handle(NetNfcGDbusTransceive *transceive,
 
 gboolean net_nfc_server_transceive_init(GDBusConnection *connection)
 {
-       GError *error = NULL;
        gboolean result;
+       GError *error = NULL;
 
        if (transceive_skeleton)
                g_object_unref(transceive_skeleton);
 
        transceive_skeleton = net_nfc_gdbus_transceive_skeleton_new();
 
-       g_signal_connect(transceive_skeleton,
-                       "handle-transceive-data",
-                       G_CALLBACK(transceive_data_handle),
-                       NULL);
+       g_signal_connect(transceive_skeleton, "handle-transceive-data",
+                       G_CALLBACK(transceive_data_handle), NULL);
 
-       g_signal_connect(transceive_skeleton,
-                       "handle-transceive",
-                       G_CALLBACK(transceive_handle),
-                       NULL);
+       g_signal_connect(transceive_skeleton, "handle-transceive",
+                       G_CALLBACK(transceive_handle), NULL);
 
        result = g_dbus_interface_skeleton_export(
                        G_DBUS_INTERFACE_SKELETON(transceive_skeleton),
                        connection,
                        "/org/tizen/NetNfcService/Transceive",
                        &error);
-       if (result == FALSE)
+       if (FALSE == result)
        {
                g_error_free(error);
                g_object_unref(transceive_skeleton);
index f597928..9014fc5 100644 (file)
 #include "net_nfc_server_se.h"
 #include "net_nfc_server_util.h"
 
-#define NET_NFC_MANAGER_SOUND_PATH_TASK_START  "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
-#define NET_NFC_MANAGER_SOUND_PATH_TASK_END    "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
-#define NET_NFC_MANAGER_SOUND_PATH_TASK_ERROR  "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
+#define NET_NFC_MANAGER_SOUND_PATH_TASK_START \
+               "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
+
+#define NET_NFC_MANAGER_SOUND_PATH_TASK_END \
+               "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
+
+#define NET_NFC_MANAGER_SOUND_PATH_TASK_ERROR \
+               "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
 
 #define OSP_K_COND             "__OSP_COND_NAME__"
 #define OSP_K_COND_TYPE                "nfc"
@@ -117,13 +122,12 @@ static bool _net_nfc_app_util_change_file_owner_permission(FILE *file)
 {
        char *buffer = NULL;
        size_t buffer_len = 0;
-       struct passwd pwd = { 0, };
-       struct passwd *pw_inhouse = NULL;
        struct group grp = { 0, };
+       struct passwd pwd = { 0, };
        struct group *gr_inhouse = NULL;
+       struct passwd *pw_inhouse = NULL;
 
-       if (file == NULL)
-               return false;
+       RETV_IF(NULL == file, false);
 
        /* change permission */
        fchmod(fileno(file), 0777);
@@ -132,12 +136,10 @@ static bool _net_nfc_app_util_change_file_owner_permission(FILE *file)
        /* get passwd id */
        buffer_len = sysconf(_SC_GETPW_R_SIZE_MAX);
        if (buffer_len == -1)
-       {
                buffer_len = 16384;
-       }
 
        _net_nfc_util_alloc_mem(buffer, buffer_len);
-       if (buffer == NULL)
+       if (NULL == buffer)
                return false;
 
        getpwnam_r("inhouse", &pwd, buffer, buffer_len, &pw_inhouse);
@@ -146,12 +148,10 @@ static bool _net_nfc_app_util_change_file_owner_permission(FILE *file)
        /* get group id */
        buffer_len = sysconf(_SC_GETGR_R_SIZE_MAX);
        if (buffer_len == -1)
-       {
                buffer_len = 16384;
-       }
 
        _net_nfc_util_alloc_mem(buffer, buffer_len);
-       if (buffer == NULL)
+       if (NULL == buffer)
                return false;
 
        getgrnam_r("inhouse", &grp, buffer, buffer_len, &gr_inhouse);
@@ -160,9 +160,7 @@ static bool _net_nfc_app_util_change_file_owner_permission(FILE *file)
        if ((pw_inhouse != NULL) && (gr_inhouse != NULL))
        {
                if (fchown(fileno(file), pw_inhouse->pw_uid, gr_inhouse->gr_gid) < 0)
-               {
                        NFC_ERR("failed to change owner");
-               }
        }
 
        return true;
@@ -171,14 +169,11 @@ static bool _net_nfc_app_util_change_file_owner_permission(FILE *file)
 static net_nfc_error_e net_nfc_app_util_store_ndef_message(data_s *data)
 {
        int ret;
-       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
-       char file_name[1024] = { 0, };
        FILE *fp = NULL;
+       char file_name[1024] = { 0, };
+       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
 
-       if (data == NULL)
-       {
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
 
        /* check and make directory */
        snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_MANAGER_DATA_PATH,
@@ -225,15 +220,15 @@ static net_nfc_error_e net_nfc_app_util_store_ndef_message(data_s *data)
        return result;
 }
 
-static bool _net_nfc_app_util_get_operation_from_record(ndef_record_s *record, char *operation, size_t length)
+static bool _net_nfc_app_util_get_operation_from_record(
+               ndef_record_s *record, char *operation, size_t length)
 {
        bool result = false;
        char *op_text = NULL;
 
-       if (record == NULL || operation == NULL || length == 0)
-       {
-               return result;
-       }
+       RETV_IF(NULL == record, result);
+       RETV_IF(NULL == operation, result);
+       RETV_IF(0 == length, result);
 
        switch (record->TNF)
        {
@@ -288,14 +283,14 @@ static void _to_lower(int type, char *str)
        _to_lower_utf_8(str);
 }
 
-static bool _net_nfc_app_util_get_mime_from_record(ndef_record_s *record, char *mime, size_t length)
+static bool _net_nfc_app_util_get_mime_from_record(
+               ndef_record_s *record, char *mime, size_t length)
 {
        bool result = false;
 
-       if (record == NULL || mime == NULL || length == 0)
-       {
-               return result;
-       }
+       RETV_IF(NULL == record, result);
+       RETV_IF(NULL == mime, result);
+       RETV_IF(0 == length, result);
 
        switch (record->TNF)
        {
@@ -327,9 +322,9 @@ static bool _net_nfc_app_util_get_mime_from_record(ndef_record_s *record, char *
 
        case NET_NFC_RECORD_MIME_TYPE :
                {
+                       int len = 0;
                        char *token = NULL;
                        char *buffer = NULL;
-                       int len = 0;
 
                        if (record->type_s.buffer == NULL || record->type_s.length == 0)
                        {
@@ -339,7 +334,7 @@ static bool _net_nfc_app_util_get_mime_from_record(ndef_record_s *record, char *
 
                        /* get mime type */
                        _net_nfc_util_alloc_mem(buffer, record->type_s.length + 1);
-                       if (buffer == NULL)
+                       if (NULL == buffer)
                        {
                                NFC_ERR("_net_nfc_manager_util_alloc_mem return NULL");
                                break;
@@ -348,13 +343,9 @@ static bool _net_nfc_app_util_get_mime_from_record(ndef_record_s *record, char *
 
                        token = strchr(buffer, ';');
                        if (token != NULL)
-                       {
                                len = MIN(token - buffer, length - 1);
-                       }
                        else
-                       {
                                len = MIN(strlen(buffer), length - 1);
-                       }
 
                        strncpy(mime, buffer, len);
                        mime[len] = '\0';
@@ -387,10 +378,9 @@ static bool _net_nfc_app_util_get_uri_from_record(ndef_record_s *record, char *d
 {
        bool result = false;
 
-       if (record == NULL || data == NULL || length == 0)
-       {
-               return result;
-       }
+       RETV_IF(NULL == record, result);
+       RETV_IF(NULL == data, result);
+       RETV_IF(0 == length, result);
 
        switch (record->TNF)
        {
@@ -467,10 +457,9 @@ static bool _net_nfc_app_util_get_data_from_record(ndef_record_s *record, char *
 {
        bool result = false;
 
-       if (record == NULL || data == NULL || length == 0)
-       {
-               return result;
-       }
+       RETV_IF(NULL == record, result);
+       RETV_IF(NULL == data, result);
+       RETV_IF(0 == length, result);
 
        switch (record->TNF)
        {
@@ -516,21 +505,19 @@ static bool _net_nfc_app_util_get_data_from_record(ndef_record_s *record, char *
 
 net_nfc_error_e net_nfc_app_util_process_ndef(data_s *data)
 {
-       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
-       ndef_message_s *msg = NULL;
-       char operation[2048] = { 0, };
+       int ret = 0;
        char mime[2048] = { 0, };
        char text[2048] = { 0, };
+       ndef_message_s *msg = NULL;
+       char operation[2048] = { 0, };
+       net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
 #ifdef USE_FULL_URI
        char uri[2048] = { 0, };
 #endif
-       int ret = 0;
 
-       if (data == NULL || data->buffer == NULL || data->length == 0)
-       {
-               NFC_ERR("net_nfc_app_util_process_ndef NET_NFC_NULL_PARAMETER");
-               return NET_NFC_NULL_PARAMETER;
-       }
+       RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == data->buffer, NET_NFC_NULL_PARAMETER);
+       RETV_IF(NULL == data->length, NET_NFC_NULL_PARAMETER);
 
        /* create file */
        if ((result = net_nfc_app_util_store_ndef_message(data)) != NET_NFC_OK)
@@ -560,7 +547,8 @@ net_nfc_error_e net_nfc_app_util_process_ndef(data_s *data)
                goto ERROR;
        }
 
-       if (_net_nfc_app_util_get_operation_from_record(msg->records, operation, sizeof(operation)) == FALSE)
+       if (_net_nfc_app_util_get_operation_from_record(msg->records, operation,
+                               sizeof(operation)) == FALSE)
        {
                NFC_ERR("_net_nfc_app_util_get_operation_from_record failed [%d]", result);
                result = NET_NFC_UNKNOWN_ERROR;
@@ -613,31 +601,21 @@ static bool net_nfc_app_util_is_dir(const char* path_name)
        struct stat statbuf = { 0 };
 
        if (stat(path_name, &statbuf) == -1)
-       {
                return false;
-       }
 
        if (S_ISDIR(statbuf.st_mode) != 0)
-       {
                return true;
-       }
        else
-       {
                return false;
-       }
 }
 
 void net_nfc_app_util_clean_storage(char* src_path)
 {
-       struct dirent* ent = NULL;
        DIR* dir = NULL;
-
        char path[1024] = { 0 };
+       struct dirent* ent = NULL;
 
-       if ((dir = opendir(src_path)) == NULL)
-       {
-               return;
-       }
+       RET_IF((dir = opendir(src_path)) == NULL);
 
        while ((ent = readdir(dir)) != NULL)
        {
@@ -700,7 +678,7 @@ int net_nfc_app_util_appsvc_launch(const char *operation, const char *uri, const
        bundle *bd = NULL;
 
        bd = bundle_create();
-       if (bd == NULL)
+       if (NULL == bd)
                return result;
 
        if (operation != NULL && strlen(operation) > 0)
@@ -741,8 +719,10 @@ void _binary_to_string(uint8_t *buffer, uint32_t len, char *out_buf, uint32_t ma
 {
        int current = 0;
 
-       if (buffer == NULL || len == 0 || out_buf == NULL || max_len == 0)
-               return;
+       RET_IF(0 == len);
+       RET_IF(0 == max_len);
+       RET_IF(NULL == buffer);
+       RET_IF(NULL == out_buf);
 
        while (len > 0 && current < max_len)
        {
@@ -753,12 +733,13 @@ void _binary_to_string(uint8_t *buffer, uint32_t len, char *out_buf, uint32_t ma
 
 void _string_to_binary(const char *input, uint8_t *output, uint32_t *length)
 {
-       int current = 0;
        int temp;
+       int current = 0;
 
-       if (input == NULL || *length == 0 || output == NULL)
-               return;
-
+       RET_IF(NULL == input);
+       RET_IF(NULL == length);
+       RET_IF(0 == *length);
+       RET_IF(NULL == output);
        NFC_DBG("_string_to_binary ");
 
        /* strlen("nfc://secure/aid/") = 17 */
@@ -773,13 +754,9 @@ void _string_to_binary(const char *input, uint8_t *output, uint32_t *length)
                        temp -= 7;
 
                if(current % 2)
-               {
                        output[current / 2] += temp;
-               }
                else
-               {
                        output[current / 2] = temp << 4;
-               }
 
                current++;
        }
@@ -787,8 +764,12 @@ void _string_to_binary(const char *input, uint8_t *output, uint32_t *length)
        *length = current / 2;
 }
 
-int net_nfc_app_util_launch_se_transaction_app(net_nfc_secure_element_type_e se_type,
-               uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len)
+int net_nfc_app_util_launch_se_transaction_app(
+               net_nfc_secure_element_type_e se_type,
+               uint8_t *aid,
+               uint32_t aid_len,
+               uint8_t *param,
+               uint32_t param_len)
 {
        bundle *bd = NULL;
 
@@ -844,8 +825,10 @@ int net_nfc_app_util_encode_base64(uint8_t *buffer, uint32_t buf_len, char *resu
        BUF_MEM *bptr;
        BIO *b64, *bmem;
 
-       if (buffer == NULL || buf_len == 0 || result == NULL || max_result == 0)
-               return ret;
+       RETV_IF(NULL == buffer, ret);
+       RETV_IF(0 == buf_len, ret);
+       RETV_IF(NULL == result, ret);
+       RETV_IF(0 == max_result, ret);
 
        /* base 64 */
        b64 = BIO_new(BIO_f_base64());
@@ -872,8 +855,11 @@ int net_nfc_app_util_decode_base64(const char *buffer, uint32_t buf_len, uint8_t
        int ret = -1;
        char *temp = NULL;
 
-       if (buffer == NULL || buf_len == 0 || result == NULL || res_len == NULL || *res_len == 0)
-               return ret;
+       RETV_IF(NULL == buffer, ret);
+       RETV_IF(0 == buf_len, ret);
+       RETV_IF(NULL == result, ret);
+       RETV_IF(NULL == res_len, ret);
+       RETV_IF(0 == *res_len, ret);
 
        _net_nfc_util_alloc_mem(temp, buf_len);
        if (temp != NULL)
@@ -909,8 +895,8 @@ int net_nfc_app_util_decode_base64(const char *buffer, uint32_t buf_len, uint8_t
 
 pid_t net_nfc_app_util_get_focus_app_pid()
 {
-       Ecore_X_Window focus;
        pid_t pid;
+       Ecore_X_Window focus;
 
        ecore_x_init(":0");
 
@@ -923,15 +909,15 @@ pid_t net_nfc_app_util_get_focus_app_pid()
 
 bool net_nfc_app_util_check_launch_state()
 {
+       bool result = false;
        pid_t focus_app_pid;
        net_nfc_launch_popup_state_e popup_state;
-       bool result = false;
 
        focus_app_pid = net_nfc_app_util_get_focus_app_pid();
 
        popup_state = net_nfc_server_gdbus_get_client_popup_state(focus_app_pid);
 
-       if(popup_state == NET_NFC_NO_LAUNCH_APP_SELECT)
+       if(NET_NFC_NO_LAUNCH_APP_SELECT == popup_state)
                result = true;
 
        return result;
@@ -942,9 +928,7 @@ static void _play_sound_callback(int id, void *data)
        NFC_DBG("_play_sound_callback");
 
        if (WAV_PLAYER_ERROR_NONE != wav_player_stop(id))
-       {
                NFC_ERR("wav_player_stop failed");
-       }
 }
 
 void net_nfc_manager_util_play_sound(net_nfc_sound_type_e sound_type)
@@ -979,9 +963,7 @@ void net_nfc_manager_util_play_sound(net_nfc_sound_type_e sound_type)
                if (SVI_SUCCESS == svi_init(&svi_handle))
                {
                        if (SVI_SUCCESS == svi_play_vib(svi_handle, SVI_VIB_TOUCH_SIP))
-                       {
                                NFC_DBG("svi_play_vib success");
-                       }
 
                        svi_fini(svi_handle);
                }
@@ -1008,7 +990,9 @@ void net_nfc_manager_util_play_sound(net_nfc_sound_type_e sound_type)
 
                if (sound_path != NULL)
                {
-                       if (WAV_PLAYER_ERROR_NONE == wav_player_start(sound_path, SOUND_TYPE_MEDIA, _play_sound_callback, NULL, NULL))
+                       if (WAV_PLAYER_ERROR_NONE ==
+                               wav_player_start(sound_path, SOUND_TYPE_MEDIA, _play_sound_callback,
+                                       NULL, NULL))
                        {
                                NFC_DBG("wav_player_start success");
                        }
index 3b1ffe3..bed8ba9 100644 (file)
@@ -43,25 +43,21 @@ static void vconf_set_flight_mode(int boolval)
        /* set predefined item */
        result = vconf_set_bool(VCONFKEY_NFC_PREDEFINED_ITEM_STATE, boolval);
        if (result != 0)
-       {
-               NFC_ERR("can not set to %d: %s",
-                               boolval,
-                               "VCONKEY_NFC_PREDEFINED_ITEM_STATE");
-       }
+               NFC_ERR("can not set to %d: %s", boolval, "VCONKEY_NFC_PREDEFINED_ITEM_STATE");
 }
 
 static void net_nfc_server_vconf_pm_state_changed(keynode_t *key,
                void *user_data)
 {
+       gint result;
        gint state = 0;
        gint pm_state = 0;
-       gint result;
 
        result = vconf_get_bool(VCONFKEY_NFC_STATE, &state);
        if (result != 0)
                NFC_ERR("can not get %s", "VCONFKEY_NFC_STATE");
 
-       if (state == false)
+       if (false == state)
        {
                NFC_DBG("NFC off");
                return;
@@ -73,36 +69,27 @@ static void net_nfc_server_vconf_pm_state_changed(keynode_t *key,
 
        NFC_DBG("pm_state : %d", pm_state);
 
-       if (pm_state == VCONFKEY_PM_STATE_NORMAL ||
-                       pm_state == VCONFKEY_PM_STATE_LCDOFF)
-       {
+       if (VCONFKEY_PM_STATE_NORMAL == pm_state || VCONFKEY_PM_STATE_LCDOFF == pm_state)
                net_nfc_server_restart_polling_loop();
-       }
 }
 
 static void net_nfc_server_vconf_flight_mode_changed(keynode_t *key,
                void *user_data)
 {
-       gint flight_mode = 0;
+       gint result = 0;
        gint nfc_state = 0;
+       gint flight_mode = 0;
 
-       gint result = 0;
 
        result = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
        if (result != 0)
-       {
-               NFC_ERR("Can not get %s",
-                               "VCONFKEY_TELEPHONY_FLIGHT_MODE");
-       }
+               NFC_ERR("Can not get VCONFKEY_TELEPHONY_FLIGHT_MODE");
 
        NFC_DBG("flight mode %d", flight_mode);
 
        result = vconf_get_bool(VCONFKEY_NFC_STATE, &nfc_state);
        if (result != 0)
-       {
-               NFC_ERR("Can not get %s",
-                               "VCONFKEY_NET_STATE");
-       }
+               NFC_ERR("Can not get VCONFKEY_NET_STATE");
 
        NFC_DBG("nfc_state %d", nfc_state);
        NFC_DBG("powerd_off_by_flightmode %d", powered_off_by_flightmode);
@@ -110,7 +97,7 @@ static void net_nfc_server_vconf_flight_mode_changed(keynode_t *key,
        if (flight_mode) /* turn on flight mode */
        {
                /* nfc is already disabled ignore it */
-               if (nfc_state == VCONFKEY_NFC_STATE_OFF)
+               if (VCONFKEY_NFC_STATE_OFF == nfc_state)
                        return;
 
                NFC_INFO("Turning NFC off");
@@ -123,10 +110,10 @@ static void net_nfc_server_vconf_flight_mode_changed(keynode_t *key,
        else /* turn off flight mode */
        {
                /* nfc is already enabled, ignre it */
-               if (nfc_state == VCONFKEY_NFC_STATE_ON)
+               if (VCONFKEY_NFC_STATE_ON == nfc_state)
                        return;
 
-               if (powered_off_by_flightmode == FALSE)
+               if (FALSE == powered_off_by_flightmode)
                        return;
 
                NFC_INFO("Turning NFC on");
@@ -141,18 +128,15 @@ static void net_nfc_server_vconf_flight_mode_changed(keynode_t *key,
 void net_nfc_server_vconf_init(void)
 {
        vconf_notify_key_changed(VCONFKEY_PM_STATE,
-                       net_nfc_server_vconf_pm_state_changed,
-                       NULL);
+                       net_nfc_server_vconf_pm_state_changed, NULL);
 
        vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                       net_nfc_server_vconf_flight_mode_changed,
-                       NULL);
+                       net_nfc_server_vconf_flight_mode_changed, NULL);
 }
 
 void net_nfc_server_vconf_deinit(void)
 {
-       vconf_ignore_key_changed(VCONFKEY_PM_STATE,
-                       net_nfc_server_vconf_pm_state_changed);
+       vconf_ignore_key_changed(VCONFKEY_PM_STATE, net_nfc_server_vconf_pm_state_changed);
 
        vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
                        net_nfc_server_vconf_flight_mode_changed);