blob: d4779505d800a9638a006e84e9fbaf629e8586ad [file] [log] [blame]
Andrew Geissler87f5cff2022-09-30 13:13:31 -05001From 7c370576b4fb7c7d3b6dbf33125136a4ae70a330 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 31 Aug 2022 21:52:16 -0700
4Subject: [PATCH] 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
10Upstream-Status: Submitted [https://sourceforge.net/p/lxdm/code/merge-requests/4/]
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 src/lxcom.c | 9 +++++++--
14 2 files changed, 10 insertions(+), 5 deletions(-)
15
16diff --git a/src/lxcom.c b/src/lxcom.c
17index 397d1b5..517c775 100644
18--- a/src/lxcom.c
19+++ b/src/lxcom.c
20@@ -117,10 +117,15 @@ static gboolean lxcom_dispatch (GSource *source,GSourceFunc callback,gpointer us
21 char ctrl[/*CMSG_SPACE(sizeof(LXDM_CRED))*/1024];
22 struct sockaddr_un peer;
23 struct iovec v={buf,sizeof(buf)};
24- struct msghdr h={&peer,sizeof(peer),&v,1,ctrl,sizeof(ctrl),0};
25+ struct msghdr h={0};
26 struct cmsghdr *cmptr;
27 int ret;
28-
29+ h.msg_name = &peer;
30+ h.msg_namelen = sizeof(peer);
31+ h.msg_iov = &v;
32+ h.msg_iovlen = 1;
33+ h.msg_control = ctrl;
34+ h.msg_controllen = sizeof(ctrl);
35 while(1)
36 {
37 peer.sun_family=0;
38--
392.37.3
40