From: Kitae Kim Date: Wed, 6 Aug 2014 08:17:09 +0000 (+0900) Subject: tethering: remove redundant source when copying ip address. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~228^2^2~38^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=60aaaee37782ca844d82013e0400f1a9ebf3f473;p=sdk%2Femulator%2Fqemu.git tethering: remove redundant source when copying ip address. Change-Id: I528aa0886cccf746ca928390da930bf07ec5bccc Signed-off-by: Kitae Kim --- diff --git a/tizen/src/ecs/ecs_tethering.c b/tizen/src/ecs/ecs_tethering.c index f6828d3784..2e4682d9d9 100644 --- a/tizen/src/ecs/ecs_tethering.c +++ b/tizen/src/ecs/ecs_tethering.c @@ -245,7 +245,6 @@ bool msgproc_tethering_req(ECS_Client* ccli, ECS__TetheringReq* msg) // get ip address and port if (msg->data.data && msg->data.len > 0) { const gchar *data = (const gchar *)msg->data.data; - // gchar **server_addr = NULL; gchar *ip_address = NULL; guint64 port = 0; diff --git a/tizen/src/tethering/common.c b/tizen/src/tethering/common.c index 6e11e765d5..709e5e726b 100644 --- a/tizen/src/tethering/common.c +++ b/tizen/src/tethering/common.c @@ -60,6 +60,7 @@ DECLARE_DEBUG_CHANNEL(app_tethering); #endif #define SEND_BUF_MAX_SIZE 4096 +static const char *loopback="127.0.0.1"; typedef struct tethering_recv_buf { uint32_t len; @@ -549,22 +550,14 @@ static void tethering_io_handler(void *opaque) static int start_tethering_socket(const char *ipaddress, int port) { struct sockaddr_in addr; - - gchar serveraddr[32] = { 0, }; int sock = -1; int ret = 0; addr.sin_family = AF_INET; addr.sin_port = htons(port); // i.e. 1234 - if (ipaddress == NULL) { - g_strlcpy(serveraddr, "127.0.0.1", sizeof(serveraddr)); - } else { - g_strlcpy(serveraddr, ipaddress, sizeof(serveraddr)); - } - - LOG_INFO("server ip address: %s, port: %d\n", serveraddr, port); - ret = inet_aton(serveraddr, &addr.sin_addr); + LOG_INFO("server ip address: %s, port: %d\n", ipaddress, port); + ret = inet_aton(ipaddress, &addr.sin_addr); if (ret == 0) { LOG_SEVERE("inet_aton failure\n"); @@ -722,6 +715,7 @@ static void *initialize_tethering_socket(void *opaque); int connect_tethering_app(const char *ipaddress, int port) { TetheringState *client = NULL; + int ipaddr_len = 0; client = g_malloc0(sizeof(TetheringState)); if (!client) { @@ -731,23 +725,21 @@ int connect_tethering_app(const char *ipaddress, int port) client->port = port; if (ipaddress) { - int ipaddr_len = 0; - ipaddr_len = strlen(ipaddress); - - client->ipaddress = g_malloc0(ipaddr_len + 1); - if (!client->ipaddress) { - g_free(client); - return -1; - } - - g_strlcpy(client->ipaddress, ipaddress, ipaddr_len); } else { - client->ipaddress = NULL; + // ipaddr_len = strlen(LOOPBACK); + ipaddr_len = strlen(loopback); + ipaddress = loopback; } - tethering_client = client; + client->ipaddress = g_malloc0(ipaddr_len + 1); + if (!client->ipaddress) { + g_free(client); + return -1; + } + g_strlcpy(client->ipaddress, ipaddress, ipaddr_len + 1); + tethering_client = client; qemu_mutex_init(&tethering_client->mutex); qemu_thread_create(&tethering_client->thread, "tethering-io-thread",