Skip to contentSkip to conversation

Remove some unnecessary checks on socket restart

PATCH In review Dan Smith 2 participants 3 messages Oct 1, 2009 2 messages not in the archive Networking

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 Remove some unnecessary checks on socket restart

These two checks are removed because they cannot be true because of the unsigned nature of the values being examined

---
 net/checkpoint.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
net/checkpoint.c +2 -4
index a11ec7a..017c7f8 100644
@@ -480,12 +480,10 @@ static int sock_cptrst(struct ckpt_ctx *ctx, struct sock *sk,
 		ckpt_debug("socket/sock in inconsistent state: %i/%i",
 			   h->socket.state, h->sock.state);
 		return -EINVAL;
-	} else if ((h->sock.state < TCP_ESTABLISHED) ||
-		   (h->sock.state >= TCP_MAX_STATES)) {
+	} else if (h->sock.state >= TCP_MAX_STATES) {
 		ckpt_debug("sock in invalid state: %i", h->sock.state);
 		return -EINVAL;
-	} else if ((h->socket.state < SS_FREE) ||
-		   (h->socket.state > SS_DISCONNECTING)) {
+	} else if (h->socket.state > SS_DISCONNECTING) {
 		ckpt_debug("socket in invalid state: %i",
 			   h->socket.state);
 		return -EINVAL;
Signature · 1 line
1.6.0.4

A message that is not in the archive (sent off-list or not yet received): 1254433228-20882-1-git-send-email-danms-r/[email protected]

#2 lore raw
Quoted 15 lines · Dan Smith

These two checks are removed because they cannot be true because of the unsigned nature of the values being examined

---
 net/checkpoint.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
net/checkpoint.c +0 -0
index a11ec7a..017c7f8 100644

net/checkpoint.c static int sock_cptrst(struct ckpt_ctx *ctx, struct sock *sk, · line 483

Quoted 6 lines
net/checkpoint.c +1 -2
@@ -480,12 +480,10 @@ static int sock_cptrst(struct ckpt_ctx *ctx, struct sock *sk,
 		ckpt_debug("socket/sock in inconsistent state: %i/%i",
 			   h->socket.state, h->sock.state);
 		return -EINVAL;
-	} else if ((h->sock.state < TCP_ESTABLISHED) ||
-		   (h->sock.state >= TCP_MAX_STATES)) {
+	} else if (h->sock.state >= TCP_MAX_STATES) {

No, TCP_ESTABLISHED is defined to 1 isn't it?

net/checkpoint.c static int sock_cptrst(struct ckpt_ctx *ctx, struct sock *sk, · line 486

Quoted 5 lines
net/checkpoint.c +1 -2
 		ckpt_debug("sock in invalid state: %i", h->sock.state);
 		return -EINVAL;
-	} else if ((h->socket.state < SS_FREE) ||
-		   (h->socket.state > SS_DISCONNECTING)) {
+	} else if (h->socket.state > SS_DISCONNECTING) {

Yes, thanks.

Quoted 5 lines
net/checkpoint.c +0 -0
 		ckpt_debug("socket in invalid state: %i",
 			   h->socket.state);
 		return -EINVAL;
Signature · 1 line
1.6.0.4

A message that is not in the archive (sent off-list or not yet received): 20091001214749.GA4343-r/[email protected]

author
#4 lore raw

SH> No, TCP_ESTABLISHED is defined to 1 isn't it?

Argh. Yes, it is, even though it's the first one in the enum. How annoying.

Signature · 3 lines
Dan Smith
IBM Linux Technology Center
email: danms-r/[email protected]