Following function implementation is not following POSIX documentation specified at https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html, which says that EAI_SYSTEM return value means that system error code is saved into errno variable:
static int nrf_to_z_dns_error_code(int nrf_error)
{
switch (nrf_error) {
case NRF_ENOMEM:
return DNS_EAI_MEMORY;
case NRF_EAGAIN:
return DNS_EAI_AGAIN;
case NRF_EAFNOSUPPORT:
return DNS_EAI_NONAME;
case NRF_EINPROGRESS:
return DNS_EAI_INPROGRESS;
case NRF_ENETUNREACH:
errno = ENETUNREACH;
default:
return DNS_EAI_SYSTEM;
}
}
This implementation returns DNS_EAI_SYSTEM as a default error, without assigning errno. This is wrong and should be fixed.