mirror of
https://github.com/curl/curl.git
synced 2026-08-26 16:13:32 +03:00
curlx_inet_ntop: return CURLcode, drop setting errno
To simplify and to remove an exception where `errno` was reused to
return a socket error codes on Windows.
The error was used by one call site (`sockaddr2string()` in
`cf-socket.c`), but it was in practice always propagated as
`SOCKEAFNOSUPPORT` to callers.
Also:
- cf-socket: update 3 error messages to show `CURLcode` accordingly.
- if2ip: handle `curlx_inet_ntop()` error in `Curl_if2ip()`.
- dnsd: display `CURLcode` on two errors.
Follow-up to 39dec13ec0 #22170
Closes #22229
This commit is contained in:
parent
c2da5c7e66
commit
bb406386d9
11 changed files with 81 additions and 110 deletions
|
|
@ -147,8 +147,8 @@ static CURLcode test_unit1607(const char *arg)
|
|||
if(tests[i].address[j] == &skip)
|
||||
continue;
|
||||
|
||||
if(addr && !sockaddr2string(addr->ai_addr, addr->ai_addrlen,
|
||||
ipaddress, &port)) {
|
||||
if(addr && sockaddr2string(addr->ai_addr, addr->ai_addrlen,
|
||||
ipaddress, &port)) {
|
||||
curl_mfprintf(stderr, "%s:%d tests[%zu] failed. "
|
||||
"getaddressinfo failed.\n",
|
||||
__FILE__, __LINE__, i);
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ static CURLcode test_unit1609(const char *arg)
|
|||
if(!addr && !tests[i].address[j])
|
||||
break;
|
||||
|
||||
if(addr && !sockaddr2string(addr->ai_addr, addr->ai_addrlen,
|
||||
ipaddress, &port)) {
|
||||
if(addr && sockaddr2string(addr->ai_addr, addr->ai_addrlen,
|
||||
ipaddress, &port)) {
|
||||
curl_mfprintf(stderr,
|
||||
"%s:%d tests[%zu] failed. Curl_addr2string failed.\n",
|
||||
__FILE__, __LINE__, i);
|
||||
|
|
|
|||
|
|
@ -48,8 +48,6 @@ static int test_ntop(void)
|
|||
char ipv4res[sizeof("255.255.255.255")];
|
||||
unsigned char ipv6a[26];
|
||||
unsigned char ipv4a[5];
|
||||
const char *ipv6ptr = 0;
|
||||
const char *ipv4ptr = 0;
|
||||
|
||||
ipv4res[0] = '\0';
|
||||
ipv4a[0] = 0xc0;
|
||||
|
|
@ -57,12 +55,9 @@ static int test_ntop(void)
|
|||
ipv4a[2] = 0x64;
|
||||
ipv4a[3] = 0x01;
|
||||
ipv4a[4] = 0x01;
|
||||
ipv4ptr = curlx_inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
|
||||
if(!ipv4ptr)
|
||||
if(curlx_inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res)))
|
||||
return 1; /* fail */
|
||||
if(ipv4ptr != ipv4res)
|
||||
return 1; /* fail */
|
||||
if(!ipv4ptr[0])
|
||||
if(!ipv4res[0])
|
||||
return 1; /* fail */
|
||||
if(memcmp(ipv4res, "192.168.100.1", 13))
|
||||
return 1; /* fail */
|
||||
|
|
@ -80,12 +75,9 @@ static int test_ntop(void)
|
|||
ipv6a[14] = 0x76;
|
||||
ipv6a[15] = 0xc8;
|
||||
ipv6a[25] = 0x01;
|
||||
ipv6ptr = curlx_inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
|
||||
if(!ipv6ptr)
|
||||
if(curlx_inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res)))
|
||||
return 1; /* fail */
|
||||
if(ipv6ptr != ipv6res)
|
||||
return 1; /* fail */
|
||||
if(!ipv6ptr[0])
|
||||
if(!ipv6res[0])
|
||||
return 1; /* fail */
|
||||
if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24))
|
||||
return 1; /* fail */
|
||||
|
|
@ -96,12 +88,9 @@ static int test_ntop(void)
|
|||
ipv6a[13] = 0x0;
|
||||
ipv6a[14] = 0x0;
|
||||
ipv6a[15] = 0x01;
|
||||
ipv6ptr = curlx_inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
|
||||
if(!ipv6ptr)
|
||||
if(curlx_inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res)))
|
||||
return 1; /* fail */
|
||||
if(ipv6ptr != ipv6res)
|
||||
return 1; /* fail */
|
||||
if(!ipv6ptr[0])
|
||||
if(!ipv6res[0])
|
||||
return 1; /* fail */
|
||||
if(memcmp(ipv6res, "::127.0.0.1", 11))
|
||||
return 1; /* fail */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue