Explicitly initialize sockaddr_in members

This commit is contained in:
Christopher Wellons 2019-02-03 12:28:22 -05:00
parent 93b94f6b44
commit 2f79375360

View File

@ -425,8 +425,11 @@ server_create(int port)
r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &dummy, sizeof(dummy));
if (r == -1) die();
struct sockaddr_in addr = {AF_INET, htons(port)};
addr.sin_addr.s_addr = htonl(INADDR_ANY);
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_port = htons(port),
.sin_addr.s_addr = htonl(INADDR_ANY)
};
r = bind(s, (void *)&addr, sizeof(addr));
if (r == -1) die();