mirror of
https://github.com/curl/curl.git
synced 2026-08-25 00:03:33 +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
|
|
@ -606,6 +606,7 @@ static int dnsd_make_answer(struct blob *blob, int query_id,
|
|||
};
|
||||
uint16_t ancount = 0;
|
||||
unsigned char rcode = 0;
|
||||
CURLcode result;
|
||||
|
||||
/* read once per incoming query, which is probably more than one
|
||||
per test case */
|
||||
|
|
@ -656,12 +657,11 @@ static int dnsd_make_answer(struct blob *blob, int query_id,
|
|||
case QTYPE_A:
|
||||
for(a = 0; !rcode && (a < ancount_a); a++) {
|
||||
const unsigned char *store = ipv4_pref;
|
||||
const char *ip;
|
||||
if(add_answer(blob, store, sizeof(ipv4_pref), QTYPE_A))
|
||||
return 1;
|
||||
ip = curlx_inet_ntop(AF_INET, store, addrbuf, sizeof(addrbuf));
|
||||
logmsg("[%d] response A (%x) '%s'", query_id, (unsigned int)QTYPE_A,
|
||||
ip ? ip : "(null)");
|
||||
result = curlx_inet_ntop(AF_INET, store, addrbuf, sizeof(addrbuf));
|
||||
logmsg("[%d] response A (%x) '%s' (%d)", query_id,
|
||||
(unsigned int)QTYPE_A, result ? "?" : addrbuf, (int)result);
|
||||
}
|
||||
if(!ancount_a)
|
||||
logmsg("[%d] response A empty", query_id);
|
||||
|
|
@ -669,12 +669,11 @@ static int dnsd_make_answer(struct blob *blob, int query_id,
|
|||
case QTYPE_AAAA:
|
||||
for(a = 0; !rcode && (a < ancount_aaaa); a++) {
|
||||
const unsigned char *store = ipv6_pref;
|
||||
const char *ip;
|
||||
if(add_answer(blob, store, sizeof(ipv6_pref), QTYPE_AAAA))
|
||||
return 1;
|
||||
ip = curlx_inet_ntop(AF_INET6, store, addrbuf, sizeof(addrbuf));
|
||||
logmsg("[%d] response AAAA (%x) '%s'", query_id,
|
||||
(unsigned int)QTYPE_AAAA, ip ? ip : "(null)");
|
||||
result = curlx_inet_ntop(AF_INET6, store, addrbuf, sizeof(addrbuf));
|
||||
logmsg("[%d] response AAAA (%x) '%s' (%d)", query_id,
|
||||
(unsigned int)QTYPE_AAAA, result ? "?" : addrbuf, (int)result);
|
||||
}
|
||||
if(!ancount_aaaa)
|
||||
logmsg("[%d] response AAAA empty", query_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue