summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-10-21 11:11:27 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-10-21 11:12:54 +0200
commit272dfc1f024f3481d5c94942a84afe592d91394c (patch)
treee63ac941a678af8c7cccd2a4e446c9f8547b4420 /src
parent3f464fc007ace5a829e8d43e72a88055f14b52e3 (diff)
socket: Remove unneeded condition check in osmo_sock_init2_multiaddr()
Since we return error at the start of the function if proto != IPPROTO_SCTP, it makes no sense to check for proto != IPPROTO_UDP later on. Fixes: CID#205088 Change-Id: Ibba7eacaa9debb77d536d47dc85170c5ee79e479
Diffstat (limited to 'src')
-rw-r--r--src/socket.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/socket.c b/src/socket.c
index 542c76e5..47528810 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -467,21 +467,21 @@ int osmo_sock_init2_multiaddr(uint16_t family, uint16_t type, uint8_t proto,
return sfd;
}
- if (proto != IPPROTO_UDP || flags & OSMO_SOCK_F_UDP_REUSEADDR) {
- rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR,
- &on, sizeof(on));
- if (rc < 0) {
- multiaddr_snprintf(strbuf, sizeof(strbuf), local_hosts, local_hosts_cnt);
- LOGP(DLGLOBAL, LOGL_ERROR,
- "cannot setsockopt socket:"
- " %s:%u: %s\n",
- strbuf, local_port,
- strerror(errno));
- for (i = 0; i < local_hosts_cnt; i++)
- freeaddrinfo(result[i]);
- close(sfd);
- return rc;
- }
+ /* Since so far we only allow IPPROTO_SCTP in this function,
+ no need to check below for "proto != IPPROTO_UDP || flags & OSMO_SOCK_F_UDP_REUSEADDR" */
+ rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR,
+ &on, sizeof(on));
+ if (rc < 0) {
+ multiaddr_snprintf(strbuf, sizeof(strbuf), local_hosts, local_hosts_cnt);
+ LOGP(DLGLOBAL, LOGL_ERROR,
+ "cannot setsockopt socket:"
+ " %s:%u: %s\n",
+ strbuf, local_port,
+ strerror(errno));
+ for (i = 0; i < local_hosts_cnt; i++)
+ freeaddrinfo(result[i]);
+ close(sfd);
+ return rc;
}
/* Build array of addresses taking first of same family for each host.