bsc_msc.c: Check setsockopt() return value

Change-Id: I79a8fe9c025772e51560503504f517485b0ace34
Fixes: Coverity CID 57644
This commit is contained in:
Harald Welte 2016-11-26 14:13:33 +01:00
parent be67050a36
commit 487436138e
1 changed files with 7 additions and 1 deletions

View File

@ -158,6 +158,9 @@ int bsc_msc_connect(struct bsc_msc_connection *con)
return -1;
}
/* TODO: Why are we not using the libosmocore soecket
* abstraction, or libosmo-netif? */
/* move to the next connection */
dest = (struct bsc_msc_dest *) con->dests->next;
llist_del(&dest->list);
@ -197,7 +200,10 @@ int bsc_msc_connect(struct bsc_msc_connection *con)
sin.sin_port = htons(dest->port);
inet_aton(dest->ip, &sin.sin_addr);
setsockopt(fd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
ret = setsockopt(fd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if (ret != 0)
LOGP(DMSC, LOGL_ERROR,
"Failed to set SO_REUSEADDR socket option\n");
ret = connect(fd->fd, (struct sockaddr *) &sin, sizeof(sin));
if (ret == -1 && errno == EINPROGRESS) {