gsocket: fix -Wsign-compare warnings when socklen_t is signed

under cygwin socklen_t is signed which leads to warnings like:

warning: comparison of integer expressions of different signedness:
‘long unsigned int’ and ‘socklen_t’ {aka ‘int’} [-Wsign-compare]

In both cases we compare against some small fixed sizes, so cast them
to socklen_t.
This commit is contained in:
Christoph Reiter 2022-12-02 20:48:50 +01:00
parent e31c6accc5
commit 60ab0737df

View File

@ -503,7 +503,7 @@ g_socket_details_from_fd (GSocket *socket)
if (addrlen > 0) if (addrlen > 0)
{ {
g_assert (G_STRUCT_OFFSET (struct sockaddr, sa_family) + g_assert (G_STRUCT_OFFSET (struct sockaddr, sa_family) +
sizeof address.storage.ss_family <= addrlen); (socklen_t) sizeof address.storage.ss_family <= addrlen);
family = address.storage.ss_family; family = address.storage.ss_family;
} }
else else
@ -4679,7 +4679,7 @@ input_message_from_msghdr (const struct msghdr *msg,
GPtrArray *my_messages = NULL; GPtrArray *my_messages = NULL;
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
if (msg->msg_controllen >= sizeof (struct cmsghdr)) if (msg->msg_controllen >= (socklen_t) sizeof (struct cmsghdr))
{ {
g_assert (message->control_messages != NULL); g_assert (message->control_messages != NULL);
for (cmsg = CMSG_FIRSTHDR (msg); for (cmsg = CMSG_FIRSTHDR (msg);