summaryrefslogtreecommitdiffstats
path: root/e_os.h
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2015-09-30 10:15:03 +0200
committerAndy Polyakov <appro@openssl.org>2015-10-05 09:22:54 +0200
commitb13fdc4860b5e1bf615b113950788a138e68ae7f (patch)
tree231723cef2d8432fa559e011d5c7eed93a2482c5 /e_os.h
parentf93ad22f6adb00e722c130e792799467f3927b56 (diff)
Explicitly cast INVALID_SOCKET to (int) to address warnings on Windows.
Even though SOCKET is effectively declared as (void *) on Windows, it's not actually a pointer, but an index within per-process table of kernel objects. The table size is actually limited and its upper limit is far below upper limit for signed 32-bit integer. This is what makes cast in question possible. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'e_os.h')
-rw-r--r--e_os.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/e_os.h b/e_os.h
index 8c4223bc53..6aa0f73ed0 100644
--- a/e_os.h
+++ b/e_os.h
@@ -477,7 +477,9 @@ struct servent *PASCAL getservbyname(const char *, const char *);
/*
* Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
* the value constitutes an index in per-process table of limited size
- * and not a real pointer.
+ * and not a real pointer. And we also depend on fact that all processors
+ * Windows run on happen to be two's-complement, which allows to
+ * interchange INVALID_SOCKET and -1.
*/
# define socket(d,t,p) ((int)socket(d,t,p))
# define accept(s,f,l) ((int)accept(s,f,l))