mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-28 23:34:49 -05:00

I just tried to trace through the Windows version's control flow in response to a confusing bug report, and found that the control flow itself was so confusing I couldn't make sense of it. Why are we choosing between getaddrinfo and gethostbyname via #ifndef NO_IPV6, then re-converging control flow and diverging a second time to report the error? So I rewrote the whole thing to have completely separate sections of code dealing with the three resolution strategies, each with its own dedicated error reporting system. And then I checked the Unix version and found it was about as confusing, so I rewrote that too in the same style. Now the two are mostly the same, except for details: Unix has an override at the top for a Unix socket pathname, Windows has to cope with getaddrinfo maybe not being found at run time (so the other cases aren't in the #else clause), and Windows uses the same error reporting for both lookup functions whereas Unix has to use the appropriate gai_strerror or hstrerror.