[libmath-prime-util-perl] 03/08: Squash some compiler warnings

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:47:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.22
in repository libmath-prime-util-perl.

commit b7bf6f65e667fa7b57bcdddd31364f9ee9191aa3
Author: Dana Jacobsen <dana at acm.org>
Date:   Mon Feb 25 15:04:31 2013 -0800

    Squash some compiler warnings
---
 XS.xs    |  7 ++++---
 aks.c    |  9 ++++-----
 factor.c |  4 ++--
 util.c   | 12 +++++++-----
 4 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/XS.xs b/XS.xs
index a712910..8c53bb2 100644
--- a/XS.xs
+++ b/XS.xs
@@ -360,7 +360,7 @@ _XS_totient(IN UV lo, IN UV hi = 0)
 
       if (hi < lo) XSRETURN_EMPTY;
       if (lo < 2) {
-        if (lo <= 0 && hi >= 0) XPUSHs(sv_2mortal(newSVuv(0)));
+        if (lo <= 0           ) XPUSHs(sv_2mortal(newSVuv(0)));
         if (lo <= 1 && hi >= 1) XPUSHs(sv_2mortal(newSVuv(1)));
         lo = 2;
       }
@@ -404,8 +404,9 @@ _XS_totient(IN UV lo, IN UV hi = 0)
 
 void
 _XS_moebius(IN UV lo, IN UV hi = 0)
-  PPCODE:
+  PREINIT:
     UV i;
+  PPCODE:
     if (hi != lo && hi != 0) {   /* mobius in a range */
       IV* mu = _moebius_range(lo, hi);
       MPUassert( mu != 0, "_moebius_range returned 0" );
@@ -415,7 +416,7 @@ _XS_moebius(IN UV lo, IN UV hi = 0)
       Safefree(mu);
     } else {
       UV factors[MPU_MAX_FACTORS+1];
-      UV i, nfactors, lastf;
+      UV nfactors, lastf;
       UV n = lo;
 
       if (n <= 1)
diff --git a/aks.c b/aks.c
index 3097ecb..4e534ce 100644
--- a/aks.c
+++ b/aks.c
@@ -25,6 +25,7 @@
 #define SQRTN_SHORTCUT 1
 
 #include "ptypes.h"
+#include "aks.h"
 #include "util.h"
 #include "sieve.h"
 #include "factor.h"
@@ -109,8 +110,7 @@ static void poly_print(UV* poly, UV r)
 
 static void poly_mod_mul(UV* px, UV* py, UV* res, UV r, UV mod)
 {
-  int i, j;
-  UV pxi, pyj, rindex;
+  UV i, j, pxi, pyj, rindex;
 
   memset(res, 0, r * sizeof(UV));
   for (i = 0; i < r; i++) {
@@ -131,8 +131,7 @@ static void poly_mod_mul(UV* px, UV* py, UV* res, UV r, UV mod)
 }
 static void poly_mod_sqr(UV* px, UV* res, UV r, UV mod)
 {
-  int d, s;
-  UV sum, rindex;
+  UV d, s, sum, rindex;
   UV degree = r-1;
 
   memset(res, 0, r * sizeof(UV)); /* zero out sums */
@@ -177,7 +176,7 @@ static int test_anr(UV a, UV n, UV r)
 {
   UV* pn;
   UV* res;
-  int i;
+  UV i;
   int retval = 1;
 
   Newz(0, pn, r, UV);
diff --git a/factor.c b/factor.c
index d4dddaa..d2da1d9 100644
--- a/factor.c
+++ b/factor.c
@@ -959,8 +959,8 @@ int racing_squfof_factor(UV n, UV *factors, UV rounds)
     3*11,     3,     5*11,   5,   7*11,   7,   11,     1   };
   const UV big2 = UV_MAX >> 2;
   mult_t mult_save[NSQUFOF_MULT];
-  int i, still_racing;
-  UV nn64, mult, f64;
+  int still_racing;
+  UV i, nn64, mult, f64;
   UV rounds_done = 0;
 
   /* Caller should have handled these trivial cases */
diff --git a/util.c b/util.c
index 37ed751..b6aa33e 100644
--- a/util.c
+++ b/util.c
@@ -667,8 +667,10 @@ IV* _moebius_range(UV lo, UV hi)
   }
   for (i = lo; i <= hi; i++) {
     IV m = mu[i-lo];
-    if (m != i && m != -i)  m *= -1;
-    mu[i-lo] = (m>0) - (m<0);
+    if (m != 0) {
+      if (m != i && -m != i)  m *= -1;
+      mu[i-lo] = (m>0) - (m<0);
+    }
   }
   return mu;
 }
@@ -909,14 +911,13 @@ static const long double riemann_zeta_table[] = {
 long double ld_riemann_zeta(long double x) {
   long double const tol = 1e-17;
   long double term;
-  int k;
   KAHAN_INIT(sum);
 
   if (x < 0.5) croak("Invalid input to RiemannZeta:  x must be >= 0.5");
 
   if (x == (unsigned int)x) {
-    k = x - 2;
-    if ((k >= 0) && (k < NPRECALC_ZETA))
+    int k = x - 2;
+    if ((k >= 0) && (k < (int)NPRECALC_ZETA))
       return riemann_zeta_table[k];
   }
 
@@ -964,6 +965,7 @@ long double ld_riemann_zeta(long double x) {
      * values using double precision, it's awful.
      * Back to the defining equation.
      */
+    int k;
     for (k = 5; k <= 1000000; k++) {
       term = powl(k, -x);
       KAHAN_SUM(sum, term);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list