Skip to contentSkip to conversation

Fix kernel test robot issue and type error in min_t

PATCH NAK Justin Lai 3 participants 9 messages Apr 16, 2025 – Apr 29, 2025

Subsystems (3)
lore
Share & tools
lore

Justin Lai

author maintainer
#0 lore raw

v2 cover Fix kernel test robot issue and type error in min_t

This patch set mainly involves fixing the kernel test robot issue and the type error in min_t.
Details are as follows:
1. Fix the compile error reported by the kernel test robot
2. Fix the compile warning reported by the kernel test robot
3. Fix a type error in min_t

v1 -> v2:
Nothing has changed, and it is simply being posted again because the initial version was posted incompletely.

Justin Lai (3):
rtase: Fix the compile error reported by the kernel test robot
rtase: Fix the compile warning reported by the kernel test robot
rtase: Fix a type error in min_t

 drivers/net/ethernet/realtek/rtase/rtase.h      | 2 +-
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v2 1/3 rtase: Fix the compile error reported by the kernel test robot

Fix the following compile error reported by the kernel test robot by modifying the condition used to detect overflow in rtase_calc_time_mitigation.

In file included from include/linux/mdio.h:10:0,
from drivers/net/ethernet/realtek/rtase/rtase_main.c:58:
In function 'u16_encode_bits',
inlined from 'rtase_calc_time_mitigation.constprop' at drivers/net/ ethernet/realtek/rtase/rtase_main.c:1915:13,
inlined from 'rtase_init_software_variable.isra.41' at drivers/net/ ethernet/realtek/rtase/rtase_main.c:1961:13,
inlined from 'rtase_init_one' at drivers/net/ethernet/realtek/ rtase/rtase_main.c:2111:2:

Quoted 1 line
Quoted 1 line

include/linux/bitfield.h:178:3: error: call to '__field_overflow'

      declared with attribute error: value doesn't fit into mask
    __field_overflow();     \
    ^~~~~~~~~~~~~~~~~~

