WPS: Merge identical error paths in ssdp_listener_open()

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-09-05 19:28:45 +03:00
parent 9425bb7828
commit c1d43d0bac

View file

@ -740,11 +740,9 @@ int ssdp_listener_open(void)
int sd; int sd;
sd = socket(AF_INET, SOCK_DGRAM, 0); sd = socket(AF_INET, SOCK_DGRAM, 0);
if (sd < 0) if (sd < 0 ||
goto fail; fcntl(sd, F_SETFL, O_NONBLOCK) != 0 ||
if (fcntl(sd, F_SETFL, O_NONBLOCK) != 0) setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
goto fail;
if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
goto fail; goto fail;
os_memset(&addr, 0, sizeof(addr)); os_memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
@ -756,9 +754,8 @@ int ssdp_listener_open(void)
mcast_addr.imr_interface.s_addr = htonl(INADDR_ANY); mcast_addr.imr_interface.s_addr = htonl(INADDR_ANY);
mcast_addr.imr_multiaddr.s_addr = inet_addr(UPNP_MULTICAST_ADDRESS); mcast_addr.imr_multiaddr.s_addr = inet_addr(UPNP_MULTICAST_ADDRESS);
if (setsockopt(sd, IPPROTO_IP, IP_ADD_MEMBERSHIP, if (setsockopt(sd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char *) &mcast_addr, sizeof(mcast_addr))) (char *) &mcast_addr, sizeof(mcast_addr)) ||
goto fail; setsockopt(sd, IPPROTO_IP, IP_MULTICAST_TTL,
if (setsockopt(sd, IPPROTO_IP, IP_MULTICAST_TTL,
&ttl, sizeof(ttl))) &ttl, sizeof(ttl)))
goto fail; goto fail;