Skip to contentSkip to conversation

net-sysfs: remove unused initial ret values

PATCH Applied Antoine Tenart 3 participants 3 messages Feb 26, 2025 – Feb 28, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net-sysfs: remove unused initial ret values

In some net-sysfs functions the ret value is initialized but never used as it is always overridden. Remove those.

---
 net/core/net-sysfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
net/core/net-sysfs.c +5 -5
index f61c1d829811..8d9dc048a548 100644
@@ -568,7 +568,7 @@ static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr,
 	struct net_device *netdev = to_net_dev(dev);
 	struct net *net = dev_net(netdev);
 	size_t count = len;
-	ssize_t ret = 0;
+	ssize_t ret;
 
 	if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
 		return -EPERM;
@@ -597,7 +597,7 @@ static ssize_t ifalias_show(struct device *dev,
 {
 	const struct net_device *netdev = to_net_dev(dev);
 	char tmp[IFALIASZ];
-	ssize_t ret = 0;
+	ssize_t ret;
 
 	ret = dev_get_alias(netdev, tmp, sizeof(tmp));
 	if (ret > 0)
@@ -638,7 +638,7 @@ static ssize_t phys_port_id_show(struct device *dev,
 {
 	struct net_device *netdev = to_net_dev(dev);
 	struct netdev_phys_item_id ppid;
-	ssize_t ret = -EINVAL;
+	ssize_t ret;
 
 	/* The check is also done in dev_get_phys_port_id; this helps returning
 	 * early without hitting the locking section below.
@@ -664,8 +664,8 @@ static ssize_t phys_port_name_show(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
 	struct net_device *netdev = to_net_dev(dev);
-	ssize_t ret = -EINVAL;
 	char name[IFNAMSIZ];
+	ssize_t ret;
 
 	/* The checks are also done in dev_get_phys_port_name; this helps
 	 * returning early without hitting the locking section below.
@@ -693,7 +693,7 @@ static ssize_t phys_switch_id_show(struct device *dev,
 {
 	struct net_device *netdev = to_net_dev(dev);
 	struct netdev_phys_item_id ppid = { };
-	ssize_t ret = -EINVAL;
+	ssize_t ret;
 
 	/* The checks are also done in dev_get_phys_port_name; this helps
 	 * returning early without hitting the locking section below. This works
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 50 lines · Antoine Tenart

In some net-sysfs functions the ret value is initialized but never used as it is always overridden. Remove those.

---
  net/core/net-sysfs.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
net/core/net-sysfs.c +4 -4
index f61c1d829811..8d9dc048a548 100644
@@ -568,7 +568,7 @@ static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr,
  	struct net_device *netdev = to_net_dev(dev);
  	struct net *net = dev_net(netdev);
  	size_t count = len;
-	ssize_t ret = 0;
+	ssize_t ret;
 
  	if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
  		return -EPERM;
@@ -597,7 +597,7 @@ static ssize_t ifalias_show(struct device *dev,
  {
  	const struct net_device *netdev = to_net_dev(dev);
  	char tmp[IFALIASZ];
-	ssize_t ret = 0;
+	ssize_t ret;
 
  	ret = dev_get_alias(netdev, tmp, sizeof(tmp));
  	if (ret > 0)
@@ -638,7 +638,7 @@ static ssize_t phys_port_id_show(struct device *dev,
  {
  	struct net_device *netdev = to_net_dev(dev);
  	struct netdev_phys_item_id ppid;
-	ssize_t ret = -EINVAL;
+	ssize_t ret;
 
  	/* The check is also done in dev_get_phys_port_id; this helps returning
  	 * early without hitting the locking section below.
@@ -664,8 +664,8 @@ static ssize_t phys_port_name_show(struct device *dev,
  				   struct device_attribute *attr, char *buf)
  {
  	struct net_device *netdev = to_net_dev(dev);
-	ssize_t ret = -EINVAL;
  	char name[IFNAMSIZ];
+	ssize_t ret;
 
  	/* The checks are also done in dev_get_phys_port_name; this helps
  	 * returning early without hitting the locking section below.

net/core/net-sysfs.c static ssize_t phys_switch_id_show(struct device *dev, · line 699

Quoted 8 lines
net/core/net-sysfs.c +1 -1
@@ -693,7 +693,7 @@ static ssize_t phys_switch_id_show(struct device *dev,
  {
  	struct net_device *netdev = to_net_dev(dev);
  	struct netdev_phys_item_id ppid = { };
-	ssize_t ret = -EINVAL;
+	ssize_t ret;
 
  	/* The checks are also done in dev_get_phys_port_name; this helps
  	 * returning early without hitting the locking section below. This works
#2 lore raw
In reply to Antoine Tenart
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 7 lines · On Wed, 26 Feb 2025 18:46:43 +0100 you wrote:

In some net-sysfs functions the ret value is initialized but never used as it is always overridden. Remove those.

---
 net/core/net-sysfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Here is the summary with links:
- [net-next] net-sysfs: remove unused initial ret values

    https://git.kernel.org/netdev/net-next/c/38d41cf575f7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html