diff mbox series

[next] net: tcp: Remove redundant initialization of variable len

Message ID 20240216125443.2107244-1-colin.i.king@gmail.com (mailing list archive)
State Accepted
Commit 465c1abcb64426f0ff39e80e508e2432672c2dae
Delegated to: Netdev Maintainers
Headers show
Series [next] net: tcp: Remove redundant initialization of variable len | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 5 maintainers not CCed: morbo@google.com justinstitt@google.com nathan@kernel.org ndesaulniers@google.com llvm@lists.linux.dev
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-19--18-00 (tests: 1449)

Commit Message

Colin Ian King Feb. 16, 2024, 12:54 p.m. UTC
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]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 net/ipv4/tcp_ao.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Dumazet Feb. 16, 2024, 1 p.m. UTC | #1
On Fri, Feb 16, 2024 at 1:54 PM Colin Ian King <colin.i.king@gmail.com> 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]
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  net/ipv4/tcp_ao.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c
> index 87db432c6bb4..3afeeb68e8a7 100644
> --- a/net/ipv4/tcp_ao.c
> +++ b/net/ipv4/tcp_ao.c
> @@ -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) {
> --
> 2.39.2
>

Cc Dmitry Safonov

Dmitry, can you take a look ?

Thanks !
Dmitry Safonov Feb. 16, 2024, 3:30 p.m. UTC | #2
On 2/16/24 13:00, Eric Dumazet wrote:
> On Fri, Feb 16, 2024 at 1:54 PM Colin Ian King <colin.i.king@gmail.com> 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]
>>
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

LGTM,

Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>

>> ---
>>  net/ipv4/tcp_ao.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c
>> index 87db432c6bb4..3afeeb68e8a7 100644
>> --- a/net/ipv4/tcp_ao.c
>> +++ b/net/ipv4/tcp_ao.c
>> @@ -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) {
>> --
>> 2.39.2
>>
> 
> Cc Dmitry Safonov
> 
> Dmitry, can you take a look ?

Thanks for Cc'ing!

> 
> Thanks !

Thanks,
             Dmitry
patchwork-bot+netdevbpf@kernel.org Feb. 20, 2024, 10:50 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

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!
diff mbox series

Patch

diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c
index 87db432c6bb4..3afeeb68e8a7 100644
--- a/net/ipv4/tcp_ao.c
+++ b/net/ipv4/tcp_ao.c
@@ -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) {