blob: 9965d2ec57fe2da40487d7f1ee62f959becd36c6 [file] [log] [blame]
Andrew Geissler87f5cff2022-09-30 13:13:31 -05001From c3f476a763412be51b4df0e748af04d4150a2c71 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 29 Aug 2022 15:41:51 -0700
4Subject: [PATCH] fping: Initialize msghdr struct in a portable way
5
6Initializing the structure assuming glibc layout results in
7compile errors on musl, therefore do partial intialization and then
8assigning the members individually.
9
Patrick Williamsb9af8752023-01-30 13:28:01 -060010Upstream-Status: Submitted [https://github.com/schweikert/fping/pull/263]
Andrew Geissler87f5cff2022-09-30 13:13:31 -050011Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 src/fping.c | 16 +++++++---------
14 1 file changed, 7 insertions(+), 9 deletions(-)
15
16diff --git a/src/fping.c b/src/fping.c
17index e26b216..81a61d9 100644
18--- a/src/fping.c
19+++ b/src/fping.c
20@@ -1951,15 +1951,13 @@ int receive_packet(int64_t wait_time,
21 reply_buf,
22 reply_buf_len
23 };
24- struct msghdr recv_msghdr = {
25- reply_src_addr,
26- reply_src_addr_len,
27- &msg_iov,
28- 1,
29- &msg_control,
30- sizeof(msg_control),
31- 0
32- };
33+ struct msghdr recv_msghdr = {0};
34+ recv_msghdr.msg_name = reply_src_addr;
35+ recv_msghdr.msg_namelen = reply_src_addr_len;
36+ recv_msghdr.msg_iov = &msg_iov;
37+ recv_msghdr.msg_iovlen = 1;
38+ recv_msghdr.msg_control = &msg_control;
39+ recv_msghdr.msg_controllen = sizeof(msg_control);
40 #if HAVE_SO_TIMESTAMPNS
41 struct cmsghdr* cmsg;
42 #endif