Skip to contentSkip to conversation

net: dsa: mt7530: refactor deprecated strncpy

PATCH In review Shubh 2 participants 2 messages Sep 5, 2023

Subsystems (5)
lore
Share & tools
lore

Shubh

author
#0 lore raw

PATCH 1/1 net: dsa: mt7530: refactor deprecated strncpy

Prefer strscpy_pad to strncpy.

---
 drivers/net/dsa/mt7530.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +1 -1
index 035a34b50..ee19475ec 100644
@@ -836,7 +836,7 @@ mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset,
 		return;
 
 	for (i = 0; i < ARRAY_SIZE(mt7530_mib); i++)
-		strncpy(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name,
+		strscpy_pad(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name,
 			ETH_GSTRING_LEN);
 }
 
Signature · 1 line
2.42.0
reviewer
#1 lore raw
Quoted 1 line · Shubh

Prefer strscpy_pad to strncpy.

I think this needs some justification.
Why is strscpy_pad() preferred in this case?

Also, assuming this is not a bug-fix for 'net', then it is an enhancement, and should be targeted at net-next.

Subject: [PATCH net-next] ...

As it stands, net-next is closed:

## Form letter - net-next-closed

The merge window for v6.6 has begun and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after Sept 11th.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

Quoted 11 lines
---
 drivers/net/dsa/mt7530.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +0 -0
index 035a34b50..ee19475ec 100644

drivers/net/dsa/mt7530.c mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset, · line 840

Quoted 6 lines
drivers/net/dsa/mt7530.c +1 -1
@@ -836,7 +836,7 @@ mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset,
 		return;
 
 	for (i = 0; i < ARRAY_SIZE(mt7530_mib); i++)
-		strncpy(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name,
+		strscpy_pad(data + i * ETH_GSTRING_LEN, mt7530_mib[i].name,
 			ETH_GSTRING_LEN);

The line above is no longer indented correctly.

drivers/net/dsa/mt7530.c mt7530_get_strings(struct dsa_switch *ds, int port, u32 stringset, · line 841

Quoted 1 line
drivers/net/dsa/mt7530.c +0 -0
 }

--
pw-bot: defer