Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/wil/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ namespace network
default:
// if not AF_INET or AF_INET6, and families don't match
// then just raw memcmp the largest field of the union (v6)
return ::memcmp(&lhs.m_sockaddr.Ipv6, &rhs.m_sockaddr.Ipv6, sizeof(SOCKADDR_IN6)) < 0;
const auto comparison{::memcmp(&lhs.m_sockaddr.Ipv6, &rhs.m_sockaddr.Ipv6, sizeof(SOCKADDR_IN6))};
return comparison < 0 ? -1 : (comparison > 0 ? 1 : 0);
Comment on lines +795 to +796
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.

}
}

Expand Down