Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/server/resolve.c: fix deprecation warning #1682

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions tests/server/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -125,28 +117,37 @@ 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you tested was ipv6 disabled? it looks like you're missing a brace here, otherwise it looks fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thanks! It was enabled, It thought that was the more interesting case.


if(rc)
printf("Resolving %s '%s' didn't work\n", ipv_inuse, host);

Expand Down