Skip to contentSkip to conversation

suspicious indentation in do_tcp_setsockopt

RFC In review Dave Jones 6 participants 8 messages Sep 5, 2013

Subsystems (3)
lore
Share & tools
lore

Dave Jones

author
#0 lore raw

RFC 1/1 suspicious indentation in do_tcp_setsockopt

What's the intent here ?

This ?

net/ipv4/tcp.c +2 -1
index b2f6c74..95544e4 100644
@@ -2454,10 +2454,11 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 	case TCP_THIN_DUPACK:
 		if (val < 0 || val > 1)
 			err = -EINVAL;
-		else
+		else {
 			tp->thin_dupack = val;
 			if (tp->thin_dupack)
 				tcp_disable_early_retrans(tp);
+		}
 		break;
 
 	case TCP_REPAIR:

Or this ...

net/ipv4/tcp.c +3 -2
index b2f6c74..187c5a4 100644
@@ -2456,8 +2456,9 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 			err = -EINVAL;
 		else
 			tp->thin_dupack = val;
-			if (tp->thin_dupack)
-				tcp_disable_early_retrans(tp);
+
+		if (tp->thin_dupack)
+			tcp_disable_early_retrans(tp);
 		break;
 
 	case TCP_REPAIR:

I'll submit the right patch in the right form once I know what was intended.

The former seems more 'correct' to me, but I'm unsure if that could break something.

Dave

maintainer
#1 lore raw

From: Dave Jones <[email protected]>
Date: Thu, 5 Sep 2013 00:20:45 -0400

Quoted 1 line

What's the intent here ?

This stuff is great, do you have a script that looks for this false indentation pattern?

author
#2 lore raw
Quoted 7 lines · David Miller

From: Dave Jones <[email protected]>
Date: Thu, 5 Sep 2013 00:20:45 -0400

Quoted 1 line

What's the intent here ?

This stuff is great, do you have a script that looks for this false indentation pattern?

Coverity. I'm doing daily builds with it now, in the hope of trying to catch things faster, but there's a *ton* of old stuff in there like this that needs sorting through, because it seems to have strange of notions of what a 'new' bug is.

Dave

#3 lore raw
Quoted 10 lines · Dave Jones
Quoted 7 lines · David Miller

From: Dave Jones <[email protected]>
Date: Thu, 5 Sep 2013 00:20:45 -0400

Quoted 1 line

What's the intent here ?

This stuff is great, do you have a script that looks for this false indentation pattern?

Coverity.

Good stuff.

Quoted 4 lines

I'm doing daily builds with it now, in the hope of trying to catch things faster, but there's a *ton* of old stuff in there like this that needs sorting through, because it seems to have strange of notions of what a 'new' bug is.

I think scripts/coccinelle/misc/ifcol.cocci
does something similar.

#4 lore raw
In reply to Dave Jones
Quoted 6 lines · Dave Jones
Quoted 5 lines · David Miller

From: Dave Jones <[email protected]>
Date: Thu, 5 Sep 2013 00:20:45 -0400

Quoted 1 line

What's the intent here ?

Quoted 7 lines
Quoted 2 lines

This stuff is great, do you have a script that looks for this false indentation pattern?

Coverity. I'm doing daily builds with it now, in the hope of trying to catch things faster, but there's a *ton* of old stuff in there like this that needs sorting through, because it seems to have strange of notions of what a 'new' bug is.

Right, it seems 'new' is just newly *detected*, not necessarily newly introduced in recent code.

Quoted 1 line

Dave

#5 lore raw
In reply to Dave Jones

(Adding Yuchung Cheng and Neal Cardwell as the
author and acker of the patch)

Quoted 3 lines · Dave Jones

What's the intent here ?

This ?

I think the first is most likely.

Quoted 50 lines
net/ipv4/tcp.c +2 -1
index b2f6c74..95544e4 100644
@@ -2454,10 +2454,11 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 	case TCP_THIN_DUPACK:
 		if (val < 0 || val > 1)
 			err = -EINVAL;
