[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/3] build: avoid compile warnings in factor.c on some system
|
From: |
Jim Meyering |
|
Subject: |
Re: [PATCH 2/3] build: avoid compile warnings in factor.c on some systems |
|
Date: |
Tue, 23 Oct 2012 14:13:57 +0200 |
PƔdraig Brady wrote:
> * src/factor.c (factor_using_pollard_rho2): On some systems
> (like sparc) we need to promote all addmod2() parameters
> to uintmax_t to avoid warnings.
> ---
> src/factor.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/factor.c b/src/factor.c
> index 73c59e9..539a686 100644
> --- a/src/factor.c
> +++ b/src/factor.c
> @@ -1532,7 +1532,7 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t n0,
> unsigned long int a,
> {
> x0 = mulredc2 (&r1m, x1, x0, x1, x0, n1, n0, ni);
> x1 = r1m;
> - addmod2 (x1, x0, x1, x0, 0, a, n1, n0);
> + addmod2 (x1, x0, x1, x0, 0, (uintmax_t) a, n1, n0);
>
> submod2 (t1, t0, z1, z0, x1, x0, n1, n0);
> P0 = mulredc2 (&r1m, P1, P0, t1, t0, n1, n0, ni);
> @@ -1555,7 +1555,7 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t n0,
> unsigned long int a,
> {
> x0 = mulredc2 (&r1m, x1, x0, x1, x0, n1, n0, ni);
> x1 = r1m;
> - addmod2 (x1, x0, x1, x0, 0, a, n1, n0);
> + addmod2 (x1, x0, x1, x0, 0, (uintmax_t) a, n1, n0);
> }
> y1 = x1; y0 = x0;
> }
> @@ -1565,7 +1565,7 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t n0,
> unsigned long int a,
> {
> y0 = mulredc2 (&r1m, y1, y0, y1, y0, n1, n0, ni);
> y1 = r1m;
> - addmod2 (y1, y0, y1, y0, 0, a, n1, n0);
> + addmod2 (y1, y0, y1, y0, 0, (uintmax_t) a, n1, n0);
>
> submod2 (t1, t0, z1, z0, y1, y0, n1, n0);
> g0 = gcd2_odd (&g1, t1, t0, n1, n0);
Thanks.
I confirmed that this addresses the problem.
Did you consider other ways of addressing it,
say without adding that cast? Imagine that
someone adds another addmod2 use in this code...
They will have to know to widen any argument that may
be narrower than uintmax_t.
- Re: more compile warnings with new factor, (continued)
- Re: more compile warnings with new factor, Jim Meyering, 2012/10/23
- Re: more compile warnings with new factor, PƔdraig Brady, 2012/10/23
- Re: more compile warnings with new factor, Jim Meyering, 2012/10/23
- Re: more compile warnings with new factor, PƔdraig Brady, 2012/10/23
- [PATCH 1/3] build: avoid build failure on some sparc systems, PƔdraig Brady, 2012/10/23
- Re: [PATCH 1/3] build: avoid build failure on some sparc systems, Jim Meyering, 2012/10/23
- [PATCH 2/3] build: avoid compile warnings in factor.c on some systems, PƔdraig Brady, 2012/10/23
- Re: [PATCH 2/3] build: avoid compile warnings in factor.c on some systems,
Jim Meyering <=
- Re: [PATCH 2/3] build: avoid compile warnings in factor.c on some systems, PƔdraig Brady, 2012/10/23
- Re: [PATCH 2/3] build: avoid compile warnings in factor.c on some systems, Jim Meyering, 2012/10/23
- [PATCH 3/3] build: avoid warnings about unused variables and macros, PƔdraig Brady, 2012/10/23
- Re: [PATCH 3/3] build: avoid warnings about unused variables and macros, Jim Meyering, 2012/10/23