Skip to contentSkip to conversation

ethnl_set_linkmodes: remove redundant null check

PATCH Applied Gaurav Singh 3 participants 3 messages Jul 31, 2020 – Aug 3, 2020

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

PATCH 1/1 ethnl_set_linkmodes: remove redundant null check

info cannot be NULL here since its being accessed earlier in the function: nlmsg_parse(info->nlhdr...). Remove this redundant NULL check.

---
 net/ethtool/linkmodes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/ethtool/linkmodes.c +1 -2
index fd4f3e58c6f6..b595d87fa880 100644
@@ -406,8 +406,7 @@ int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info)
 
 	ret = __ethtool_get_link_ksettings(dev, &ksettings);
 	if (ret < 0) {
-		if (info)
-			GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
+		GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
 		goto out_ops;
 	}
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Gaurav Singh

info cannot be NULL here since its being accessed earlier in the function: nlmsg_parse(info->nlhdr...). Remove this redundant NULL check.

This is what the static checker tells you but it could still mean the other place is missing the check. The actual reason why this check is superfluous is that the function is only used as ->doit() handler which is never called with null info.

Quoted 1 line

The subject should rather start with "ethtool: " (instead of "[net/ethtool] ").

For the change itself:

Michal

Quoted 21 lines
---
 net/ethtool/linkmodes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/ethtool/linkmodes.c +1 -2
index fd4f3e58c6f6..b595d87fa880 100644
@@ -406,8 +406,7 @@ int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info)
 
 	ret = __ethtool_get_link_ksettings(dev, &ksettings);
 	if (ret < 0) {
-		if (info)
-			GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
+		GENL_SET_ERR_MSG(info, "failed to retrieve link settings");
 		goto out_ops;
 	}
 
Signature · 1 line
2.17.1