summaryrefslogtreecommitdiff
blob: d56bb501682c6ee20159efd5c62521a4946ad0bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
https://bugs.gentoo.org/895182
https://github.com/schweikert/fping/commit/c0fbccb977c523ba671afdf0f37de40d26351f77

From c0fbccb977c523ba671afdf0f37de40d26351f77 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 29 Aug 2022 15:41:51 -0700
Subject: [PATCH] fping: Initialize msghdr struct in a portable way

Initializing the structure assuming glibc layout results in
compile errors on musl, therefore do partial intialization and then
assigning the members individually.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
--- a/src/fping.c
+++ b/src/fping.c
@@ -1962,15 +1962,13 @@ int receive_packet(int64_t wait_time,
         reply_buf,
         reply_buf_len
     };
-    struct msghdr recv_msghdr = {
-        reply_src_addr,
-        reply_src_addr_len,
-        &msg_iov,
-        1,
-        &msg_control,
-        sizeof(msg_control),
-        0
-    };
+    struct msghdr recv_msghdr = {0};
+    recv_msghdr.msg_name = reply_src_addr;
+    recv_msghdr.msg_namelen = reply_src_addr_len;
+    recv_msghdr.msg_iov = &msg_iov;
+    recv_msghdr.msg_iovlen = 1;
+    recv_msghdr.msg_control = &msg_control;
+    recv_msghdr.msg_controllen = sizeof(msg_control);
 #if HAVE_SO_TIMESTAMPNS
     struct cmsghdr *cmsg;
 #endif