Fix struct msghdr initialization
musl defines struct msghdr with padding fields to be strictly POSIX compliant. The current code gives following warnings: irqbalance.c: In function 'sock_handle': irqbalance.c:333:42: warning: initialization makes integer from pointer without a cast [-Wint-conversion] struct msghdr msg = { NULL, 0, &iov, 1, NULL, 0, 0 }; ^~~~ irqbalance.c:333:42: note: (near initialization for 'msg.__pad1') irqbalance.c:333:9: warning: missing initializer for field '__pad2' of 'struct msghdr' [-Wmissing-field-initializers] struct msghdr msg = { NULL, 0, &iov, 1, NULL, 0, 0 }; ^~~~~~ In file included from /usr/include/sys/socket.h:20:0, from /usr/include/fortify/sys/socket.h:20, from irqbalance.c:34: /usr/include/bits/socket.h:7:28: note: '__pad2' declared here socklen_t msg_controllen, __pad2; ^~~~~~ Fix this by not relying on field ordering. Alternatively designated initializers could be used, but as they are not used elsewhere in the code, I used explicit assignments. Signed-off-by: Timo Teräs <timo.teras@iki.fi>
This commit is contained in:
parent
766410ae80
commit
d00f237d78
|
@ -330,7 +330,9 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
|
|||
int valid_user = 0;
|
||||
|
||||
struct iovec iov = { buff, 500 };
|
||||
struct msghdr msg = { NULL, 0, &iov, 1, NULL, 0, 0 };
|
||||
struct msghdr msg = { 0 };
|
||||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = malloc(CMSG_SPACE(sizeof(struct ucred)));
|
||||
msg.msg_controllen = CMSG_SPACE(sizeof(struct ucred));
|
||||
|
||||
|
|
Loading…
Reference in a new issue