mirror of
https://passt.top/passt
synced 2025-06-18 05:05:33 +02:00
Use C11 anonymous members to make poll refs less verbose to use
union epoll_ref has a deeply nested set of structs and unions to let us subdivide it into the various different fields we want. This means that referencing elements can involve an awkward long string of intermediate fields. Using C11 anonymous structs and unions lets us do this less clumsily. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
649068a287
commit
8218d99013
10 changed files with 73 additions and 78 deletions
4
util.c
4
util.c
|
@ -102,7 +102,7 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto,
|
|||
const void *bind_addr, const char *ifname, uint16_t port,
|
||||
uint32_t data)
|
||||
{
|
||||
union epoll_ref ref = { .r.proto = proto, .r.p.data = data };
|
||||
union epoll_ref ref = { .proto = proto, .data = data };
|
||||
struct sockaddr_in addr4 = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_port = htons(port),
|
||||
|
@ -145,7 +145,7 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto,
|
|||
return -EBADF;
|
||||
}
|
||||
|
||||
ref.r.s = fd;
|
||||
ref.s = fd;
|
||||
|
||||
if (af == AF_INET) {
|
||||
if (bind_addr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue