From b13fdc4860b5e1bf615b113950788a138e68ae7f Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Wed, 30 Sep 2015 10:15:03 +0200 Subject: 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 Reviewed-by: Tim Hudson --- e_os.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'e_os.h') 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)) -- cgit v1.2.3