Module Name:    src
Committed By:   jakllsch
Date:           Tue Aug 30 02:58:04 UTC 2011

Modified Files:
        src/games/primes: primes.c

Log Message:
No need to cast double to ubig (aka uintmax_t) through int.

This change prevents a modulo by zero in a invocation such as:
primes 18446744073709551000 18446744073709551615
on a LP64 machine.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/games/primes/primes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/primes/primes.c
diff -u src/games/primes/primes.c:1.18 src/games/primes/primes.c:1.19
--- src/games/primes/primes.c:1.18	Thu May 13 17:52:12 2010
+++ src/games/primes/primes.c	Tue Aug 30 02:58:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: primes.c,v 1.18 2010/05/13 17:52:12 tnozaki Exp $	*/
+/*	$NetBSD: primes.c,v 1.19 2011/08/30 02:58:04 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)primes.c	8.5 (Berkeley) 5/10/95";
 #else
-__RCSID("$NetBSD: primes.c,v 1.18 2010/05/13 17:52:12 tnozaki Exp $");
+__RCSID("$NetBSD: primes.c,v 1.19 2011/08/30 02:58:04 jakllsch Exp $");
 #endif
 #endif /* not lint */
 
@@ -305,11 +305,10 @@
 		/* note highest useful factor and sieve spot */
 		if (stop-start > TABSIZE+TABSIZE) {
 			tab_lim = &table[TABSIZE]; /* sieve it all */
-			fact_lim = (int)sqrt(
-					(double)(start)+TABSIZE+TABSIZE+1.0);
+			fact_lim = sqrt((double)(start)+TABSIZE+TABSIZE+1.0);
 		} else {
 			tab_lim = &table[(stop-start)/2]; /* partial sieve */
-			fact_lim = (int)sqrt((double)(stop)+1.0);
+			fact_lim = sqrt((double)(stop)+1.0);
 		}
 		/* sieve for factors >= 17 */
 		factor = 17;	/* 17 is first prime to use */

Reply via email to