All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: remove redundant check on tskb
@ 2019-04-04 14:46 ` Colin King
  0 siblings, 0 replies; 10+ messages in thread
From: Colin King @ 2019-04-04 14:46 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The non-null check on tskb is always false because it is in an else
path of a check on tskb and hence tskb is null in this code block.
This is check is therefore redundant and can be removed as well
as the label coalesc.

if (tsbk) {
        ...
} else {
        ...
        if (unlikely(!skb)) {
                if (tskb)       /* can never be true, redundant code */
                        goto coalesc;
                return;
        }
}

Addresses-Coverity: ("Logically dead code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/ipv4/tcp_output.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e265d1aeeb66..32061928b054 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3088,7 +3088,6 @@ void tcp_send_fin(struct sock *sk)
 		tskb = skb_rb_last(&sk->tcp_rtx_queue);
 
 	if (tskb) {
-coalesce:
 		TCP_SKB_CB(tskb)->tcp_flags |= TCPHDR_FIN;
 		TCP_SKB_CB(tskb)->end_seq++;
 		tp->write_seq++;
@@ -3104,11 +3103,9 @@ void tcp_send_fin(struct sock *sk)
 		}
 	} else {
 		skb = alloc_skb_fclone(MAX_TCP_HEADER, sk->sk_allocation);
-		if (unlikely(!skb)) {
-			if (tskb)
-				goto coalesce;
+		if (unlikely(!skb))
 			return;
-		}
+
 		INIT_LIST_HEAD(&skb->tcp_tsorted_anchor);
 		skb_reserve(skb, MAX_TCP_HEADER);
 		sk_forced_mem_schedule(sk, skb->truesize);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] tcp: remove redundant check on tskb
@ 2019-04-04 14:46 ` Colin King
  0 siblings, 0 replies; 10+ messages in thread
From: Colin King @ 2019-04-04 14:46 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The non-null check on tskb is always false because it is in an else
path of a check on tskb and hence tskb is null in this code block.
This is check is therefore redundant and can be removed as well
as the label coalesc.

if (tsbk) {
        ...
} else {
        ...
        if (unlikely(!skb)) {
                if (tskb)       /* can never be true, redundant code */
                        goto coalesc;
                return;
        }
}

