From: Yang Tse Date: Thu, 19 Jan 2012 19:20:56 +0000 (+0100) Subject: ares_init.c: fix compiler warning on winsock builds X-Git-Tag: upstream/1.10.0~135 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ab65461b6aefd0654a5b586bc6ee57976f3fba3;p=platform%2Fupstream%2Fc-ares.git ares_init.c: fix compiler warning on winsock builds --- diff --git a/ares_init.c b/ares_init.c index 0c1d545..d18f97e 100644 --- a/ares_init.c +++ b/ares_init.c @@ -1,6 +1,6 @@ /* Copyright 1998 by the Massachusetts Institute of Technology. - * Copyright (C) 2007-2011 by Daniel Stenberg + * Copyright (C) 2007-2012 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -1186,11 +1186,14 @@ static int init_by_defaults(ares_channel channel) /* Derive a default domain search list from the kernel hostname, * or set it to empty if the hostname isn't helpful. */ +#ifndef HAVE_GETHOSTNAME + channel->ndomains = 0; /* default to none */ +#else + GETHOSTNAME_TYPE_ARG2 lenv = 64; size_t len = 64; int res; channel->ndomains = 0; /* default to none */ -#ifdef HAVE_GETHOSTNAME hostname = malloc(len); if(!hostname) { rc = ARES_ENOMEM; @@ -1198,11 +1201,12 @@ static int init_by_defaults(ares_channel channel) } do { - res = gethostname(hostname, len); + res = gethostname(hostname, lenv); if(toolong(res)) { char *p; len *= 2; + lenv *= 2; p = realloc(hostname, len); if(!p) { rc = ARES_ENOMEM; diff --git a/ares_setup.h b/ares_setup.h index a46c510..1ef054d 100644 --- a/ares_setup.h +++ b/ares_setup.h @@ -2,7 +2,7 @@ #define HEADER_CARES_SETUP_H -/* Copyright (C) 2004 - 2009 by Daniel Stenberg et al +/* Copyright (C) 2004 - 2012 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided @@ -157,6 +157,18 @@ #endif /* HAVE_CONFIG_H */ +/* + * Arg 2 type for gethostname in case it hasn't been defined in config file. + */ + +#ifndef GETHOSTNAME_TYPE_ARG2 +# ifdef USE_WINSOCK +# define GETHOSTNAME_TYPE_ARG2 int +# else +# define GETHOSTNAME_TYPE_ARG2 size_t +# endif +#endif + #ifdef __POCC__ # include # include