include/linux/bitfield.h:198:2: note: in expansion of macro '____MAKE_OP'
____MAKE_OP(u##size,u##size,,)
^~~~~~~~~~~
include/linux/bitfield.h:200:1: note: in expansion of macro '__MAKE_OP'
__MAKE_OP(16)
^~~~~~~~~

Fixes a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
---
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/rtase/rtase_main.c +2 -2
index 2aacc1996796..55b8d3666153 100644
@@ -1925,8 +1925,8 @@ static u16 rtase_calc_time_mitigation(u32 time_us)
 
 	time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
 
-	msb = fls(time_us);
-	if (msb >= RTASE_MITI_COUNT_BIT_NUM) {
+	if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
+		msb = fls(time_us);
 		time_unit = msb - RTASE_MITI_COUNT_BIT_NUM;
 		time_count = time_us >> (msb - RTASE_MITI_COUNT_BIT_NUM);
 	} else {
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot

Quoted 3 lines · Justin Lai

Fix the following compile error reported by the kernel test robot by modifying the condition used to detect overflow in rtase_calc_time_mitigation.

The Subject: line is not very useful. It is better to talk about what you are fixing, not that a robot reported an issue.

Andrew

---
pw-bot: cr

author maintainer
#3 lore raw

RE: [PATCH net v2 1/3] rtase: Fix the compile error reported by the kernel test robot

Quoted 6 lines · Justin Lai
Quoted 3 lines

Fix the following compile error reported by the kernel test robot by modifying the condition used to detect overflow in rtase_calc_time_mitigation.

Quoted 7 lines

The Subject: line is not very useful. It is better to talk about what you are fixing, not that a robot reported an issue.

Andrew

---
pw-bot: cr

Hi Andrew,

Thank you for your response. I will modify the subject and post a new version.

Thanks,
Justin

author maintainer
#4 lore raw

PATCH v2 2/3 rtase: Fix the compile warning reported by the kernel test robot

In reply to Justin Lai

Fix the following compile warning reported by the kernel test robot by increasing the size of ivec->name.

drivers/net/ethernet/realtek/rtase/rtase_main.c: In function 'rtase_open':

Quoted 1 line
Quoted 1 line

drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:52: warning:

'%i' directive output may be truncated writing between 1 and 10 bytes into a region of size between 7 and 22 [-Wformat-truncation=]

     snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
                                                     ^~
 drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:45: note:
 directive argument in the range [0, 2147483647]
     snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
                                              ^~~~~~~~~~
 drivers/net/ethernet/realtek/rtase/rtase_main.c:1117:4: note:
 'snprintf' output between 6 and 30 bytes into a destination of
 size 26
     snprintf(ivec->name, sizeof(ivec->name), "%s_int%i",
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       tp->dev->name, i);
       ~~~~~~~~~~~~~~~~~
Fixes a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
---
 drivers/net/ethernet/realtek/rtase/rtase.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/realtek/rtase/rtase.h +1 -1
index 2bbfcad613ab..1e63b5826da1 100644
@@ -259,7 +259,7 @@ union rtase_rx_desc {
 #define RTASE_VLAN_TAG_MASK     GENMASK(15, 0)
 #define RTASE_RX_PKT_SIZE_MASK  GENMASK(13, 0)
 
-#define RTASE_IVEC_NAME_SIZE (IFNAMSIZ + 10)
+#define RTASE_IVEC_NAME_SIZE (IFNAMSIZ + 14)
 
 struct rtase_int_vector {
 	struct rtase_private *tp;
Signature · 1 line
2.34.1
author maintainer
#5 lore raw

PATCH v2 3/3 rtase: Fix a type error in min_t

In reply to Justin Lai

Fix a type error in min_t.

Fixes a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
---
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/rtase/rtase_main.c +2 -2
index 55b8d3666153..bc856fb3d6f3 100644
@@ -1923,7 +1923,7 @@ static u16 rtase_calc_time_mitigation(u32 time_us)
 	u8 msb, time_count, time_unit;
 	u16 int_miti;
 
-	time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
+	time_us = min_t(u32, time_us, RTASE_MITI_MAX_TIME);
 
 	if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
 		msb = fls(time_us);
@@ -1945,7 +1945,7 @@ static u16 rtase_calc_packet_num_mitigation(u16 pkt_num)
 	u8 msb, pkt_num_count, pkt_num_unit;
 	u16 int_miti;
 
-	pkt_num = min_t(int, pkt_num, RTASE_MITI_MAX_PKT_NUM);
+	pkt_num = min_t(u16, pkt_num, RTASE_MITI_MAX_PKT_NUM);
 
 	if (pkt_num > 60) {
 		pkt_num_unit = RTASE_MITI_MAX_PKT_NUM_IDX;
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH net v2 3/3] rtase: Fix a type error in min_t

In reply to Justin Lai
Quoted 1 line · On Wed, 16 Apr 2025 20:45:34 +0800 Justin Lai <[email protected]> wrote:

Fix a type error in min_t.

NAK, in particular u16 is likely to be buggy
Consider what would happen if RTBASE_MITI_MAX_PKT_NUM was 65536. (Yes, I know that isn't the intent of the code...)

As pointed out earlier using min() shouldn't generate a compile warning and won't mask off significant bits.

Also I think it isn't a bug in any sense because the two functions have a single caller that passes a constant.

David

Quoted 29 lines
Fixes a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
---
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/rtase/rtase_main.c +2 -2
index 55b8d3666153..bc856fb3d6f3 100644
@@ -1923,7 +1923,7 @@ static u16 rtase_calc_time_mitigation(u32 time_us)
 	u8 msb, time_count, time_unit;
 	u16 int_miti;
 
-	time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
+	time_us = min_t(u32, time_us, RTASE_MITI_MAX_TIME);
 
 	if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
 		msb = fls(time_us);
@@ -1945,7 +1945,7 @@ static u16 rtase_calc_packet_num_mitigation(u16 pkt_num)
 	u8 msb, pkt_num_count, pkt_num_unit;
 	u16 int_miti;
 
-	pkt_num = min_t(int, pkt_num, RTASE_MITI_MAX_PKT_NUM);
+	pkt_num = min_t(u16, pkt_num, RTASE_MITI_MAX_PKT_NUM);
 
 	if (pkt_num > 60) {
 		pkt_num_unit = RTASE_MITI_MAX_PKT_NUM_IDX;
author maintainer
#8 lore raw

RE: [PATCH net v2 3/3] rtase: Fix a type error in min_t

Quoted 9 lines
Quoted 1 line · On Wed, 16 Apr 2025 20:45:34 +0800 Justin Lai <[email protected]> wrote:

Fix a type error in min_t.

NAK, in particular u16 is likely to be buggy Consider what would happen if RTBASE_MITI_MAX_PKT_NUM was 65536.
(Yes, I know that isn't the intent of the code...)

Quoted 7 lines

As pointed out earlier using min() shouldn't generate a compile warning and won't mask off significant bits.

Also I think it isn't a bug in any sense because the two functions have a single caller that passes a constant.

David

Hi David,

This is indeed not a bug fix, and I have modified it to use min instead of min_t, and posted it to net-next.

Thanks,
Justin

Quoted 35 lines

drivers/net/ethernet/realtek/rtase/rtase_main.c static u16 rtase_calc_time_mitigation(u32

Quoted 16 lines
Fixes a36e9f5cfe9e ("rtase: Add support for a pci table in this

module")

---
 drivers/net/ethernet/realtek/rtase/rtase_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/realtek/rtase/rtase_main.c +0 -0
index 55b8d3666153..bc856fb3d6f3 100644
@@ -1923,7 +1923,7 @@ static u16 rtase_calc_time_mitigation(u32

time_us)

drivers/net/ethernet/realtek/rtase/rtase_main.c static u16 rtase_calc_packet_num_mitigation(u16

Quoted 9 lines
drivers/net/ethernet/realtek/rtase/rtase_main.c +1 -1
      u8 msb, time_count, time_unit;
      u16 int_miti;
 
-     time_us = min_t(int, time_us, RTASE_MITI_MAX_TIME);
+     time_us = min_t(u32, time_us, RTASE_MITI_MAX_TIME);
 
      if (time_us > RTASE_MITI_TIME_COUNT_MASK) {
              msb = fls(time_us);
@@ -1945,7 +1945,7 @@ static u16 rtase_calc_packet_num_mitigation(u16

pkt_num)

Quoted 8 lines
drivers/net/ethernet/realtek/rtase/rtase_main.c +1 -1
      u8 msb, pkt_num_count, pkt_num_unit;
      u16 int_miti;
 
-     pkt_num = min_t(int, pkt_num, RTASE_MITI_MAX_PKT_NUM);
+     pkt_num = min_t(u16, pkt_num, RTASE_MITI_MAX_PKT_NUM);
 
      if (pkt_num > 60) {
              pkt_num_unit = RTASE_MITI_MAX_PKT_NUM_IDX;