Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame^] | 1 | From 7c370576b4fb7c7d3b6dbf33125136a4ae70a330 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 31 Aug 2022 21:52:16 -0700 |
| 4 | Subject: [PATCH] Initialize msghdr struct in a portable way |
| 5 | |
| 6 | Initializing the structure assuming glibc layout results in |
| 7 | compile errors on musl, therefore do partial intialization and then |
| 8 | assigning the members individually. |
| 9 | |
| 10 | Upstream-Status: Submitted [https://sourceforge.net/p/lxdm/code/merge-requests/4/] |
| 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 12 | --- |
| 13 | src/lxcom.c | 9 +++++++-- |
| 14 | 2 files changed, 10 insertions(+), 5 deletions(-) |
| 15 | |
| 16 | diff --git a/src/lxcom.c b/src/lxcom.c |
| 17 | index 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 | -- |
| 39 | 2.37.3 |
| 40 | |