From: Junyeon LEE Date: Thu, 20 Apr 2017 08:32:37 +0000 (+0900) Subject: netutils/websocket: fixes minor issues in websocket X-Git-Tag: 1.1_Public_Release~597^2~123 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ceedf9a751886fe386859c0e58ad25a4f71c51a4;p=rtos%2Ftinyara.git netutils/websocket: fixes minor issues in websocket This commit fixes minor issues in websocket library. . clearify socket close routine . clearify the context compare Change-Id: I9a6ccf5504f4615bdb5d737c96eaa46c73c1a58a Signed-off-by: Junyeon LEE --- diff --git a/apps/netutils/websocket/websocket.c b/apps/netutils/websocket/websocket.c index 23ec1f0..f555a9d 100644 --- a/apps/netutils/websocket/websocket.c +++ b/apps/netutils/websocket/websocket.c @@ -338,7 +338,11 @@ EXIT_WEBSOCKET_HANDSHAKE_ERROR: void websocket_socket_free(websocket_t *ctx) { - if (ctx != NULL || ctx->fd >= 0) { + if (ctx == NULL) { + return; + } + + if (ctx->fd >= 0) { close(ctx->fd); ctx->fd = -1; } @@ -773,7 +777,6 @@ websocket_return_t websocket_client_open(websocket_t *client, char *host, char * if (websocket_client_handshake(client, host, port, path) != WEBSOCKET_SUCCESS) { WEBSOCKET_DEBUG("fail to http handshake\n"); - close(fd); r = WEBSOCKET_HANDSHAKE_ERROR; goto EXIT_CLIENT_OPEN; } @@ -781,7 +784,6 @@ websocket_return_t websocket_client_open(websocket_t *client, char *host, char * socket_data = malloc(sizeof(struct websocket_info_t)); if (socket_data == NULL) { WEBSOCKET_DEBUG("fail to allocate memory\n"); - close(fd); r = WEBSOCKET_ALLOCATION_ERROR; goto EXIT_CLIENT_OPEN; } @@ -791,7 +793,6 @@ websocket_return_t websocket_client_open(websocket_t *client, char *host, char * if (wslay_event_context_client_init(&client->ctx, client->cb, socket_data) != WEBSOCKET_SUCCESS) { WEBSOCKET_DEBUG("fail to init websocket client context\n"); free(socket_data); - close(fd); r = WEBSOCKET_INIT_ERROR; goto EXIT_CLIENT_OPEN; }