summaryrefslogtreecommitdiffstats
path: root/lib/nl.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2024-05-29 16:01:34 (GMT)
committerThomas Haller <thaller@redhat.com>2024-05-29 18:03:38 (GMT)
commit5248e1a45576617b349465997822cef34cbc5053 (patch)
tree4e4e588cda887f1691afdea3186b4b413bf5e966 /lib/nl.c
parent9451842e1109d909a7803db2266ccb1f8f00eef2 (diff)
downloadlibnl-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.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/nl.c b/lib/nl.c
index 7d729a7..a24c026 100644
--- a/lib/nl.c
+++ b/lib/nl.c
@@ -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