coverity 83657 plat unix check setsockopt return
authorAndy Green <andy.green@linaro.org>
Sun, 30 Nov 2014 05:06:09 +0000 (13:06 +0800)
committerAndy Green <andy.green@linaro.org>
Sun, 30 Nov 2014 05:10:26 +0000 (13:10 +0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/lws-plat-unix.c

index e81bb1e..9af4bdf 100644 (file)
@@ -227,10 +227,12 @@ lws_plat_set_socket_options(struct libwebsocket_context *context, int fd)
        optval = 1;
 #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
     !defined(__OpenBSD__)
-       setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&optval, optlen);
+       if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
+               return 1;
 #else
        tcp_proto = getprotobyname("TCP");
-       setsockopt(fd, tcp_proto->p_proto, TCP_NODELAY, &optval, optlen);
+       if (setsockopt(fd, tcp_proto->p_proto, TCP_NODELAY, &optval, optlen) < 0)
+               return 1;
 #endif
 
        /* We are nonblocking... */