| To: | Joe Perches <joe@perches.com> |
|---|---|
| Subject: | Re: [PATCH 1/8] add lib/gcd.c |
| From: | Andrew Morton <akpm@linux-foundation.org> |
| Date: | Thu, 4 Jun 2009 12:03:40 -0700 |
| Cc: | Florian Fainelli <florian@openwrt.org>, Sergei Shtylyov <sshtylyov@ru.mvista.com>, David Miller <davem@davemloft.net>, netdev@vger.kernel.org, Linux-MIPS <linux-mips@linux-mips.org>, linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.de>, Ralf Baechle <ralf@linux-mips.org> |
| In-reply-to: | <1244131044.3631.14.camel@Joe-Laptop.home> |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| References: | <200906041615.10467.florian@openwrt.org> <4A27DAAD.5000303@ru.mvista.com> <200906041639.04868.florian@openwrt.org> <1244131044.3631.14.camel@Joe-Laptop.home> |
| Sender: | linux-mips-bounce@linux-mips.org |
On Thu, 04 Jun 2009 08:57:24 -0700 Joe Perches <joe@perches.com> wrote:
> On Thu, 2009-06-04 at 16:39 +0200, Florian Fainelli wrote:
> > diff --git a/lib/gcd.c b/lib/gcd.c
> > new file mode 100644
> > index 0000000..6634741
> > --- /dev/null
> > +++ b/lib/gcd.c
> > @@ -0,0 +1,20 @@
> > +#include <linux/gcd.h>
> > +#include <linux/module.h>
> > +
> > +/* Greatest common divisor */
> > +unsigned long gcd(unsigned long a, unsigned long b)
> > +{
> > + unsigned long r;
> > +
> > + if (a < b) {
> > + r = a;
> > + a = b;
> > + b = r;
> swap(a, b)
yup
> > + }
> > + while ((r = a % b) != 0) {
> > + a = b;
> > + b = r;
> > + }
> > + return b;
> > +}
> > +EXPORT_SYMBOL_GPL(gcd);
>
> Shouldn't a generic gcd protect against a div0
> if gcd(0,0)?
nope. It's a caller bug, there's nothing the callee can do to fix it,
so an oops is a fine response.
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [loongson-PATCH-v3 18/25] Add Siliconmotion 712 framebuffer driver, Simon Braunschmidt |
|---|---|
| Next by Date: | Re: [PATCH 4/6] headers_check fix: mips, ioctl.h, Sam Ravnborg |
| Previous by Thread: | Re: [PATCH 1/8] add lib/gcd.c, Joe Perches |
| Next by Thread: | Re: [PATCH 1/8] add lib/gcd.c, Andrew Morton |
| Indexes: | [Date] [Thread] [Top] [All Lists] |