From c34586d851d6a8630f398f4b5f456ea306b82895 Mon Sep 17 00:00:00 2001 From: WangYuli Date: Sun, 24 Nov 2024 15:10:10 +0800 Subject: [PATCH] eth: linkdata: sxevf: Return -ENOMEM when l_xdp_rxq_reg_failed Fix follow error with clang-19: drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c:73:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] 73 | if (xdp_rxq_info_reg(&ring->xdp_rxq, adapter->netdev, ring->idx, 0) < 0) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c:96:9: note: uninitialized use occurs here 96 | return ret; | ^~~ drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c:73:2: note: remove the 'if' if its condition is always false 73 | if (xdp_rxq_info_reg(&ring->xdp_rxq, adapter->netdev, ring->idx, 0) < 0) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 74 | LOG_ERROR_BDF("ring[%u] xdp rxq info reg failed\n",ring->idx); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 75 | goto l_xdp_rxq_reg_failed; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 76 | } | ~ drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c:35:9: note: initialize the variable 'ret' to silence this warning 35 | s32 ret; | ^ | = 0 1 error generated. Signed-off-by: WangYuli --- drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c b/drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c index a51fe749fc27..aac02c836ae0 100644 --- a/drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c +++ b/drivers/net/ethernet/linkdata/sxevf/sxevf/sxevf_rx_proc.c @@ -32,7 +32,7 @@ static inline int xdp_rxq_info_reg_compat(struct xdp_rxq_info *xdp_rxq, static s32 sxevf_rx_ring_alloc(struct sxevf_ring *ring) { - s32 ret; + s32 ret = 0; u32 size; union sxevf_rx_data_desc *desc; struct sxevf_adapter *adapter = netdev_priv(ring->netdev); @@ -72,13 +72,14 @@ static s32 sxevf_rx_ring_alloc(struct sxevf_ring *ring) #ifndef HAVE_NO_XDP_BUFF_RXQ if (xdp_rxq_info_reg(&ring->xdp_rxq, adapter->netdev, ring->idx, 0) < 0) { LOG_ERROR_BDF("ring[%u] xdp rxq info reg failed\n",ring->idx); + ret = -ENOMEM; goto l_xdp_rxq_reg_failed; } #endif ring->xdp_prog = adapter->xdp_prog; - return 0; + return ret; #ifndef HAVE_NO_XDP_BUFF_RXQ l_xdp_rxq_reg_failed: