Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754451AbZFDTGB (ORCPT ); Thu, 4 Jun 2009 15:06:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752295AbZFDTFt (ORCPT ); Thu, 4 Jun 2009 15:05:49 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:53217 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752547AbZFDTFs (ORCPT ); Thu, 4 Jun 2009 15:05:48 -0400 Date: Thu, 4 Jun 2009 12:03:40 -0700 From: Andrew Morton To: Joe Perches Cc: Florian Fainelli , Sergei Shtylyov , David Miller , netdev@vger.kernel.org, Linux-MIPS , linux-kernel@vger.kernel.org, Takashi Iwai , Ralf Baechle Subject: Re: [PATCH 1/8] add lib/gcd.c Message-Id: <20090604120340.079f6cdf.akpm@linux-foundation.org> In-Reply-To: <1244131044.3631.14.camel@Joe-Laptop.home> References: <200906041615.10467.florian@openwrt.org> <4A27DAAD.5000303@ru.mvista.com> <200906041639.04868.florian@openwrt.org> <1244131044.3631.14.camel@Joe-Laptop.home> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1103 Lines: 45 On Thu, 04 Jun 2009 08:57:24 -0700 Joe Perches 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 > > +#include > > + > > +/* 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/