From 7136cd987635e8c323fc7da35c8c9f0d3ba25ebd Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Tue, 21 Feb 2023 23:05:22 +0100 Subject: [PATCH] musl regtest : fix warnings and badly initialized struct msghdr --- memcheck/tests/badpoll.c | 2 +- memcheck/tests/linux/syscalls-2007.c | 4 +--- memcheck/tests/linux/timerfd-syscall.c | 4 +--- none/tests/fdleak_cmsg.c | 14 ++++++++++++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/memcheck/tests/badpoll.c b/memcheck/tests/badpoll.c index 61b8d31bb1..beae44aa31 100644 --- a/memcheck/tests/badpoll.c +++ b/memcheck/tests/badpoll.c @@ -1,6 +1,6 @@ #include #include -#include +#include // At one point, poll()'s checking was not done accurately. This test // exposes this -- previously Memcheck only found one error, now if finds diff --git a/memcheck/tests/linux/syscalls-2007.c b/memcheck/tests/linux/syscalls-2007.c index 54946237eb..b91df82a5e 100644 --- a/memcheck/tests/linux/syscalls-2007.c +++ b/memcheck/tests/linux/syscalls-2007.c @@ -20,9 +20,7 @@ #if defined(HAVE_SYS_EVENTFD_H) #include #endif -#if defined(HAVE_SYS_POLL_H) -#include -#endif +#include #if defined(HAVE_SYS_SIGNALFD_H) #include #endif diff --git a/memcheck/tests/linux/timerfd-syscall.c b/memcheck/tests/linux/timerfd-syscall.c index 4af622cc48..61d75b5545 100644 --- a/memcheck/tests/linux/timerfd-syscall.c +++ b/memcheck/tests/linux/timerfd-syscall.c @@ -35,9 +35,7 @@ #include #include #include -#if defined(HAVE_SYS_SIGNAL_H) -#include -#endif +#include #if defined(HAVE_SYS_SYSCALL_H) #include #endif diff --git a/none/tests/fdleak_cmsg.c b/none/tests/fdleak_cmsg.c index 7927045f5b..d4300bcf2d 100644 --- a/none/tests/fdleak_cmsg.c +++ b/none/tests/fdleak_cmsg.c @@ -91,8 +91,18 @@ void client (void) struct cmsghdr cm; char control[CMSG_SPACE(sizeof(int) * 2)]; } control_un; - struct msghdr msg = { NULL, 0, iov, 1, control_un.control, - sizeof(control_un), 0 }; + struct msghdr msg; + /* this was using brace initialization + * but that doesn't work on MSL because of padding fields + * C99 designated initializers would be nicer + * but I'll just do it the simple way */ + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = iov; + msg.msg_iovlen = 1; + msg.msg_control = control_un.control; + msg.msg_controllen = sizeof(control_un); + msg.msg_flags = 0; struct cmsghdr *cmsg = &control_un.cm; char buf[1024]; -- 2.47.2