diff options
author | Thomas Haller <thaller@redhat.com> | 2024-05-29 16:01:34 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2024-05-29 18:03:38 (GMT) |
commit | 5248e1a45576617b349465997822cef34cbc5053 (patch) | |
tree | 4e4e588cda887f1691afdea3186b4b413bf5e966 /lib/nl.c | |
parent | 9451842e1109d909a7803db2266ccb1f8f00eef2 (diff) | |
download | libnl-5248e1a45576617b349465997822cef34cbc5053.zip libnl-5248e1a45576617b349465997822cef34cbc5053.tar.gz libnl-5248e1a45576617b349465997822cef34cbc5053.tar.bz2 |
all: fix and enable "-Wsign-compare" warning
Diffstat (limited to 'lib/nl.c')
-rw-r--r-- | lib/nl.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -659,7 +659,7 @@ int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla, { ssize_t n; int flags = 0; - static int page_size = 0; + static int page_size = 0; /* GLOBAL! */ struct iovec iov; struct msghdr msg = { .msg_name = (void *) nla, @@ -680,7 +680,7 @@ int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla, if (page_size == 0) page_size = getpagesize() * 4; - iov.iov_len = sk->s_bufsize ? sk->s_bufsize : page_size; + iov.iov_len = sk->s_bufsize ? sk->s_bufsize : ((size_t)page_size); iov.iov_base = malloc(iov.iov_len); if (!iov.iov_base) { @@ -734,7 +734,7 @@ retry: goto retry; } - if (iov.iov_len < n || (msg.msg_flags & MSG_TRUNC)) { + if (iov.iov_len < ((size_t)n) || (msg.msg_flags & MSG_TRUNC)) { void *tmp; /* respond with error to an incomplete message */ @@ -964,7 +964,8 @@ continue_reading: else if (hdr->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *e = nlmsg_data(hdr); - if (hdr->nlmsg_len < nlmsg_size(sizeof(*e))) { + if (hdr->nlmsg_len < + ((unsigned)nlmsg_size(sizeof(*e)))) { /* Truncated error message, the default action * is to stop parsing. The user may overrule * this action by returning NL_SKIP or |