Fix crash problem when ipc was failed
authorWonkyu Kwon <wonkyu.kwon@samsung.com>
Mon, 7 Oct 2013 23:49:40 +0000 (08:49 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Mon, 7 Oct 2013 23:49:40 +0000 (08:49 +0900)
Revise initializations

Change-Id: I481dce63ed8d61f61705720e211121607404d714

client/net_nfc_client_handover.c
client/net_nfc_client_llcp.c
client/net_nfc_client_manager.c
client/net_nfc_client_ndef.c
client/net_nfc_client_se.c
client/net_nfc_client_snep.c
client/net_nfc_client_system_handler.c
client/net_nfc_client_tag.c
client/net_nfc_client_transceive.c

index 24a908f..5e90ee0 100644 (file)
@@ -38,7 +38,7 @@ static void p2p_connection_handover(GObject *source_object,
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
        GVariant *data = NULL;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        net_nfc_conn_handover_carrier_type_e type =
                NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN;
        GError *error = NULL;
index c134aac..51eb3d7 100644 (file)
@@ -132,7 +132,7 @@ static void llcp_call_listen(GObject *source_object, GAsyncResult *res,
        gboolean ret;
        GError *error = NULL;
        net_nfc_error_e result;
-       guint32 out_client_socket;
+       guint32 out_client_socket = -1;
        LlcpFuncData *func_data = user_data;
        net_nfc_llcp_internal_socket_s *socket_data = NULL;
 
@@ -232,7 +232,7 @@ static void llcp_call_connect(GObject *source_object, GAsyncResult *res,
        gboolean ret;
        GError *error = NULL;
        net_nfc_error_e result;
-       guint32 out_client_socket;
+       guint32 out_client_socket = -1;
        LlcpFuncData *func_data = user_data;
        net_nfc_llcp_internal_socket_s *socket_data = NULL;
 
@@ -273,7 +273,7 @@ static void llcp_call_connect_sap(GObject *source_object,
        gboolean ret;
        GError *error = NULL;
        net_nfc_error_e result;
-       guint32 out_client_socket;
+       guint32 out_client_socket = -1;
        LlcpFuncData *func_data = user_data;
        net_nfc_llcp_internal_socket_s *socket_data = NULL;
 
@@ -313,7 +313,7 @@ static void llcp_call_send(GObject *source_object, GAsyncResult *res,
        gboolean ret;
        GError *error = NULL;
        net_nfc_error_e result;
-       guint32 out_client_socket;
+       guint32 out_client_socket = -1;
        LlcpFuncData *func_data = user_data;
 
        g_assert(func_data != NULL);
@@ -344,7 +344,7 @@ static void llcp_call_send_to(GObject *source_object, GAsyncResult *res,
        gboolean ret;
        GError *error = NULL;
        net_nfc_error_e result;
-       guint32 out_client_socket;
+       guint32 out_client_socket = -1;
        LlcpFuncData *func_data = user_data;
 
        g_assert(func_data != NULL);
@@ -408,11 +408,11 @@ static void llcp_call_receive(GObject *source_object, GAsyncResult *res,
 static void llcp_call_receive_from(GObject *source_object, GAsyncResult *res,
                gpointer user_data)
 {
-       sap_t sap;
        gboolean ret;
-       GVariant *variant;
+       sap_t sap = 0;
        GError *error = NULL;
        net_nfc_error_e result;
+       GVariant *variant = NULL;
        LlcpFuncData *func_data = user_data;
 
        g_assert(func_data != NULL);
@@ -448,7 +448,7 @@ static void llcp_call_close(GObject *source_object, GAsyncResult *res,
        gboolean ret;
        GError *error = NULL;
        net_nfc_error_e result;
-       guint32 out_client_socket;
+       guint32 out_client_socket = -1;
        LlcpFuncData *func_data = user_data;
        net_nfc_llcp_internal_socket_s *socket_data = NULL;
 
@@ -487,7 +487,7 @@ static void llcp_call_disconnect(GObject *source_object,    GAsyncResult *res,
        gboolean ret;
        GError *error = NULL;
        net_nfc_error_e result;
-       guint32 out_client_socket;
+       guint32 out_client_socket = -1;
        LlcpFuncData *func_data = user_data;
        net_nfc_llcp_internal_socket_s *socket_data = NULL;
 
index b4cf043..798cec4 100644 (file)
@@ -75,7 +75,7 @@ static void manager_call_set_active_callback(GObject *source_object,
                gpointer user_data)
 {
        ManagerFuncData *func_data = (ManagerFuncData *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
@@ -114,7 +114,7 @@ static void manager_call_get_server_state_callback(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        guint out_state = 0;
        GError *error = NULL;
 
index 3136c31..532f72c 100644 (file)
@@ -48,13 +48,11 @@ static void ndef_call_format(GObject *source_object,
                GAsyncResult *res,
                gpointer user_data);
 
-
 static gboolean ndef_is_supported_tag(void)
 {
        net_nfc_target_info_s *target_info = NULL;
 
        target_info = net_nfc_client_tag_get_client_target_info();
-
        if (target_info == NULL)
        {
                NFC_ERR("target_info does not exist");
@@ -82,8 +80,7 @@ static void ndef_call_read(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-
-       net_nfc_error_e out_result = NET_NFC_OK;
+       net_nfc_error_e out_result;
        GVariant *out_data = NULL;
        GError *error = NULL;
 
@@ -124,8 +121,7 @@ static void ndef_call_write(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-
-       net_nfc_error_e out_result = NET_NFC_OK;
+       net_nfc_error_e out_result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
@@ -136,7 +132,6 @@ static void ndef_call_write(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-
                NFC_ERR("Can not finish write: %s", error->message);
                g_error_free(error);
 
@@ -159,8 +154,7 @@ static void ndef_call_make_read_only(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-
-       net_nfc_error_e out_result = NET_NFC_OK;
+       net_nfc_error_e out_result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
@@ -171,9 +165,7 @@ static void ndef_call_make_read_only(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-
-               NFC_ERR("Can not finish make read only: %s",
-                               error->message);
+               NFC_ERR("Can not finish make read only: %s", error->message);
                g_error_free(error);
 
                out_result = NET_NFC_IPC_FAIL;
@@ -195,8 +187,7 @@ static void ndef_call_format(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-
-       net_nfc_error_e out_result = NET_NFC_OK;
+       net_nfc_error_e out_result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
@@ -207,7 +198,6 @@ static void ndef_call_format(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-
                NFC_ERR("Can not finish format: %s", error->message);
                g_error_free(error);
 
@@ -421,7 +411,6 @@ API net_nfc_error_e net_nfc_client_ndef_make_read_only(
                return NET_NFC_INVALID_STATE;
        }
 
-
        if (net_nfc_client_tag_is_connected() == FALSE)
                return NET_NFC_NOT_CONNECTED;
 
@@ -466,7 +455,6 @@ API net_nfc_error_e net_nfc_client_ndef_make_read_only_sync(
                return NET_NFC_INVALID_STATE;
        }
 
-
        if (net_nfc_client_tag_is_connected() == FALSE)
                return NET_NFC_NOT_CONNECTED;
 
@@ -519,6 +507,7 @@ API net_nfc_error_e net_nfc_client_ndef_format(net_nfc_target_handle_h handle,
 
        func_data->callback = (gpointer)callback;
        func_data->user_data = user_data;
+
        arg_data = net_nfc_util_gdbus_data_to_variant((data_s *)key);
 
        net_nfc_gdbus_ndef_call_format(ndef_proxy,
@@ -558,7 +547,6 @@ API net_nfc_error_e net_nfc_client_ndef_format_sync(
 
        arg_data = net_nfc_util_gdbus_data_to_variant((data_s *)key);
 
-
        if (net_nfc_gdbus_ndef_call_format_sync(ndef_proxy ,
                                GPOINTER_TO_UINT(handle),
                                arg_data,
@@ -593,7 +581,6 @@ net_nfc_error_e net_nfc_client_ndef_init(void)
                        "/org/tizen/NetNfcService/Ndef",
                        NULL,
                        &error);
-
        if (ndef_proxy == NULL)
        {
                NFC_ERR("Can not create proxy : %s", error->message);
index 9a23921..2ac8e0d 100644 (file)
@@ -161,7 +161,7 @@ static void set_secure_element(GObject *source_object,
                gpointer user_data)
 {
        SeFuncData *func_data = (SeFuncData *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
@@ -171,12 +171,10 @@ static void set_secure_element(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-               result = NET_NFC_IPC_FAIL;
-
-               NFC_ERR("Could not set secure element: %s",
-                               error->message);
-
+               NFC_ERR("Could not set secure element: %s", error->message);
                g_error_free(error);
+
+               result = NET_NFC_IPC_FAIL;
        }
 
        if (func_data->se_callback != NULL)
@@ -195,7 +193,7 @@ static void get_secure_element(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        gint type = 0;
        GError *error = NULL;
 
@@ -207,9 +205,7 @@ static void get_secure_element(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-               NFC_ERR("Could not set secure element: %s",
-                               error->message);
-
+               NFC_ERR("Could not set secure element: %s", error->message);
                g_error_free(error);
 
                result = NET_NFC_IPC_FAIL;
@@ -231,7 +227,7 @@ static void _set_card_emulation_cb(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
@@ -242,9 +238,7 @@ static void _set_card_emulation_cb(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-               NFC_ERR("Could not set card emulation: %s",
-                               error->message);
-
+               NFC_ERR("Could not set card emulation: %s", error->message);
                g_error_free(error);
 
                result = NET_NFC_IPC_FAIL;
@@ -267,7 +261,7 @@ static void open_secure_element(GObject *source_object,
                gpointer user_data)
 {
        SeFuncData *func_data = (SeFuncData *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        guint out_handle = 0;
        GError *error = NULL;
 
@@ -280,12 +274,10 @@ static void open_secure_element(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-               result = NET_NFC_IPC_FAIL;
-
-               NFC_ERR("Could not open secure element: %s",
-                               error->message);
-
+               NFC_ERR("Could not open secure element: %s", error->message);
                g_error_free(error);
+
+               result = NET_NFC_IPC_FAIL;
        }
 
        if (func_data->se_callback != NULL)
@@ -305,7 +297,7 @@ static void close_secure_element(GObject *source_object,
                gpointer user_data)
 {
        SeFuncData *func_data = (SeFuncData *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
@@ -316,11 +308,9 @@ static void close_secure_element(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-               result = NET_NFC_IPC_FAIL;
-
                NFC_ERR("Could not close secure element: %s", error->message);
-
                g_error_free(error);
+               result = NET_NFC_IPC_FAIL;
        }
 
        if (func_data->se_callback != NULL)
@@ -340,7 +330,7 @@ static void send_apdu_secure_element(GObject *source_object,
                gpointer user_data)
 {
        SeFuncData *func_data = (SeFuncData *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        GVariant *out_response = NULL;
        GError *error = NULL;
 
@@ -353,11 +343,9 @@ static void send_apdu_secure_element(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-               result = NET_NFC_IPC_FAIL;
-
                NFC_ERR("Could not send apdu: %s", error->message);
-
                g_error_free(error);
+               result = NET_NFC_IPC_FAIL;
        }
 
        if (func_data->se_callback != NULL)
@@ -382,7 +370,7 @@ static void get_atr_secure_element(GObject *source_object,
                gpointer user_data)
 {
        SeFuncData *func_data = (SeFuncData *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        GVariant *out_atr = NULL;
        GError *error = NULL;
 
@@ -395,11 +383,9 @@ static void get_atr_secure_element(GObject *source_object,
                                res,
                                &error) == FALSE)
        {
-               result = NET_NFC_IPC_FAIL;
-
                NFC_ERR("Could not get atr: %s", error->message);
-
                g_error_free(error);
+               result = NET_NFC_IPC_FAIL;
        }
 
        if (func_data->se_callback != NULL)
@@ -484,9 +470,7 @@ API net_nfc_error_e net_nfc_client_se_set_secure_element_type_sync(
                                &error) == FALSE)
        {
                NFC_ERR("Set secure element failed: %s", error->message);
-
                g_error_free(error);
-
                result = NET_NFC_IPC_FAIL;
        }
 
@@ -637,9 +621,7 @@ API net_nfc_error_e net_nfc_set_card_emulation_mode_sync(
                                &error) == FALSE)
        {
                NFC_ERR("Set card emulation failed: %s", error->message);
-
                g_error_free(error);
-
                result = NET_NFC_IPC_FAIL;
        }
 
@@ -778,10 +760,8 @@ API net_nfc_error_e net_nfc_client_se_close_internal_secure_element_sync(
                                NULL,
                                &error) == FALSE)
        {
-               NFC_ERR("close internal secure element failed: %s",
-                               error->message);
+               NFC_ERR("close internal secure element failed: %s", error->message);
                g_error_free(error);
-
                result = NET_NFC_IPC_FAIL;
        }
 
@@ -854,7 +834,6 @@ API net_nfc_error_e net_nfc_client_se_get_atr_sync(
        } else {
                NFC_ERR("Get attributes failed: %s", error->message);
                g_error_free(error);
-
                result = NET_NFC_IPC_FAIL;
        }
 
@@ -941,10 +920,8 @@ API net_nfc_error_e net_nfc_client_se_send_apdu_sync(
                                &error) == true) {
                *response = net_nfc_util_gdbus_variant_to_data(out_data);
        } else {
-               NFC_ERR("Send APDU failed: %s",
-                               error->message);
+               NFC_ERR("Send APDU failed: %s", error->message);
                g_error_free(error);
-
                result = NET_NFC_IPC_FAIL;
        }
 
index 57a0a26..ee71130 100644 (file)
@@ -30,22 +30,20 @@ static NetNfcGDbusSnep *snep_proxy = NULL;
 
 /*******************************************************************/
 
-
 static void snep_send_client_request(GObject *source_object,
                GAsyncResult *res,
                gpointer user_data);
 
 /*********************************************************************/
 
-
 static void snep_send_client_request(GObject *source_object,
                GAsyncResult *res,
                gpointer user_data)
 {
        GVariant *parameter = (GVariant *)user_data;
        net_nfc_error_e out_result;
-       net_nfc_snep_type_t out_type;
-       GVariant *out_data;
+       net_nfc_snep_type_t out_type = NET_NFC_SNEP_GET;
+       GVariant *out_data = NULL;
        GError *error = NULL;
        net_nfc_client_snep_event_cb callback;
        void *user_param;
@@ -74,12 +72,13 @@ static void snep_send_client_request(GObject *source_object,
                        (guint *)&handle);
 
        if (callback != NULL) {
-               ndef_message_h message = NULL;
+               ndef_message_h message;
 
                message = net_nfc_util_gdbus_variant_to_ndef_message(out_data);
 
                callback(handle, out_type, out_result,
                                message, user_param);
+
                net_nfc_free_ndef_message(message);
        }
 
index 75a5c0d..8617ab9 100644 (file)
@@ -36,7 +36,7 @@ static void popup_set_active_callback(GObject *source_object, GAsyncResult *res,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e result = NET_NFC_OK;
+       net_nfc_error_e result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);
index 10e0920..b1433a0 100644 (file)
@@ -218,7 +218,7 @@ static void tag_is_tag_connected(GObject *source_object,
                gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e out_result = NET_NFC_OK;
+       net_nfc_error_e out_result;
        gboolean out_is_connected = false;
        net_nfc_target_type_e out_dev_type = NET_NFC_UNKNOWN_TARGET;
        GError *error = NULL;
@@ -442,7 +442,7 @@ static void tag_tag_detached(NetNfcGDbusTag *object,
        client_target_info = NULL;
 }
 
-/* internal funcion */
+/* internal function */
 gboolean net_nfc_client_tag_is_connected(void)
 {
        if (client_target_info == NULL)
@@ -459,6 +459,7 @@ net_nfc_target_info_s *net_nfc_client_tag_get_client_target_info(void)
        return client_target_info;
 }
 
+/* public APIs */
 #if 0
 API net_nfc_error_e net_nfc_client_tag_is_tag_connected(
                net_nfc_client_tag_is_tag_connected_completed callback,
index 4578fea..5856323 100644 (file)
@@ -84,6 +84,7 @@ static GVariant *transceive_data_to_transceive_variant(
                        memcpy(transceive_info.buffer,
                                        data->buffer,
                                        data->length);
+
                        net_nfc_util_compute_CRC(CRC_B,
                                        transceive_info.buffer,
                                        transceive_info.length);
@@ -112,7 +113,7 @@ 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 = NET_NFC_OK;
+       net_nfc_error_e out_result;
        GVariant *out_data = NULL;
        GError *error = NULL;
 
@@ -152,7 +153,7 @@ static void transceive_call(GObject *source_object,
                GAsyncResult *res, gpointer user_data)
 {
        NetNfcCallback *func_data = (NetNfcCallback *)user_data;
-       net_nfc_error_e out_result = NET_NFC_OK;
+       net_nfc_error_e out_result;
        GError *error = NULL;
 
        g_assert(user_data != NULL);