From 9c9dfb8193f11608e0872176ea1122fd868df378 Mon Sep 17 00:00:00 2001 From: David Lin Date: Sun, 26 Apr 2020 21:24:20 +0800 Subject: [PATCH] Update HAL_TCP_lwip.c --- .../port/TencentOS_tiny/HAL_TCP_lwip.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/components/connectivity/qcloud-iot-explorer-sdk/port/TencentOS_tiny/HAL_TCP_lwip.c b/components/connectivity/qcloud-iot-explorer-sdk/port/TencentOS_tiny/HAL_TCP_lwip.c index 8d5bb482..5ddbf321 100644 --- a/components/connectivity/qcloud-iot-explorer-sdk/port/TencentOS_tiny/HAL_TCP_lwip.c +++ b/components/connectivity/qcloud-iot-explorer-sdk/port/TencentOS_tiny/HAL_TCP_lwip.c @@ -45,8 +45,8 @@ static uint32_t _time_left(uint32_t t_end, uint32_t t_now) uintptr_t HAL_TCP_Connect(const char *host, uint16_t port) { - int ret; - struct addrinfo hints, *addr_list, *cur; + int ret; + struct addrinfo hints, *addr_list, *cur; int fd = 0; char port_str[6]; @@ -65,20 +65,20 @@ uintptr_t HAL_TCP_Connect(const char *host, uint16_t port) for (cur = addr_list; cur != NULL; cur = cur->ai_next) { fd = (int) socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol ); - if( fd < 0 ) - { - ret = 0; - continue; - } - - if (connect(fd, cur->ai_addr, cur->ai_addrlen) == 0) - { - ret = fd + LWIP_SOCKET_FD_SHIFT; - break; - } - - close( fd ); - ret = 0; + if( fd < 0 ) + { + ret = 0; + continue; + } + + if (connect(fd, cur->ai_addr, cur->ai_addrlen) == 0) + { + ret = fd + LWIP_SOCKET_FD_SHIFT; + break; + } + + close( fd ); + ret = 0; } if (ret == 0) { -- GitLab