[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 152/208: tests/server/resolve.c: fix deprecation wa
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 152/208: tests/server/resolve.c: fix deprecation warning |
Date: |
Wed, 09 Aug 2017 17:35:49 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.55.0
in repository gnurl.
commit da6aa3f76382e6ddf471dad198c507b7c7704ffb
Author: Marcel Raad <address@hidden>
AuthorDate: Sun Jul 16 14:28:10 2017 +0200
tests/server/resolve.c: fix deprecation warning
MSVC warns that gethostbyname is deprecated. Always use getaddrinfo
instead to fix this when IPv6 is enabled, also for IPv4 resolves. This
is also consistent with what libcurl does.
Closes https://github.com/curl/curl/pull/1682
---
tests/server/resolve.c | 54 ++++++++++++++++++++++++++------------------------
1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/tests/server/resolve.c b/tests/server/resolve.c
index 206245aba..34f14e066 100644
--- a/tests/server/resolve.c
+++ b/tests/server/resolve.c
@@ -107,16 +107,8 @@ int main(int argc, char *argv[])
atexit(win32_cleanup);
#endif
- if(!use_ipv6) {
- /* gethostbyname() resolve */
- struct hostent *he;
-
- he = gethostbyname(host);
-
- rc = !he;
- }
- else {
#ifdef ENABLE_IPV6
+ if(use_ipv6) {
/* Check that the system has IPv6 enabled before checking the resolver */
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
if(s == CURL_SOCKET_BAD)
@@ -125,28 +117,38 @@ int main(int argc, char *argv[])
else {
sclose(s);
}
+ }
- if(rc == 0) {
- /* getaddrinfo() resolve */
- struct addrinfo *ai;
- struct addrinfo hints;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = PF_INET6;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_CANONNAME;
- /* Use parenthesis around functions to stop them from being replaced by
- the macro in memdebug.h */
- rc = (getaddrinfo)(host, "80", &hints, &ai);
- if(rc == 0)
- (freeaddrinfo)(ai);
- }
-
+ if(rc == 0) {
+ /* getaddrinfo() resolve */
+ struct addrinfo *ai;
+ struct addrinfo hints;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = use_ipv6 ? PF_INET6 : PF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_CANONNAME;
+ /* Use parenthesis around functions to stop them from being replaced by
+ the macro in memdebug.h */
+ rc = (getaddrinfo)(host, "80", &hints, &ai);
+ if(rc == 0)
+ (freeaddrinfo)(ai);
+ }
#else
+ if(use_ipv6) {
puts("IPv6 support has been disabled in this program");
return 1;
-#endif
}
+ else {
+ /* gethostbyname() resolve */
+ struct hostent *he;
+
+ he = gethostbyname(host);
+
+ rc = !he;
+ }
+#endif
+
if(rc)
printf("Resolving %s '%s' didn't work\n", ipv_inuse, host);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 75/208: CURLOPT_SOCKS5_AUTH: allowed methods for SOCKS5 proxy auth, (continued)
- [GNUnet-SVN] [gnurl] 75/208: CURLOPT_SOCKS5_AUTH: allowed methods for SOCKS5 proxy auth, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 126/208: travis: install stunnel, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 160/208: curl_rtmp: fix a compiler warning, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 136/208: tests: Fix up issues with errno in test files, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 161/208: include.d: clarify that it concerns the response headers, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 62/208: maketgz: switch to -6e for xz, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 153/208: nss: unify the coding style of nss_send() and nss_recv(), gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 145/208: winbuild: build with warning level 4, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 53/208: lib: fix the djgpp build, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 129/208: smb: rename variable to fix shadowing warning, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 152/208: tests/server/resolve.c: fix deprecation warning,
gnunet <=
- [GNUnet-SVN] [gnurl] 68/208: curl/system.h: add check for XTENSA for 32bit gcc, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 148/208: sockfilt: suppress conversion warning with explicit cast, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 144/208: travis: install libidn2, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 125/208: valgrind.supp: supress OpenSSL false positive seen on travis, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 167/208: include.d: clarify --include is only for response headers, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 195/208: gssapi: fix memory leak of output token in multi round context, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 193/208: CMake: fix CURL_WERROR for MSVC, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 133/208: ldap: fix MinGW compiler warning, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 66/208: progress: progress.timespent needs to be us, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 154/208: nss: fix a possible use-after-free in SelectClientCert(), gnunet, 2017/08/09