From: Roy Marples Date: Mon, 9 Jan 2023 11:15:13 +0000 (+0000) Subject: linux: clean some more compiler warnings X-Git-Tag: v10.0.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b74f62e038e94370ea977053dca798db218419d;p=thirdparty%2Fdhcpcd.git linux: clean some more compiler warnings gcc-12 and clang-14 no longer emit any errors --- diff --git a/src/if-linux.c b/src/if-linux.c index 057eaf89..3ca96705 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -554,15 +554,15 @@ if_getnetlink(struct dhcpcd_ctx *ctx, struct iovec *iov, int fd, int flags, .msg_name = &nladdr, .msg_namelen = sizeof(nladdr), .msg_iov = iov, .msg_iovlen = 1, }; - ssize_t len; + size_t len; struct nlmsghdr *nlm; int r = 0; unsigned int again; bool terminated; recv_again: - len = recvmsg(fd, &msg, flags); - if (len == -1 || len == 0) + len = (size_t)recvmsg(fd, &msg, flags); + if (len == 0 || (ssize_t)len == -1) return (int)len; /* Check sender */ @@ -578,7 +578,7 @@ recv_again: again = 0; terminated = false; for (nlm = iov->iov_base; - nlm && NLMSG_OK(nlm, (size_t)len); + nlm && NLMSG_OK(nlm, len); nlm = NLMSG_NEXT(nlm, len)) { again = (nlm->nlmsg_flags & NLM_F_MULTI); @@ -1143,7 +1143,8 @@ if_sendnetlink(struct dhcpcd_ctx *ctx, int protocol, struct nlmsghdr *hdr, } #define NLMSG_TAIL(nmsg) \ - ((struct rtattr *)(((ptrdiff_t)(nmsg))+NLMSG_ALIGN((nmsg)->nlmsg_len))) + ((struct rtattr *)(void *)(((char *)(nmsg)) + \ + NLMSG_ALIGN((nmsg)->nlmsg_len))) static int add_attr_l(struct nlmsghdr *n, unsigned short maxlen, unsigned short type,