DPDK patches and discussions
 help / color / mirror / Atom feed
From: Howard Wang <howard_wang@realsil.com.cn>
To: <dev@dpdk.org>
Cc: <pro_nic_dpdk@realtek.com>, Howard Wang <howard_wang@realsil.com.cn>
Subject: [PATCH v1 3/3] net/r8169: fix issues reported by Coverity
Date: Tue, 28 Oct 2025 16:47:16 +0800	[thread overview]
Message-ID: <20251028084716.369128-4-howard_wang@realsil.com.cn> (raw)
In-Reply-To: <20251028084716.369128-1-howard_wang@realsil.com.cn>

Signed-off-by: Howard Wang <howard_wang@realsil.com.cn>
---
 drivers/net/r8169/r8169_hw.c   | 10 ++++-----
 drivers/net/r8169/r8169_phy.c  |  2 +-
 drivers/net/r8169/r8169_rxtx.c | 37 +++++++++++++++++++---------------
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/net/r8169/r8169_hw.c b/drivers/net/r8169/r8169_hw.c
index f69f87c202..e1521f5f9d 100644
--- a/drivers/net/r8169/r8169_hw.c
+++ b/drivers/net/r8169/r8169_hw.c
@@ -346,16 +346,16 @@ rtl_oob_mutex_lock(struct rtl_hw *hw)
 	}
 
 	rtl_ocp_write(hw, ocp_reg_mutex_ib, 1, BIT_0);
-	reg_16 = rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
+	reg_16 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
 	wait_cnt_0 = 0;
 	while (reg_16) {
-		reg_a0 = rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
+		reg_a0 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
 		if (reg_a0) {
 			rtl_ocp_write(hw, ocp_reg_mutex_ib, 1, 0x00);
-			reg_a0 = rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
+			reg_a0 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
 			wait_cnt_1 = 0;
 			while (reg_a0) {
-				reg_a0 = rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
+				reg_a0 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_prio, 1);
 
 				wait_cnt_1++;
 
@@ -364,7 +364,7 @@ rtl_oob_mutex_lock(struct rtl_hw *hw)
 			};
 			rtl_ocp_write(hw, ocp_reg_mutex_ib, 1, BIT_0);
 		}
-		reg_16 = rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
+		reg_16 = (u8)rtl_ocp_read(hw, ocp_reg_mutex_oob, 1);
 
 		wait_cnt_0++;
 
diff --git a/drivers/net/r8169/r8169_phy.c b/drivers/net/r8169/r8169_phy.c
index 9bb5774672..50c24d1504 100644
--- a/drivers/net/r8169/r8169_phy.c
+++ b/drivers/net/r8169/r8169_phy.c
@@ -807,7 +807,7 @@ rtl8168_phy_ram_code_check(struct rtl_hw *hw)
 				retval = FALSE;
 		}
 
-		retval = rtl_clear_phy_mcu_patch_request(hw);
+		rtl_clear_phy_mcu_patch_request(hw);
 
 		rte_delay_ms(2);
 	}
diff --git a/drivers/net/r8169/r8169_rxtx.c b/drivers/net/r8169/r8169_rxtx.c
index 50a47c3670..37f4c4da80 100644
--- a/drivers/net/r8169/r8169_rxtx.c
+++ b/drivers/net/r8169/r8169_rxtx.c
@@ -1707,9 +1707,6 @@ rtl8125_tx_clean(struct rtl_hw *hw, struct rtl_tx_queue *txq)
 	uint32_t tx_left;
 	uint32_t tx_desc_closed;
 
