lib/lcm.c: ensure correct result whenever it fits
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Wed, 10 Dec 2014 23:51:27 +0000 (15:51 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Dec 2014 01:41:11 +0000 (17:41 -0800)
commit74a5fef7cb0839c6b595f90c7914a62ac9d0bcf9
tree82e34b9120005a8a764d25f9c91b17ada4445b05
parent7b212edf86e28f4d0198f2152b2f0553f51a59a5
lib/lcm.c: ensure correct result whenever it fits

Ensure that lcm(a,b) returns the mathematically correct result, provided
it fits in an unsigned long.  The current version returns garbage if a*b
overflows, even if the final result would fit.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/lcm.c