From 2d30c35b7d37676933def5de95c7bcc68b8846ca Mon Sep 17 00:00:00 2001
From: Julian Anastasov <ja@ssi.bg>
Date: Mon, 29 Sep 2003 11:55:23 -0700
Subject: [PATCH] [IPVS]: Simplify ip_vs_wrr_gcd_weight

---
 net/ipv4/ipvs/ip_vs_wrr.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/net/ipv4/ipvs/ip_vs_wrr.c b/net/ipv4/ipvs/ip_vs_wrr.c
index 7ec189990b6d..fa8b1c2dca25 100644
--- a/net/ipv4/ipvs/ip_vs_wrr.c
+++ b/net/ipv4/ipvs/ip_vs_wrr.c
@@ -58,26 +58,18 @@ static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc)
 {
 	struct ip_vs_dest *dest;
 	int weight;
-	int g = 1;
+	int g = 0;
 
 	list_for_each_entry(dest, &svc->destinations, n_list) {
 		weight = atomic_read(&dest->weight);
 		if (weight > 0) {
-			g = weight;
-			goto search_gcd;
+			if (g > 0)
+				g = gcd(weight, g);
+			else
+				g = weight;
 		}
 	}
-
-	return g;
-
- search_gcd:
-	list_for_each_entry(dest, &svc->destinations, n_list) {
-		weight = atomic_read(&dest->weight);
-		if (weight > 0)
-			g = gcd(weight, g);
-	}
-
-	return g;
+	return g ? g : 1;
 }
 
 
-- 
2.30.9