[PATCH] openbsc[master]: bsc_msc.c: Check setsockopt() return value

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Nov 26 13:44:37 UTC 2016


Review at  https://gerrit.osmocom.org/1316

bsc_msc.c: Check setsockopt() return value

Change-Id: I79a8fe9c025772e51560503504f517485b0ace34
Fixes: Coverity CID 57644
---
M openbsc/src/libbsc/bsc_msc.c
1 file changed, 7 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/16/1316/1

diff --git a/openbsc/src/libbsc/bsc_msc.c b/openbsc/src/libbsc/bsc_msc.c
index 829ee2b..e373679 100644
--- a/openbsc/src/libbsc/bsc_msc.c
+++ b/openbsc/src/libbsc/bsc_msc.c
@@ -158,6 +158,9 @@
 		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 @@
 	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) {

-- 
To view, visit https://gerrit.osmocom.org/1316
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I79a8fe9c025772e51560503504f517485b0ace34
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list