Correct return value of nsapi_dns_query_multiple

Documentation states that nsapi_dns_query_multiple returns the number of
addresses found on success - it was returning 0.

Overloads using SocketAddress are relying on the return value, meaning
those calls didn't work at all.

Fixes #5921.
pull/6056/head
Kevin Bracey 2018-01-26 14:06:35 +02:00 committed by adbridge
parent 73ed270d2d
commit 6e2584e39e
1 changed files with 4 additions and 3 deletions

View File

@ -214,7 +214,7 @@ static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const
socket.set_timeout(DNS_TIMEOUT); socket.set_timeout(DNS_TIMEOUT);
// create network packet // create network packet
uint8_t *packet = (uint8_t *)malloc(DNS_BUFFER_SIZE); uint8_t * const packet = (uint8_t *)malloc(DNS_BUFFER_SIZE);
if (!packet) { if (!packet) {
return NSAPI_ERROR_NO_MEMORY; return NSAPI_ERROR_NO_MEMORY;
} }
@ -243,8 +243,9 @@ static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const
} }
const uint8_t *response = packet; const uint8_t *response = packet;
if (dns_scan_response(&response, addr, addr_count) > 0) { int count = dns_scan_response(&response, addr, addr_count);
result = NSAPI_ERROR_OK; if (count > 0) {
result = count;
} }
/* The DNS response is final, no need to check other servers */ /* The DNS response is final, no need to check other servers */