Skip to content

Use current addrinfo entry in #XGETADDRINFO result iteration#318

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-code-review-suggestion
Closed

Use current addrinfo entry in #XGETADDRINFO result iteration#318
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-code-review-suggestion

Conversation

Copy link
Copy Markdown

Copilot AI commented May 22, 2026

The reviewed issue pointed out that AT#XGETADDRINFO iterated addrinfo results but read result->ai_addr (head node) instead of the current loop node, which can return incorrect addresses when multiple DNS results are present.
This update scopes to that comment and aligns address selection with the active iterator entry.

  • AT#XGETADDRINFO address selection

    • In handle_at_getaddrinfo(), switched IPv4/IPv6 address casts from result->ai_addr to res->ai_addr inside the result loop.
    • This ensures each emitted address comes from the corresponding addrinfo node.
  • Regression coverage for multi-result iteration

    • Added a focused unit test for AT#XGETADDRINFO with multiple mocked IPv4 results.
    • Verifies output includes both addresses in order, confirming per-node address handling.
for (res = result; res != NULL; res = res->ai_next) {
    if (res->ai_family == NRF_AF_INET) {
        struct nrf_sockaddr_in *host =
            (struct nrf_sockaddr_in *)res->ai_addr;
    } else if (res->ai_family == NRF_AF_INET6) {
        struct nrf_sockaddr_in6 *host =
            (struct nrf_sockaddr_in6 *)res->ai_addr;
    }
}

Copilot AI changed the title [WIP] Fix code based on review comment Use current addrinfo entry in #XGETADDRINFO result iteration May 22, 2026
Copilot AI requested a review from MarkusLassila May 22, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants