Skip to content

Commit

Permalink
fping: Initialize msghdr struct in a portable way
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kraj authored and schweikert committed Aug 27, 2023
1 parent f94adaf commit c0fbccb
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0fbccb

Please sign in to comment.