diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-01-06 11:43:13 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-01-23 18:54:44 +0100 |
commit | 67afaab411001d777c4af6b016c7c045ef4d8ed5 (patch) | |
tree | 5d4294fdc9b5b455f9a107e2ecc89a5700274704 | |
parent | f5a950115be5aca6d19ea183247bc36088c472c9 (diff) | |
download | passt-67afaab411001d777c4af6b016c7c045ef4d8ed5.tar passt-67afaab411001d777c4af6b016c7c045ef4d8ed5.tar.gz passt-67afaab411001d777c4af6b016c7c045ef4d8ed5.tar.bz2 passt-67afaab411001d777c4af6b016c7c045ef4d8ed5.tar.lz passt-67afaab411001d777c4af6b016c7c045ef4d8ed5.tar.xz passt-67afaab411001d777c4af6b016c7c045ef4d8ed5.tar.zst passt-67afaab411001d777c4af6b016c7c045ef4d8ed5.zip |
tcp, udp: Use named field initializers in iov_init functions
Both the TCP and UDP iov_init functions have some large structure literals
defined in "field order" style. These are pretty hard to read since it's
not obvious what value corresponds to what field. Use named field style
initializers instead to make this clearer.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | tcp.c | 26 | ||||
-rw-r--r-- | udp.c | 13 |
2 files changed, 16 insertions, 23 deletions
@@ -1058,18 +1058,17 @@ static void tcp_sock4_iov_init(void) int i; for (i = 0; i < ARRAY_SIZE(tcp4_l2_buf); i++) { - tcp4_l2_buf[i] = (struct tcp4_l2_buf_t) { 0, 0, - { 0 }, - 0, L2_BUF_ETH_IP4_INIT, L2_BUF_IP4_INIT(IPPROTO_TCP), - { .doff = sizeof(struct tcphdr) / 4, .ack = 1 }, { 0 }, + tcp4_l2_buf[i] = (struct tcp4_l2_buf_t) { + .eh = L2_BUF_ETH_IP4_INIT, + .iph = L2_BUF_IP4_INIT(IPPROTO_TCP), + .th = { .doff = sizeof(struct tcphdr) / 4, .ack = 1 } }; } for (i = 0; i < ARRAY_SIZE(tcp4_l2_flags_buf); i++) { - tcp4_l2_flags_buf[i] = (struct tcp4_l2_flags_buf_t) { 0, 0, - { 0 }, - 0, L2_BUF_ETH_IP4_INIT, L2_BUF_IP4_INIT(IPPROTO_TCP), - { 0 }, { 0 }, + tcp4_l2_flags_buf[i] = (struct tcp4_l2_flags_buf_t) { + .eh = L2_BUF_ETH_IP4_INIT, + .iph = L2_BUF_IP4_INIT(IPPROTO_TCP) }; } @@ -1092,17 +1091,16 @@ static void tcp_sock6_iov_init(void) for (i = 0; i < ARRAY_SIZE(tcp6_l2_buf); i++) { tcp6_l2_buf[i] = (struct tcp6_l2_buf_t) { - { 0 }, - 0, L2_BUF_ETH_IP6_INIT, L2_BUF_IP6_INIT(IPPROTO_TCP), - { .doff = sizeof(struct tcphdr) / 4, .ack = 1 }, { 0 }, + .eh = L2_BUF_ETH_IP6_INIT, + .ip6h = L2_BUF_IP6_INIT(IPPROTO_TCP), + .th = { .doff = sizeof(struct tcphdr) / 4, .ack = 1 } }; } for (i = 0; i < ARRAY_SIZE(tcp6_l2_flags_buf); i++) { tcp6_l2_flags_buf[i] = (struct tcp6_l2_flags_buf_t) { - { 0 }, - 0, L2_BUF_ETH_IP6_INIT, L2_BUF_IP6_INIT(IPPROTO_TCP), - { 0 }, { 0 }, + .eh = L2_BUF_ETH_IP6_INIT, + .ip6h = L2_BUF_IP6_INIT(IPPROTO_TCP) }; } @@ -329,9 +329,8 @@ static void udp_sock4_iov_init(const struct ctx *c) for (i = 0; i < ARRAY_SIZE(udp4_l2_buf); i++) { udp4_l2_buf[i] = (struct udp4_l2_buf_t) { - { 0 }, 0, 0, - L2_BUF_ETH_IP4_INIT, L2_BUF_IP4_INIT(IPPROTO_UDP), - {{{ 0 }}}, { 0 }, + .eh = L2_BUF_ETH_IP4_INIT, + .iph = L2_BUF_IP4_INIT(IPPROTO_UDP) }; } @@ -371,12 +370,8 @@ static void udp_sock6_iov_init(const struct ctx *c) for (i = 0; i < ARRAY_SIZE(udp6_l2_buf); i++) { udp6_l2_buf[i] = (struct udp6_l2_buf_t) { - { 0 }, -#ifdef __AVX2__ - { 0 }, -#endif - 0, L2_BUF_ETH_IP6_INIT, L2_BUF_IP6_INIT(IPPROTO_UDP), - {{{ 0 }}}, { 0 }, + .eh = L2_BUF_ETH_IP6_INIT, + .ip6h = L2_BUF_IP6_INIT(IPPROTO_UDP) }; } |