helper: wl-socket: fix build for musl

bind(2) expects its second parameters is a "const struct sockaddr*",
let's cast the "struct sockaddr_un*" to "struct sockaddr*" before
passing into bind(2).

SUN_LEN is a BSD extension that also implemented by GNU, let's define
_DEFAULT_SOURCE before including "sys/un.h".
This commit is contained in:
Đoàn Trần Công Danh 2021-02-24 07:52:10 +07:00 committed by Vlad Zahorodnii
parent 9977f21980
commit 7800f15587

View file

@ -8,6 +8,7 @@
SPDX-License-Identifier: GPL-2.0-or-later SPDX-License-Identifier: GPL-2.0-or-later
*/ */
#define _DEFAULT_SOURCE
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
@ -155,7 +156,7 @@ struct wl_socket *wl_socket_create()
s->fd = socket(PF_LOCAL, SOCK_STREAM, 0); s->fd = socket(PF_LOCAL, SOCK_STREAM, 0);
int size = SUN_LEN(&s->addr); int size = SUN_LEN(&s->addr);
int ret = bind(s->fd, &s->addr, size); int ret = bind(s->fd, (struct sockaddr*)&s->addr, size);
if (ret < 0) { if (ret < 0) {
goto fail; goto fail;
} }