-		else
+		else {
 			tp->thin_dupack = val;
 			if (tp->thin_dupack)
 				tcp_disable_early_retrans(tp);
+		}
 		break;
 
 	case TCP_REPAIR:

Or this ...

net/ipv4/tcp.c +3 -2
index b2f6c74..187c5a4 100644
@@ -2456,8 +2456,9 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
 			err = -EINVAL;
 		else
 			tp->thin_dupack = val;
-			if (tp->thin_dupack)
-				tcp_disable_early_retrans(tp);
+
+		if (tp->thin_dupack)
+			tcp_disable_early_retrans(tp);
 		break;
 
 	case TCP_REPAIR:

I'll submit the right patch in the right form once I know what was intended.

The former seems more 'correct' to me, but I'm unsure if that could break something.

Dave

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw
Quoted 9 lines · Joe Perches

(Adding Yuchung Cheng and Neal Cardwell as the
author and acker of the patch)

Quoted 3 lines · Dave Jones

What's the intent here ?

This ?

I think the first is most likely.

Yes, exactly. The first version makes more sense. We only need to check thin_dupack and potentially disable early retransmit if the setsockopt successfully changes thin_dupack.

neal

Quoted 53 lines
Quoted 50 lines
net/ipv4/tcp.c +2 -1
index b2f6c74..95544e4 100644
@@ -2454,10 +2454,11 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
      case TCP_THIN_DUPACK:
              if (val < 0 || val > 1)
                      err = -EINVAL;
-             else
+             else {
                      tp->thin_dupack = val;
                      if (tp->thin_dupack)
                              tcp_disable_early_retrans(tp);
+             }
              break;
 
      case TCP_REPAIR:

Or this ...

net/ipv4/tcp.c +3 -2
index b2f6c74..187c5a4 100644
@@ -2456,8 +2456,9 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
                      err = -EINVAL;
              else
                      tp->thin_dupack = val;
-                     if (tp->thin_dupack)
-                             tcp_disable_early_retrans(tp);
+
+             if (tp->thin_dupack)
+                     tcp_disable_early_retrans(tp);
              break;
 
      case TCP_REPAIR:

I'll submit the right patch in the right form once I know what was intended.

The former seems more 'correct' to me, but I'm unsure if that could break something.

Dave

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 7 lines · Neal Cardwell
Quoted 6 lines · Joe Perches

(Adding Yuchung Cheng and Neal Cardwell as the
author and acker of the patch)

Quoted 2 lines · Dave Jones

What's the intent here ?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

This ?

I think the first is most likely.

Yes, exactly. The first version makes more sense. We only need to check thin_dupack and potentially disable early retransmit if the setsockopt successfully changes thin_dupack.

ack. first version is the intended one. thanks.

Quoted 57 lines

neal

Quoted 53 lines
Quoted 50 lines
net/ipv4/tcp.c +2 -1
index b2f6c74..95544e4 100644
@@ -2454,10 +2454,11 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
      case TCP_THIN_DUPACK:
              if (val < 0 || val > 1)
                      err = -EINVAL;
-             else
+             else {
                      tp->thin_dupack = val;
                      if (tp->thin_dupack)
                              tcp_disable_early_retrans(tp);
+             }
              break;
 
      case TCP_REPAIR:

Or this ...

net/ipv4/tcp.c +3 -2
index b2f6c74..187c5a4 100644
@@ -2456,8 +2456,9 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
                      err = -EINVAL;
              else
                      tp->thin_dupack = val;
-                     if (tp->thin_dupack)
-                             tcp_disable_early_retrans(tp);
+
+             if (tp->thin_dupack)
+                     tcp_disable_early_retrans(tp);
              break;
 
      case TCP_REPAIR:

I'll submit the right patch in the right form once I know what was intended.

The former seems more 'correct' to me, but I'm unsure if that could break something.

Dave

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html