Commit 7def93cf authored by Youness Alaoui's avatar Youness Alaoui

use socklen_t where needed, and cast it to size_t as it defined as an int in...

use socklen_t where needed, and cast it to size_t as it defined as an int in mingw and as an uint on linux systems
parent 7e4bf0ee
......@@ -80,7 +80,7 @@ socket_recv (
{
gint recvd;
struct sockaddr_storage sa;
guint from_len = sizeof (sa);
socklen_t from_len = sizeof (sa);
recvd = recvfrom (sock->fileno, buf, len, 0, (struct sockaddr *) &sa,
&from_len);
......@@ -132,7 +132,7 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
{
int sockfd = -1;
struct sockaddr_storage name;
guint name_len = sizeof (name);
socklen_t name_len = sizeof (name);
NiceSocket *sock = g_slice_new0 (NiceSocket);
if (!sock) {
......
......@@ -375,7 +375,7 @@ nice_udp_turn_socket_parse_recv (
StunValidationStatus valid;
StunMessage msg;
struct sockaddr_storage sa;
guint from_len = sizeof (sa);
socklen_t from_len = sizeof (sa);
GList *i = priv->channels;
ChannelBinding *binding = NULL;
......
......@@ -217,7 +217,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type,
case 1:
{
struct sockaddr_in *ip4 = (struct sockaddr_in *)addr;
if ((*addrlen < sizeof (*ip4)) || (len != 8))
if (((size_t) *addrlen < sizeof (*ip4)) || (len != 8))
{
*addrlen = sizeof (*ip4);
return EINVAL;
......@@ -237,7 +237,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type,
case 2:
{
struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)addr;
if ((*addrlen < sizeof (*ip6)) || (len != 20))
if (((size_t) *addrlen < sizeof (*ip6)) || (len != 20))
{
*addrlen = sizeof (*ip6);
return EINVAL;
......@@ -402,7 +402,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type,
uint16_t alen, port;
uint8_t family;
if (addrlen < sizeof (struct sockaddr))
if ((size_t) addrlen < sizeof (struct sockaddr))
return EINVAL;
switch (addr->sa_family)
......@@ -420,7 +420,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type,
case AF_INET6:
{
const struct sockaddr_in6 *ip6 = (const struct sockaddr_in6 *)addr;
if (addrlen < sizeof (*ip6))
if ((size_t) addrlen < sizeof (*ip6))
return EINVAL;
family = 2;
......@@ -453,7 +453,7 @@ int stun_message_append_xor_addr (StunMessage *msg, stun_attr_type_t type,
/* Must be big enough to hold any supported address: */
struct sockaddr_storage xor;
if (addrlen > sizeof (xor))
if ((size_t) addrlen > sizeof (xor))
addrlen = sizeof (xor);
memcpy (&xor, addr, addrlen);
......@@ -474,7 +474,7 @@ int stun_message_append_xor_addr_full (StunMessage *msg, stun_attr_type_t type,
/* Must be big enough to hold any supported address: */
struct sockaddr_storage xor;
if (addrlen > sizeof (xor))
if ((size_t) addrlen > sizeof (xor))
addrlen = sizeof (xor);
memcpy (&xor, addr, addrlen);
......
......@@ -70,7 +70,7 @@ int stun_trans_init (stun_trans_t *tr, int fd,
{
assert (fd != -1);
if (srvlen > sizeof (tr->dst))
if ((size_t) srvlen > sizeof (tr->dst))
return ENOBUFS;
tr->own_fd = -1;
......@@ -126,7 +126,7 @@ int stun_trans_create (stun_trans_t *restrict tr, int type, int proto,
{
int val, fd;
if (srvlen < sizeof(*srv))
if ((size_t) srvlen < sizeof(*srv))
return EINVAL;
fd = stun_socket (srv->sa_family, type, proto);
......
......@@ -176,7 +176,7 @@ int stun_xor_address (const StunMessage *msg,
case AF_INET:
{
struct sockaddr_in *ip4 = (struct sockaddr_in *)addr;
if (addrlen < sizeof (*ip4))
if ((size_t) addrlen < sizeof (*ip4))
return EINVAL;
ip4->sin_port ^= htons (magic_cookie >> 16);
......@@ -189,7 +189,7 @@ int stun_xor_address (const StunMessage *msg,
struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)addr;
unsigned short i;
if (addrlen < sizeof (*ip6))
if ((size_t) addrlen < sizeof (*ip6))
return EINVAL;
ip6->sin6_port ^= htons (magic_cookie >> 16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment