summaryrefslogtreecommitdiff
path: root/erts/emulator
diff options
context:
space:
mode:
authorSverker Eriksson <sverker@erlang.org>2020-04-17 19:13:14 +0200
committerSverker Eriksson <sverker@erlang.org>2020-05-03 22:18:48 +0200
commit54f926beab9f31076af9a95cab70370b52a2fd51 (patch)
treef97b4c7e2a7b72759f39dc689f904ae7e907826e /erts/emulator
parent7f060311f78e421d78e22f2ff856b0ec1bcfe7f3 (diff)
downloaderlang-54f926beab9f31076af9a95cab70370b52a2fd51.tar.gz
erts: Fix int_drv use of type SOCKLEN_T
SOCKLEN_T is used for the last arguments of #define sock_getopt getsockopt #define sock_setopt setsockopt #define sock_name getsockname #define sock_peer getpeername On unix this is type socklen_t, but on Windows this is type int. Commit 011954e851d421b882b0b4eaeda04cfc2895d70a changed SOCKLEN_T from int to size_t which is not correct on Windows. Kept size_t fallback on non-Windows with a compile #warning, not sure if this is ever needed/correct.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index bbc50923b5..ccf60b2a31 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -591,7 +591,10 @@ static int my_strncasecmp(const char *s1, const char *s2, size_t n)
#ifdef HAVE_SOCKLEN_T
# define SOCKLEN_T socklen_t
+#elif defined(__WIN32__)
+# define SOCKLEN_T int
#else
+# warning "Non-Windows OS without type 'socklen_t'"
# define SOCKLEN_T size_t
#endif
@@ -1113,8 +1116,8 @@ typedef struct {
inet_address* peer_ptr; /* fake peername or NULL */
inet_address* name_ptr; /* fake sockname or NULL */
- SOCKLEN_T peer_addr_len; /* fake peername size */
- SOCKLEN_T name_addr_len; /* fake sockname size */
+ unsigned int peer_addr_len; /* fake peername size */
+ unsigned int name_addr_len; /* fake sockname size */
int bufsz; /* minimum buffer constraint */
unsigned int hsz; /* the list header size, -1 is large !!! */
@@ -4778,7 +4781,7 @@ static ErlDrvSSizeT inet_ctl_fdopen(inet_descriptor* desc, int domain, int type,
char** rbuf, ErlDrvSizeT rsize)
{
inet_address name;
- unsigned int sz;
+ SOCKLEN_T sz;
if (bound) {
/* check that it is a socket and that the socket is bound */
@@ -9455,7 +9458,7 @@ static ErlDrvSSizeT inet_ctl(inet_descriptor* desc, int cmd, char* buf,
return ctl_xerror(xerror, rbuf, rsize);
else {
desc->peer_ptr = &desc->peer_addr;
- desc->peer_addr_len = (SOCKLEN_T) len;
+ desc->peer_addr_len = (unsigned int) len;
return ctl_reply(INET_REP_OK, NULL, 0, rbuf, rsize);
}
}
@@ -9530,7 +9533,7 @@ static ErlDrvSSizeT inet_ctl(inet_descriptor* desc, int cmd, char* buf,
return ctl_xerror(xerror, rbuf, rsize);
else {
desc->name_ptr = &desc->name_addr;
- desc->name_addr_len = (SOCKLEN_T) len;
+ desc->name_addr_len = (unsigned int) len;
return ctl_reply(INET_REP_OK, NULL, 0, rbuf, rsize);
}
}