netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [IPVS] replace if .. goto with while
@ 2006-12-18  3:11 Horms
  2007-01-02  8:38 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Horms @ 2006-12-18  3:11 UTC (permalink / raw)
  To: netdev
  Cc: David Miller, Wensong Zhan, Julian Anastasov, Roberto Nibali,
	Joseph Mack NA3T

I guess that this code used to be more complex, but replacing
the goto with a while seems to make things a bit more readable.
Or in other words, two fairly gratuitous goto are removed.

On a related note, I wonder if there should be a limit to how
many times it tries.

Signed-Off-By: Simon Horman <horms@verge.net.au>

Index: linux-2.6/net/ipv4/ipvs/ip_vs_sync.c
===================================================================
--- linux-2.6.orig/net/ipv4/ipvs/ip_vs_sync.c	2006-11-29 09:50:37.000000000 +0900
+++ linux-2.6/net/ipv4/ipvs/ip_vs_sync.c	2006-11-29 10:03:11.000000000 +0900
@@ -822,12 +822,10 @@
 
 	/* fork the sync thread here, then the parent process of the
 	   sync thread is the init process after this thread exits. */
-  repeat:
-	if ((pid = kernel_thread(sync_thread, startup, 0)) < 0) {
+	while ((pid = kernel_thread(sync_thread, startup, 0)) < 0) {
 		IP_VS_ERR("could not create sync_thread due to %d... "
 			  "retrying.\n", pid);
 		msleep_interruptible(1000);
-		goto repeat;
 	}
 
 	return 0;
@@ -856,12 +854,10 @@
 		ip_vs_backup_syncid = syncid;
 	}
 
-  repeat:
-	if ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0) {
+	while ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0) {
 		IP_VS_ERR("could not create fork_sync_thread due to %d... "
 			  "retrying.\n", pid);
 		msleep_interruptible(1000);
-		goto repeat;
 	}
 
 	wait_for_completion(&startup);

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

* Re: [PATCH] [IPVS] replace if .. goto with while
  2006-12-18  3:11 [PATCH] [IPVS] replace if .. goto with while Horms
@ 2007-01-02  8:38 ` David Miller
  2007-01-03 13:37   ` Horms
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2007-01-02  8:38 UTC (permalink / raw)
  To: horms; +Cc: netdev, wensong, ja, ratz, jmack

From: Horms <horms@verge.net.au>
Date: Mon, 18 Dec 2006 12:11:11 +0900

> I guess that this code used to be more complex, but replacing
> the goto with a while seems to make things a bit more readable.
> Or in other words, two fairly gratuitous goto are removed.
> 
> On a related note, I wonder if there should be a limit to how
> many times it tries.
> 
> Signed-Off-By: Simon Horman <horms@verge.net.au>

Yes, there should be, something like a limit of one. :-)

There is no reason to loop on something like this, just
return a failure immediately if creating the kernel thread
fails.

As a side note, if it's easy you might want to convert this
over the the include/linux/kthread.h interfaces.  I just did
this for pktgen tonight and it cleaned a lot of stuff up.

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

* Re: [PATCH] [IPVS] replace if .. goto with while
  2007-01-02  8:38 ` David Miller
@ 2007-01-03 13:37   ` Horms
  0 siblings, 0 replies; 3+ messages in thread
From: Horms @ 2007-01-03 13:37 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, wensong, ja, ratz, jmack

On Tue, Jan 02, 2007 at 12:38:39AM -0800, David Miller wrote:
> From: Horms <horms@verge.net.au>
> Date: Mon, 18 Dec 2006 12:11:11 +0900
> 
> > I guess that this code used to be more complex, but replacing
> > the goto with a while seems to make things a bit more readable.
> > Or in other words, two fairly gratuitous goto are removed.
> > 
> > On a related note, I wonder if there should be a limit to how
> > many times it tries.
> > 
> > Signed-Off-By: Simon Horman <horms@verge.net.au>
> 
> Yes, there should be, something like a limit of one. :-)
> 
> There is no reason to loop on something like this, just
> return a failure immediately if creating the kernel thread
> fails.

Will do.

> As a side note, if it's easy you might want to convert this
> over the the include/linux/kthread.h interfaces.  I just did
> this for pktgen tonight and it cleaned a lot of stuff up.

Thanks, I will look into it.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


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

end of thread, other threads:[~2007-01-03 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-18  3:11 [PATCH] [IPVS] replace if .. goto with while Horms
2007-01-02  8:38 ` David Miller
2007-01-03 13:37   ` Horms

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).