+ lib-lcmc-ensure-correct-result-whenever-it-fits.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: lib/lcm.c: ensure correct result whenever it fits
has been added to the -mm tree.  Its filename is
     lib-lcmc-ensure-correct-result-whenever-it-fits.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/lib-lcmc-ensure-correct-result-whenever-it-fits.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/lib-lcmc-ensure-correct-result-whenever-it-fits.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
Subject: 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@xxxxxxxxxxxxxxxxxx>
Cc: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 lib/lcm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN lib/lcm.c~lib-lcmc-ensure-correct-result-whenever-it-fits lib/lcm.c
--- a/lib/lcm.c~lib-lcmc-ensure-correct-result-whenever-it-fits
+++ a/lib/lcm.c
@@ -7,7 +7,7 @@
 unsigned long lcm(unsigned long a, unsigned long b)
 {
 	if (a && b)
-		return (a * b) / gcd(a, b);
+		return (a / gcd(a, b)) * b;
 	else if (b)
 		return b;
 
_

Patches currently in -mm which might be from linux@xxxxxxxxxxxxxxxxxx are

lib-lcmc-ensure-correct-result-whenever-it-fits.patch
lib-lcmc-lcmn0=lcm0n-is-0-not-n.patch
linux-next.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux