From 9da3e5e1f91bc7fbb429e6877153ffa9c22727ab Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 7 Jan 2015 02:06:38 -0800 Subject: [PATCH] Util: Fix socket code to not use struct designated initialization --- src/util/socket.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/util/socket.h b/src/util/socket.h index a0ac806a0..312794e2c 100644 --- a/src/util/socket.h +++ b/src/util/socket.h @@ -50,11 +50,10 @@ static inline Socket SocketOpenTCP(int port, uint32_t bindAddress) { return sock; } - struct sockaddr_in bindInfo = { - .sin_family = AF_INET, - .sin_port = htons(port), - .sin_addr = { 0 } - }; + struct sockaddr_in bindInfo; + memset(&bindInfo, 0, sizeof(bindInfo)); + bindInfo.sin_family = AF_INET; + bindInfo.sin_port = htons(port); bindInfo.sin_addr.s_addr = htonl(bindAddress); int err = bind(sock, (const struct sockaddr*) &bindInfo, sizeof(struct sockaddr_in)); if (err) { @@ -70,11 +69,10 @@ static inline Socket SocketConnectTCP(int port, uint32_t destinationAddress) { return sock; } - struct sockaddr_in bindInfo = { - .sin_family = AF_INET, - .sin_port = htons(port), - .sin_addr = { 0 } - }; + struct sockaddr_in bindInfo; + memset(&bindInfo, 0, sizeof(bindInfo)); + bindInfo.sin_family = AF_INET; + bindInfo.sin_port = htons(port); bindInfo.sin_addr.s_addr = htonl(destinationAddress); int err = connect(sock, (const struct sockaddr*) &bindInfo, sizeof(struct sockaddr_in)); if (err) {