Addresses-Coverity: ("Logically dead code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/ipv4/tcp_output.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e265d1aeeb66..32061928b054 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3088,7 +3088,6 @@ void tcp_send_fin(struct sock *sk)
 		tskb = skb_rb_last(&sk->tcp_rtx_queue);
 
 	if (tskb) {
-coalesce:
 		TCP_SKB_CB(tskb)->tcp_flags |= TCPHDR_FIN;
 		TCP_SKB_CB(tskb)->end_seq++;
 		tp->write_seq++;
@@ -3104,11 +3103,9 @@ void tcp_send_fin(struct sock *sk)
 		}
 	} else {
 		skb = alloc_skb_fclone(MAX_TCP_HEADER, sk->sk_allocation);
-		if (unlikely(!skb)) {
-			if (tskb)
-				goto coalesce;
+		if (unlikely(!skb))
 			return;
-		}
+
 		INIT_LIST_HEAD(&skb->tcp_tsorted_anchor);
 		skb_reserve(skb, MAX_TCP_HEADER);
 		sk_forced_mem_schedule(sk, skb->truesize);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
  2019-04-04 14:46 ` Colin King
@ 2019-04-04 15:05   ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2019-04-04 15:05 UTC (permalink / raw)
  To: Colin King
  Cc: Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev, kernel-janitors, linux-kernel

On Thu, Apr 04, 2019 at 03:46:03PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
> 
> if (tsbk) {
>         ...
> } else {
>         ...
>         if (unlikely(!skb)) {
>                 if (tskb)       /* can never be true, redundant code */
>                         goto coalesc;
>                 return;
>         }
> }
> 
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

This was fallout from commit 75c119afe14f ("tcp: implement rb-tree based
retransmit queue").

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
@ 2019-04-04 15:05   ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2019-04-04 15:05 UTC (permalink / raw)
  To: Colin King
  Cc: Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev, kernel-janitors, linux-kernel

On Thu, Apr 04, 2019 at 03:46:03PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
> 
> if (tsbk) {
>         ...
> } else {
>         ...
>         if (unlikely(!skb)) {
>                 if (tskb)       /* can never be true, redundant code */
>                         goto coalesc;
>                 return;
>         }
> }
> 
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

This was fallout from commit 75c119afe14f ("tcp: implement rb-tree based
retransmit queue").

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
  2019-04-04 14:46 ` Colin King
@ 2019-04-05  6:59   ` Mukesh Ojha
  -1 siblings, 0 replies; 10+ messages in thread
From: Mukesh Ojha @ 2019-04-05  6:47 UTC (permalink / raw)
  To: Colin King, Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev
  Cc: kernel-janitors, linux-kernel


On 4/4/2019 8:16 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
>
> if (tsbk) {
>          ...
> } else {
>          ...
>          if (unlikely(!skb)) {
>                  if (tskb)       /* can never be true, redundant code */
>                          goto coalesc;
>                  return;
>          }
> }
>
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

Cheers,
-Mukesh
> ---
>   net/ipv4/tcp_output.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index e265d1aeeb66..32061928b054 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -3088,7 +3088,6 @@ void tcp_send_fin(struct sock *sk)
>   		tskb = skb_rb_last(&sk->tcp_rtx_queue);
>   
>   	if (tskb) {
> -coalesce:
>   		TCP_SKB_CB(tskb)->tcp_flags |= TCPHDR_FIN;
>   		TCP_SKB_CB(tskb)->end_seq++;
>   		tp->write_seq++;
> @@ -3104,11 +3103,9 @@ void tcp_send_fin(struct sock *sk)
>   		}
>   	} else {
>   		skb = alloc_skb_fclone(MAX_TCP_HEADER, sk->sk_allocation);
> -		if (unlikely(!skb)) {
> -			if (tskb)
> -				goto coalesce;
> +		if (unlikely(!skb))
>   			return;
> -		}
> +
>   		INIT_LIST_HEAD(&skb->tcp_tsorted_anchor);
>   		skb_reserve(skb, MAX_TCP_HEADER);
>   		sk_forced_mem_schedule(sk, skb->truesize);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
@ 2019-04-05  6:59   ` Mukesh Ojha
  0 siblings, 0 replies; 10+ messages in thread
From: Mukesh Ojha @ 2019-04-05  6:59 UTC (permalink / raw)
  To: Colin King, Eric Dumazet, David S . Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, netdev
  Cc: kernel-janitors, linux-kernel


On 4/4/2019 8:16 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
>
> if (tsbk) {
>          ...
> } else {
>          ...
>          if (unlikely(!skb)) {
>                  if (tskb)       /* can never be true, redundant code */
>                          goto coalesc;
>                  return;
>          }
> }
>
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

Cheers,
-Mukesh
> ---
>   net/ipv4/tcp_output.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index e265d1aeeb66..32061928b054 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -3088,7 +3088,6 @@ void tcp_send_fin(struct sock *sk)
>   		tskb = skb_rb_last(&sk->tcp_rtx_queue);
>   
>   	if (tskb) {
> -coalesce:
>   		TCP_SKB_CB(tskb)->tcp_flags |= TCPHDR_FIN;
>   		TCP_SKB_CB(tskb)->end_seq++;
>   		tp->write_seq++;
> @@ -3104,11 +3103,9 @@ void tcp_send_fin(struct sock *sk)
>   		}
>   	} else {
>   		skb = alloc_skb_fclone(MAX_TCP_HEADER, sk->sk_allocation);
> -		if (unlikely(!skb)) {
> -			if (tskb)
> -				goto coalesce;
> +		if (unlikely(!skb))
>   			return;
> -		}
> +
>   		INIT_LIST_HEAD(&skb->tcp_tsorted_anchor);
>   		skb_reserve(skb, MAX_TCP_HEADER);
>   		sk_forced_mem_schedule(sk, skb->truesize);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
  2019-04-04 14:46 ` Colin King
@ 2019-04-05  7:46   ` Eric Dumazet
  -1 siblings, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2019-04-05  7:46 UTC (permalink / raw)
  To: Colin King
  Cc: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
	kernel-janitors, LKML

On Thu, Apr 4, 2019 at 7:46 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
>...

> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

SGTM, thanks.

Signed-off-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
@ 2019-04-05  7:46   ` Eric Dumazet
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2019-04-05  7:46 UTC (permalink / raw)
  To: Colin King
  Cc: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
	kernel-janitors, LKML

On Thu, Apr 4, 2019 at 7:46 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
>...

> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

SGTM, thanks.

Signed-off-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
  2019-04-04 14:46 ` Colin King
@ 2019-04-07  1:18   ` David Miller
  -1 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2019-04-07  1:18 UTC (permalink / raw)
  To: colin.king
  Cc: edumazet, kuznet, yoshfuji, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Thu,  4 Apr 2019 15:46:03 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
> 
> if (tsbk) {
>         ...
> } else {
>         ...
>         if (unlikely(!skb)) {
>                 if (tskb)       /* can never be true, redundant code */
>                         goto coalesc;
>                 return;
>         }
> }
> 
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to net-next.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] tcp: remove redundant check on tskb
@ 2019-04-07  1:18   ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2019-04-07  1:18 UTC (permalink / raw)
  To: colin.king
  Cc: edumazet, kuznet, yoshfuji, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Thu,  4 Apr 2019 15:46:03 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> The non-null check on tskb is always false because it is in an else
> path of a check on tskb and hence tskb is null in this code block.
> This is check is therefore redundant and can be removed as well
> as the label coalesc.
> 
> if (tsbk) {
>         ...
> } else {
>         ...
>         if (unlikely(!skb)) {
>                 if (tskb)       /* can never be true, redundant code */
>                         goto coalesc;
>                 return;
>         }
> }
> 
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to net-next.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-04-07  1:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04 14:46 [PATCH] tcp: remove redundant check on tskb Colin King
2019-04-04 14:46 ` Colin King
2019-04-04 15:05 ` Dan Carpenter
2019-04-04 15:05   ` Dan Carpenter
2019-04-05  6:47 ` Mukesh Ojha
2019-04-05  6:59   ` Mukesh Ojha
2019-04-05  7:46 ` Eric Dumazet
2019-04-05  7:46   ` Eric Dumazet
2019-04-07  1:18 ` David Miller
2019-04-07  1:18   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.