From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 05BF35A0274 for ; Fri, 9 Dec 2022 06:42:41 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4NT0KM3GLPz4xcm; Fri, 9 Dec 2022 16:42:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1670564551; bh=Z1l8v7722h4GsVd8TCPtP3H9FtRfGtgI8sXk+I2ebSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mkgp/3FaM4XHH0rcpgkxnmW6aWKNumny2RMaHL/1EAEA/FXAXy1YPClC48yio0len /ZD44tg3mRDpoQuuLPlCwEs+qFoCjrMufccqRoanPjlmGvTgw3iqklxpN+c2NmSCoN i3UoJn2gvjhoRoUZWFTLBj2Y3wNY7vDfSp6UX7vI= From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 09/18] tcp, udp: Use named field initializers in iov_init functions Date: Fri, 9 Dec 2022 16:42:19 +1100 Message-Id: <20221209054228.4085990-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221209054228.4085990-1-david@gibson.dropbear.id.au> References: <20221209054228.4085990-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: MRQDT54QLTHDHC3G6ES4GIJ7BZHAIUQA X-Message-ID-Hash: MRQDT54QLTHDHC3G6ES4GIJ7BZHAIUQA X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- tcp.c | 26 ++++++++++++-------------- udp.c | 13 ++++--------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/tcp.c b/tcp.c index 0c46a7e..79fc733 100644 --- a/tcp.c +++ b/tcp.c @@ -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) }; } diff --git a/udp.c b/udp.c index f7b9bdc..ffedca1 100644 --- a/udp.c +++ b/udp.c @@ -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) }; } -- 2.38.1