Skip to contentSkip to conversation

net/netfilter/ipvs/ip_vs_wrr.c: use lib/gcd.c

PATCH Applied [email protected] 2 participants 2 messages Dec 22, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/netfilter/ipvs/ip_vs_wrr.c: use lib/gcd.c

From: Florian Fainelli <[email protected]>

Remove the private version of the greatest common divider to use lib/gcd.c, the latter also implementing the a < b case.

[[email protected]: repair neighboring whitespace because the diff looked odd]
Cc Sergei Shtylyov <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Julius Volz <[email protected]>
Cc David S. Miller <[email protected]>
Cc Patrick McHardy <[email protected]>

---

 net/netfilter/ipvs/Kconfig     |    3 ++-
 net/netfilter/ipvs/ip_vs_wrr.c |   15 +--------------
 2 files changed, 3 insertions(+), 15 deletions(-)
net/netfilter/ipvs/Kconfig renamed from net/netfilter/ipvs/Kconfig~net-netfilter-ipvs-ip_vs_wrrc-use-lib-gcdc +2 -1
diff -puN net/netfilter/ipvs/Kconfig~net-netfilter-ipvs-ip_vs_wrrc-use-lib-gcdc net/netfilter/ipvs/Kconfig
@@ -112,7 +112,8 @@ config	IP_VS_RR
 	  module, choose M here. If unsure, say N.
  
 config	IP_VS_WRR
-        tristate "weighted round-robin scheduling" 
+	tristate "weighted round-robin scheduling"
+	select GCD
 	---help---
 	  The weighted robin-robin scheduling algorithm directs network
 	  connections to different real servers based on server weights
net/netfilter/ipvs/ip_vs_wrr.c renamed from net/netfilter/ipvs/ip_vs_wrr.c~net-netfilter-ipvs-ip_vs_wrrc-use-lib-gcdc +1 -14
diff -puN net/netfilter/ipvs/ip_vs_wrr.c~net-netfilter-ipvs-ip_vs_wrrc-use-lib-gcdc net/netfilter/ipvs/ip_vs_wrr.c
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/net.h>
+#include <linux/gcd.h>
 
 #include <net/ip_vs.h>
 
@@ -38,20 +39,6 @@ struct ip_vs_wrr_mark {
 };
 
 
-/*
- *    Get the gcd of server weights
- */
-static int gcd(int a, int b)
-{
-	int c;
-
-	while ((c = a % b)) {
-		a = b;
-		b = c;
-	}
-	return b;
-}
-
 static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc)
 {
 	struct ip_vs_dest *dest;

_