-	if (!txq)
-		return;
-
 	if (enable_tx_no_close) {
 		txq->NextHwDesCloPtr = rtl_get_hw_clo_ptr(txq);
 		tx_desc_closed = rtl_fast_mod_mask(txq->NextHwDesCloPtr -
@@ -1755,9 +1752,6 @@ rtl8168_tx_clean(struct rtl_hw *hw __rte_unused, struct rtl_tx_queue *txq)
 	int head = txq->tx_head;
 	uint16_t desc_freed = 0;
 
-	if (!txq)
-		return;
-
 	while (1) {
 		txd = &txq->hw_ring[head];
 
@@ -1794,13 +1788,13 @@ static int
 rtl8125_tx_done_cleanup(void *tx_queue, uint32_t free_cnt)
 {
 	struct rtl_tx_queue *txq = tx_queue;
-	struct rtl_hw *hw = txq->hw;
-	struct rtl_tx_entry *sw_ring = txq->sw_ring;
+	struct rtl_hw *hw;
+	struct rtl_tx_entry *sw_ring;
 	struct rtl_tx_entry *txe;
 	struct rtl_tx_desc *txd;
-	const uint8_t enable_tx_no_close = hw->EnableTxNoClose;
-	const uint16_t nb_tx_desc = txq->nb_tx_desc;
-	uint16_t head = txq->tx_head;
+	uint8_t enable_tx_no_close;
+	uint16_t nb_tx_desc;
+	uint16_t head;
 	uint16_t desc_freed = 0;
 	uint32_t tx_left;
 	uint32_t count = 0;
@@ -1810,6 +1804,12 @@ rtl8125_tx_done_cleanup(void *tx_queue, uint32_t free_cnt)
 	if (!txq)
 		return -ENODEV;
 
+	hw = txq->hw;
+	enable_tx_no_close = hw->EnableTxNoClose;
+	sw_ring = txq->sw_ring;
+	nb_tx_desc = txq->nb_tx_desc;
+	head = txq->tx_head;
+
 	if (enable_tx_no_close) {
 		txq->NextHwDesCloPtr = rtl_get_hw_clo_ptr(txq);
 		tx_desc_closed = rtl_fast_mod_mask(txq->NextHwDesCloPtr -
@@ -1860,19 +1860,24 @@ static int
 rtl8168_tx_done_cleanup(void *tx_queue, uint32_t free_cnt)
 {
 	struct rtl_tx_queue *txq = tx_queue;
-	struct rtl_tx_entry *sw_ring = txq->sw_ring;
+	struct rtl_tx_entry *sw_ring;
 	struct rtl_tx_entry *txe;
 	struct rtl_tx_desc *txd;
-	const uint16_t nb_tx_desc = txq->nb_tx_desc;
-	const int tx_tail = txq->tx_tail % nb_tx_desc;
-	int head = txq->tx_head;
+	uint16_t nb_tx_desc;
 	uint16_t desc_freed = 0;
-	int count = 0;
 	uint32_t status;
+	int tx_tail;
+	int head;
+	int count = 0;
 
 	if (!txq)
 		return -ENODEV;
 
+	sw_ring = txq->sw_ring;
+	nb_tx_desc = txq->nb_tx_desc;
+	tx_tail = txq->tx_tail % nb_tx_desc;
+	head = txq->tx_head;
+
 	while (1) {
 		txd = &txq->hw_ring[head];
 
-- 
2.34.1


  parent reply	other threads:[~2025-10-28  8:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28  8:47 [PATCH v1 0/3] net/r8169: support multiq and code refactor Howard Wang
2025-10-28  8:47 ` [PATCH v1 1/3] net/r8169: support multiq for 8126 and 8127 Howard Wang
2025-10-28  8:47 ` [PATCH v1 2/3] net/r8169: simplify config method check with if Howard Wang
2025-10-28  8:47 ` Howard Wang [this message]
2025-10-28 13:37   ` [PATCH v1 3/3] net/r8169: fix issues reported by Coverity Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251028084716.369128-4-howard_wang@realsil.com.cn \
    --to=howard_wang@realsil.com.cn \
    --cc=dev@dpdk.org \
    --cc=pro_nic_dpdk@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).