Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net: Update comment on the `To4` function. #10349
@minux I didn't know you didn't accept pull requests (via GitHub?). Also the change is not an improvement, yes. It doesn't reduce CPU cycles or the memory requirements of
The old comment says "if ip is not an IPv4 address, To4 returns nil", which is exactly what the code does. Your proposed change changed that sentence to "If ip is not an IP address (it is the wrong length), To4 returns nil." This is more confusing that it was. If the user passes in an IPv6 address (not an IPv4-mapped IPv6 address), and expect To4 to return a non-nil address. According to your docs, it should work because the user has passed an IP address. If you say an IPv6 address is not the "correct" length for To4, then what about IPv4-mapped IPv6 addresses? They have the length of IPv6 address, but To4 can still convert them to IPv4.