Clearer GCD function in icmpmonitor.c.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 21 Sep 2019 07:41:38 +0000 (00:41 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Sat, 21 Sep 2019 07:41:38 +0000 (00:41 -0700)
icmpmonitor.c

index 42b1b3a..f0fbc09 100644 (file)
@@ -591,12 +591,7 @@ static void log(int type, char *format, ...)
 
 static int gcd(int x, int y)
 {
-    while(x!=y)
-    {
-        if(x<y)
-            y-=x;
-        else 
-            x-=y;
-    }
-    return x;
+    int remainder = x % y;
+    if (remainder == 0) return y;
+    return gcd(y, remainder);
 }