[PATCH linux-next] net/core: Remove unused assignment operations and variable

Subsystems: networking [general], the rest

STALE1763d

2 messages, 2 authors, 2021-10-20 · open the first message on its own page

[PATCH linux-next] net/core: Remove unused assignment operations and variable

From: luo penghao <hidden>
Date: 2021-10-18 09:14:24

From: penghao luo <redacted>

Although if_info_size is assigned, it has not been used. And the variable
should also be deleted.

The clang_analyzer complains as follows:

net/core/rtnetlink.c:3806: warning:

Although the value stored to 'if_info_size' is used in the enclosing expression,
the value is never actually read from 'if_info_size'.

Reported-by: Zeal Robot <redacted>
Signed-off-by: penghao luo <redacted>
---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 327ca6b..52dc51a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3804,9 +3804,9 @@ struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
 	struct net *net = dev_net(dev);
 	struct sk_buff *skb;
 	int err = -ENOBUFS;
-	size_t if_info_size;
 
-	skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), flags);
+
+	skb = nlmsg_new((if_nlmsg_size(dev, 0)), flags);
 	if (skb == NULL)
 		goto errout;
 
-- 
2.15.2

Re: [PATCH linux-next] net/core: Remove unused assignment operations and variable

From: Simon Horman <horms@kernel.org>
Date: 2021-10-20 09:21:38

On Mon, Oct 18, 2021 at 09:13:56AM +0000, luo penghao wrote:
From: penghao luo <redacted>
I think the correct patch prefix for this patch would be:

[PATCH net-next] rtnetlink:
quoted hunk
Although if_info_size is assigned, it has not been used. And the variable
should also be deleted.

The clang_analyzer complains as follows:

net/core/rtnetlink.c:3806: warning:

Although the value stored to 'if_info_size' is used in the enclosing expression,
the value is never actually read from 'if_info_size'.

Reported-by: Zeal Robot <redacted>
Signed-off-by: penghao luo <redacted>
---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 327ca6b..52dc51a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3804,9 +3804,9 @@ struct sk_buff *rtmsg_ifinfo_build_skb(int type, struct net_device *dev,
 	struct net *net = dev_net(dev);
 	struct sk_buff *skb;
 	int err = -ENOBUFS;
-	size_t if_info_size;
 
-	skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), flags);
+
+	skb = nlmsg_new((if_nlmsg_size(dev, 0)), flags);
I think you can also drop the parentheses around the call to if_nlmsg_size.
 	if (skb == NULL)
 		goto errout;
 
-- 
2.15.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help