Skip to content

Commit e43c54e

Browse files
committed
Use designated initializers for iovec and msghdr structs
POSIX does not guarantee the absence of other members (or even the ordering of the members) for these structs. luastatus reportedly does not build with musl because musl inserts "padding" members into struct msghdr: https://git.musl-libc.org/cgit/musl/commit/?id=7168790763cdeb794df52be6e3b3 Reported-by: #73
1 parent 44ceeab commit e43c54e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugins/network-linux/network.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ static bool interact(LuastatusPluginData *pd, LuastatusPluginRunFuncs funcs)
332332
while (1) {
333333
make_call(pd, funcs, false);
334334

335-
struct iovec iov = {buf, NBUF};
336-
struct msghdr msg = {NULL, 0, &iov, 1, NULL, 0, 0};
335+
struct iovec iov = {.iov_base = buf, .iov_len = NBUF};
336+
struct msghdr msg = {.msg_iov = &iov, .msg_iovlen = 1};
337337
ssize_t len = recvmsg(fd, &msg, 0);
338338
if (len < 0) {
339339
if (errno == EINTR) {

0 commit comments

Comments
 (0)