-
-
Notifications
You must be signed in to change notification settings - Fork 420
Mark all functions with a @safe interface as @trusted #3839
Conversation
Thanks for your pull request, @schveiguy! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + druntime#3839" |
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.
Looks fine according to MSDN documentation.
@WalterBright do you have any comments on this? |
@@ -64,11 +64,11 @@ int getsockopt(SOCKET s, int level, int optname, void* optval, socklen_t* optlen | |||
int setsockopt(SOCKET s, int level, int optname, const(void)* optval, socklen_t optlen); | |||
uint inet_addr(const char* cp); | |||
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds, const(timeval)* timeout); | |||
char* inet_ntoa(in_addr ina); | |||
@trusted char* inet_ntoa(in_addr ina); |
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.
inet_ntoa
cannot be @trusted
.
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-inet_ntoa#remarks says:
The string returned by inet_ntoa resides in memory that is allocated by Windows Sockets. The application should not make any assumptions about the way in which the memory is allocated. The string returned is guaranteed to be valid only until the next Windows Sockets function call is made within the same thread.
I.e., if you dereference the returned pointer after having called another Windows Sockets function, you've got undefined behavior. That's not safe.
hostent* gethostbyname(const char* name); | ||
hostent* gethostbyaddr(const(void)* addr, int len, int type); | ||
protoent* getprotobyname(const char* name); | ||
protoent* getprotobynumber(int number); | ||
@trusted protoent* getprotobynumber(int number); |
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.
getprotobynumber
cannot be @trusted
.
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getprotobynumber#remarks says:
The pointer that is returned points to the structure allocated by Windows Sockets. The application must never attempt to modify this structure [...].
But the return value is mutable. So @safe
code might do just that.
Ping @WalterBright
This took 10 minutes.