]> git.hungrycats.org Git - linux/commitdiff
[IPVS]: Simplify ip_vs_wrr_gcd_weight
authorJulian Anastasov <ja@ssi.bg>
Mon, 29 Sep 2003 18:55:23 +0000 (11:55 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Mon, 29 Sep 2003 18:55:23 +0000 (11:55 -0700)
net/ipv4/ipvs/ip_vs_wrr.c

index 7ec189990b6d444f354527ba9a9668682db4a879..fa8b1c2dca25b13c7575c8701a2f93bdb6919fbe 100644 (file)
@@ -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;
 }