hostip: make more functions return CURLcode

- Curl_async_getaddrinfo() always returned NULL so it was pointless.
  Return proper curlcode instead to distinguish between errors. Same for
  Curl_doh().
- simplify the IP address handling
- make Curl_str2addr() function return CURLcode

Closes #19669
This commit is contained in:
Daniel Stenberg 2025-11-24 14:00:09 +01:00
parent a075d1c0d8
commit ce06fe7771
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
9 changed files with 117 additions and 145 deletions

View file

@ -755,15 +755,11 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data,
/*
* Curl_async_getaddrinfo() - for getaddrinfo
*/
struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data,
const char *hostname,
int port,
int ip_version,
int *waitp)
CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname,
int port, int ip_version)
{
struct addrinfo hints;
int pf = PF_INET;
*waitp = 0; /* default to synchronous response */
CURL_TRC_DNS(data, "init threaded resolve of %s:%d", hostname, port);
#ifdef CURLRES_IPV6
@ -785,14 +781,11 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data,
SOCK_STREAM : SOCK_DGRAM;
/* fire up a new resolver thread! */
if(async_thrdd_init(data, hostname, port, ip_version, &hints)) {
*waitp = 1; /* expect asynchronous response */
return NULL;
}
if(async_thrdd_init(data, hostname, port, ip_version, &hints))
return CURLE_OK;
failf(data, "getaddrinfo() thread failed to start");
return NULL;
return CURLE_FAILED_INIT;
}
#endif /* !HAVE_GETADDRINFO */