-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect call to Unicode Win32 InetPton #4306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
@jmorrill I have read the doc: https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-inetptonw. Seems that Windows has Unix's i.e.
And I am curious why we don't function redefinition error because Windows has inet_pton too. |
src/common/socket.h
Outdated
@@ -59,7 +59,7 @@ static inline int poll(struct pollfd *pfd, int nfds, | |||
return WSAPoll(pfd, nfds, timeout); | |||
} | |||
static inline int inet_pton(int family, const char* addr_str, void* addr_buf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe be better to remove? Because WIndows / Unix both have inet_pton as comment said before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find! I removed the "static inline int inet_pton" function from socket.h and got a successful build on Windows.
Should I close this PR and resubmit a new PR with it removed?
@jmorrill seems there was some problem in rebasing, please cherry pick your windows change and rebase against the master |
cc3aad9
to
6f96747
Compare
Sorry you are dealing with a n00b, I'm still new with these git features. The commit we want is here: 6f96747
Reports everything up to date |
No worries. Our TVM website has one good Git usage tips: https://docs.tvm.ai/contribute/git_howto.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks @jmorrill @FrozenGene @soiferj ! |
* Fix incorrect call to Unicode Win32 * Removed inet_pton call. Win32 already has it.
The recent commit for #4281 is calling the Win32 MACRO InetPton. If the Visual studio project is set to "Use Unicode Character Set", (which tvm.dll seems to be) this calls InetPtonW, which uses wchar_t* (aka PCWSTR). This causes a build error as the "addr_buf" is a char*.
From InetPton docs:
This can be fixed by directly calling InetPtonA, which is safe as the tvm function always uses a char* for add_str and InetPtonA always takes a char* (aka PCSTR)