Skip to content

Commit

Permalink
coverity: fix iiod.c Unchecked return value from library
Browse files Browse the repository at this point in the history
Converity was complaining:
CID 138660: Unchecked return value from library (CHECKED_RETURN)

So, check them, and print a warning if there is an issue.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed Apr 3, 2020
1 parent e284750 commit eb99f04
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions iiod/iiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,11 @@ static int main_server(struct iio_context *ctx, bool debug)
return EXIT_FAILURE;
}

setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
if (ret < 0) {
iio_strerror(errno, err_str, sizeof(err_str));
WARNING("setsockopt SO_REUSEADDR : %s (%d)", err_str, -errno);
}

#ifdef HAVE_IPV6
if (ipv6)
Expand Down Expand Up @@ -513,14 +517,34 @@ static int main_server(struct iio_context *ctx, bool debug)
/* Configure the socket to send keep-alive packets every 10s,
* and disconnect the client if no reply was received for one
* minute. */
setsockopt(new, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes));
setsockopt(new, IPPROTO_TCP, TCP_KEEPCNT, &keepalive_probes,
ret = setsockopt(new, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes));
if (ret < 0) {
iio_strerror(errno, err_str, sizeof(err_str));
WARNING("setsockopt SO_KEEPALIVE : %s (%d)", err_str, -errno);
}
ret = setsockopt(new, IPPROTO_TCP, TCP_KEEPCNT, &keepalive_probes,
sizeof(keepalive_probes));
setsockopt(new, IPPROTO_TCP, TCP_KEEPIDLE, &keepalive_time,
if (ret < 0) {
iio_strerror(errno, err_str, sizeof(err_str));
WARNING("setsockopt TCP_KEEPCNT : %s (%d)", err_str, -errno);
}
ret = setsockopt(new, IPPROTO_TCP, TCP_KEEPIDLE, &keepalive_time,
sizeof(keepalive_time));
setsockopt(new, IPPROTO_TCP, TCP_KEEPINTVL, &keepalive_intvl,
if (ret < 0) {
iio_strerror(errno, err_str, sizeof(err_str));
WARNING("setsockopt TCP_KEEPIDLE : %s (%d)", err_str, -errno);
}
ret = setsockopt(new, IPPROTO_TCP, TCP_KEEPINTVL, &keepalive_intvl,
sizeof(keepalive_intvl));
setsockopt(new, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
if (ret < 0) {
iio_strerror(errno, err_str, sizeof(err_str));
WARNING("setsockopt TCP_KEEPINTVL : %s (%d)", err_str, -errno);
}
ret = setsockopt(new, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
if (ret < 0) {
iio_strerror(errno, err_str, sizeof(err_str));
WARNING("setsockopt TCP_NODELAY : %s (%d)", err_str, -errno);
}

cdata->fd = new;
cdata->ctx = ctx;
Expand Down

0 comments on commit eb99f04

Please sign in to comment.