Skip to contentSkip to conversation

net: tcp: Remove redundant initialization of variable len

PATCH Applied Colin Ian King 4 participants 4 messages Feb 16, 2024 – Feb 20, 2024

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

PATCH 1/1 net: tcp: Remove redundant initialization of variable len

The variable len being initialized with a value that is never read, an if statement is initializing it in both paths of the if statement. The initialization is redundant and can be removed.

Cleans up clang scan build warning:
net/ipv4/tcp_ao.c:512:11: warning: Value stored to 'len' during its initialization is never read [deadcode.DeadStores]

---
 net/ipv4/tcp_ao.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_ao.c +1 -1
index 87db432c6bb4..3afeeb68e8a7 100644
@@ -509,9 +509,9 @@ static int tcp_ao_hash_header(struct tcp_sigpool *hp,
 			      bool exclude_options, u8 *hash,
 			      int hash_offset, int hash_len)
 {
-	int err, len = th->doff << 2;
 	struct scatterlist sg;
 	u8 *hdr = hp->scratch;
+	int err, len;
 
 	/* We are not allowed to change tcphdr, make a local copy */
 	if (exclude_options) {
Signature · 1 line
2.39.2
#1 lore raw
Quoted 30 lines · Colin Ian King

The variable len being initialized with a value that is never read, an if statement is initializing it in both paths of the if statement. The initialization is redundant and can be removed.

Cleans up clang scan build warning:
net/ipv4/tcp_ao.c:512:11: warning: Value stored to 'len' during its initialization is never read [deadcode.DeadStores]

---
 net/ipv4/tcp_ao.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_ao.c +1 -2
index 87db432c6bb4..3afeeb68e8a7 100644
@@ -509,9 +509,9 @@ static int tcp_ao_hash_header(struct tcp_sigpool *hp,
                              bool exclude_options, u8 *hash,
                              int hash_offset, int hash_len)
 {
-       int err, len = th->doff << 2;
        struct scatterlist sg;
        u8 *hdr = hp->scratch;
+       int err, len;
 
        /* We are not allowed to change tcphdr, make a local copy */
        if (exclude_options) {
--
Quoted 2 lines

2.39.2

Cc Dmitry Safonov

Dmitry, can you take a look ?

Thanks !

Reviewed-by
#2 lore raw
Quoted 11 lines · Eric Dumazet
Quoted 10 lines · Colin Ian King

The variable len being initialized with a value that is never read, an if statement is initializing it in both paths of the if statement. The initialization is redundant and can be removed.

Cleans up clang scan build warning:
net/ipv4/tcp_ao.c:512:11: warning: Value stored to 'len' during its initialization is never read [deadcode.DeadStores]

LGTM,

Quoted 25 lines
Quoted 20 lines
---
 net/ipv4/tcp_ao.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_ao.c +1 -2
index 87db432c6bb4..3afeeb68e8a7 100644
@@ -509,9 +509,9 @@ static int tcp_ao_hash_header(struct tcp_sigpool *hp,
                              bool exclude_options, u8 *hash,
                              int hash_offset, int hash_len)
 {
-       int err, len = th->doff << 2;
        struct scatterlist sg;
        u8 *hdr = hp->scratch;
+       int err, len;
 
        /* We are not allowed to change tcphdr, make a local copy */
        if (exclude_options) {
--
Quoted 2 lines

2.39.2

Cc Dmitry Safonov

Quoted 1 line

Dmitry, can you take a look ?

Thanks for Cc'ing!

Quoted 2 lines

Thanks !

Thanks,
Dmitry

#3 lore raw
In reply to Colin Ian King
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

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

Quoted 9 lines · On Fri, 16 Feb 2024 12:54:43 +0000 you wrote:

The variable len being initialized with a value that is never read, an if statement is initializing it in both paths of the if statement. The initialization is redundant and can be removed.

Cleans up clang scan build warning:
net/ipv4/tcp_ao.c:512:11: warning: Value stored to 'len' during its initialization is never read [deadcode.DeadStores]

[...]

Here is the summary with links:
- [next] net: tcp: Remove redundant initialization of variable len

    https://git.kernel.org/netdev/net-next/c/465c1abcb644

You are awesome, thank you!

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