[PATCH 2/2] net/bonding: fix minsize build
Jack Bond-Preston
jack.bond-preston at foss.arm.com
Thu Oct 15 14:57:40 CEST 2026
"minsize" builds of DPDK with GCC can trigger the following warning
(error with Werror):
../drivers/net/bonding/rte_eth_bond_pmd.c: In function 'bond_ethdev_tx_burst_tlb':
../drivers/net/bonding/rte_eth_bond_pmd.c:997:29: warning: 'primary_member_addr' may be used uninitialized [-Wmaybe-uninitialized]
997 | if (rte_is_same_ether_addr(ðer_hdr->src_addr,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
998 | &primary_member_addr))
| ~~~~~~~~~~~~~~~~~~~~~
This is a compiler bug - primary_member_addr was initialized above by
the rte_ether_addr_copy() call.
Silence the warning by replacing rte_ether_addr_copy() with memcpy()
in this instance, which satisfies GCC that the variable has been
initialized.
Signed-off-by: Jack Bond-Preston <jack.bond-preston at foss.arm.com>
Reviewed-by: Wathsala Vithanage <wathsala.vithanage at arm.com>
---
Note: The other option is to memset() primary_member_addr after declaring it,
which also satisfies GCC - I went with this change for smaller code impact.
drivers/net/bonding/rte_eth_bond_pmd.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 6a4f997b5a..b7b111536e 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -978,8 +978,13 @@ bond_ethdev_tx_burst_tlb(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
memcpy(members, internals->tlb_members_order,
sizeof(internals->tlb_members_order[0]) * num_of_members);
-
- rte_ether_addr_copy(primary_port->data->mac_addrs, &primary_member_addr);
+ /*
+ * memcpy() the address to avoid a GCC bug - using rte_ether_addr_copy()
+ * causes -Wmaybe-uninitialized warnings to trigger on usages of
+ * primary_member_addr.
+ */
+ memcpy(&primary_member_addr, primary_port->data->mac_addrs,
+ sizeof(primary_member_addr));
if (nb_pkts > 3) {
for (i = 0; i < 3; i++)
--
2.43.0
More information about the dev
mailing list