summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2008-08-28 14:35:54 +0200
committerJulien Danjou <julien@danjou.info>2008-08-28 14:35:54 +0200
commitbcf662c1b433b296060c66ae1656fcb5c6e697ef (patch)
tree192a02d19d6550fd30ae9e10839f593b984e7656
parentbaf31b1bf20b49ec00d0f64bb7cc9c788a28c088 (diff)
Initialize all fields of addrinfo
Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r--src/xcb_util.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/xcb_util.c b/src/xcb_util.c
index c772908..c6c5189 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -201,14 +201,7 @@ static int _xcb_open_decnet(const char *host, const char *protocol, const unsign
static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port)
{
int fd = -1;
- struct addrinfo hints = { 0
-#ifdef AI_ADDRCONFIG
- | AI_ADDRCONFIG
-#endif
-#ifdef AI_NUMERICSERV
- | AI_NUMERICSERV
-#endif
- , AF_UNSPEC, SOCK_STREAM };
+ struct addrinfo hints;
char service[6]; /* "65535" with the trailing '\0' */
struct addrinfo *results, *addr;
char *bracket;
@@ -216,6 +209,16 @@ static int _xcb_open_tcp(char *host, char *protocol, const unsigned short port)
if (protocol && strcmp("tcp",protocol))
return -1;
+ memset(&hints, 0, sizeof(hints));
+#ifdef AI_ADDRCONFIG
+ hints.ai_flags |= AI_ADDRCONFIG;
+#endif
+#ifdef AI_NUMERICSERV
+ hints.ai_flags |= AI_NUMERICSERV;
+#endif
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+
#ifdef AF_INET6
/* Allow IPv6 addresses enclosed in brackets. */
if(host[0] == '[' && (bracket = strrchr(host, ']')) && bracket[1] == '\0')