Skip to content

Fixed comparison function for non-network address families#557

Open
keith-horton wants to merge 9 commits into
microsoft:masterfrom
keith-horton:master
Open

Fixed comparison function for non-network address families#557
keith-horton wants to merge 9 commits into
microsoft:masterfrom
keith-horton:master

Conversation

@keith-horton

Copy link
Copy Markdown
Member

Found through a separate tool when I manually copied this header to that project.

Signed-off-by: Keith Horton <khorton@microsoft.com>
@ChrisGuzak

Copy link
Copy Markdown
Member

is it possible to create a test for this and similar cases?

@ChrisGuzak ChrisGuzak self-assigned this Nov 2, 2025
Comment thread include/wil/network.h
Comment on lines +795 to +796
const auto comparison{::memcmp(&lhs.m_sockaddr.Ipv6, &rhs.m_sockaddr.Ipv6, sizeof(SOCKADDR_IN6))};
return comparison < 0 ? -1 : (comparison > 0 ? 1 : 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anything take a dependency on this returning exactly -1, 0, or 1? Seems easier and more efficient to just return ::memcmp(...)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. I thought about making it do just that. I'm going to add tests for this oddball scenario. I might change to just return what memcmp returns then.

@dunhor

dunhor commented Nov 4, 2025

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

3 participants