Fix #1471 - calm static analyzer

This commit is contained in:
Sergey Lyubka committed 2022-02-23 13:28:56 +00:00
1 parent dd08231a34
commit 78e81fef27
2 files changed
+32 -16

No files matched your search

+16 -8
View File
@@ -3335,8 +3335,8 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
ioctlsocket(fd, FIONBIO, &on); ioctlsocket(fd, FIONBIO, &on);
#elif MG_ARCH == MG_ARCH_FREERTOS_TCP #elif MG_ARCH == MG_ARCH_FREERTOS_TCP
const BaseType_t off = 0; const BaseType_t off = 0;
setsockopt(fd, 0, FREERTOS_SO_RCVTIMEO, &off, sizeof(off)); if (setsockopt(fd, 0, FREERTOS_SO_RCVTIMEO, &off, sizeof(off)) != 0) (void) 0;
setsockopt(fd, 0, FREERTOS_SO_SNDTIMEO, &off, sizeof(off)); if (setsockopt(fd, 0, FREERTOS_SO_SNDTIMEO, &off, sizeof(off)) != 0) (void) 0;
#elif MG_ARCH == MG_ARCH_FREERTOS_LWIP #elif MG_ARCH == MG_ARCH_FREERTOS_LWIP
lwip_fcntl(fd, F_SETFL, O_NONBLOCK); lwip_fcntl(fd, F_SETFL, O_NONBLOCK);
#elif MG_ARCH == MG_ARCH_AZURERTOS #elif MG_ARCH == MG_ARCH_AZURERTOS
@@ -3466,21 +3466,29 @@ static void setsockopts(struct mg_connection *c) {
#if !defined(SOL_TCP) #if !defined(SOL_TCP)
#define SOL_TCP IPPROTO_TCP #define SOL_TCP IPPROTO_TCP
#endif #endif
setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on)); if (setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) != 0)
(void) 0;
#if defined(TCP_QUICKACK) #if defined(TCP_QUICKACK)
setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on)); if (setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on)) != 0)
(void) 0;
#endif #endif
setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)); if (setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)) !=
0)
(void) 0;
#if (defined(ESP32) && ESP32) || (defined(ESP8266) && ESP8266) || \ #if (defined(ESP32) && ESP32) || (defined(ESP8266) && ESP8266) || \
defined(__linux__) defined(__linux__)
int idle = 60; int idle = 60;
setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)); if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)) != 0)
(void) 0;
#endif #endif
#if MG_ARCH != MG_ARCH_WIN32 && !defined(__QNX__) #if MG_ARCH != MG_ARCH_WIN32 && !defined(__QNX__)
{ {
int cnt = 3, intvl = 20; int cnt = 3, intvl = 20;
setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)); if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)) != 0)
setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)); (void) 0;
if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)) !=
0)
(void) 0;
} }
#endif #endif
#endif #endif
+16 -8
View File
@@ -168,8 +168,8 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
ioctlsocket(fd, FIONBIO, &on); ioctlsocket(fd, FIONBIO, &on);
#elif MG_ARCH == MG_ARCH_FREERTOS_TCP #elif MG_ARCH == MG_ARCH_FREERTOS_TCP
const BaseType_t off = 0; const BaseType_t off = 0;
setsockopt(fd, 0, FREERTOS_SO_RCVTIMEO, &off, sizeof(off)); if (setsockopt(fd, 0, FREERTOS_SO_RCVTIMEO, &off, sizeof(off)) != 0) (void) 0;
setsockopt(fd, 0, FREERTOS_SO_SNDTIMEO, &off, sizeof(off)); if (setsockopt(fd, 0, FREERTOS_SO_SNDTIMEO, &off, sizeof(off)) != 0) (void) 0;
#elif MG_ARCH == MG_ARCH_FREERTOS_LWIP #elif MG_ARCH == MG_ARCH_FREERTOS_LWIP
lwip_fcntl(fd, F_SETFL, O_NONBLOCK); lwip_fcntl(fd, F_SETFL, O_NONBLOCK);
#elif MG_ARCH == MG_ARCH_AZURERTOS #elif MG_ARCH == MG_ARCH_AZURERTOS
@@ -299,21 +299,29 @@ static void setsockopts(struct mg_connection *c) {
#if !defined(SOL_TCP) #if !defined(SOL_TCP)
#define SOL_TCP IPPROTO_TCP #define SOL_TCP IPPROTO_TCP
#endif #endif
setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on)); if (setsockopt(FD(c), SOL_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) != 0)
(void) 0;
#if defined(TCP_QUICKACK) #if defined(TCP_QUICKACK)
setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on)); if (setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on)) != 0)
(void) 0;
#endif #endif
setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)); if (setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)) !=
0)
(void) 0;
#if (defined(ESP32) && ESP32) || (defined(ESP8266) && ESP8266) || \ #if (defined(ESP32) && ESP32) || (defined(ESP8266) && ESP8266) || \
defined(__linux__) defined(__linux__)
int idle = 60; int idle = 60;
setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)); if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)) != 0)
(void) 0;
#endif #endif
#if MG_ARCH != MG_ARCH_WIN32 && !defined(__QNX__) #if MG_ARCH != MG_ARCH_WIN32 && !defined(__QNX__)
{ {
int cnt = 3, intvl = 20; int cnt = 3, intvl = 20;
setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)); if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt)) != 0)
setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)); (void) 0;
if (setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl)) !=
0)
(void) 0;
} }
#endif #endif
#endif #endif