Subject: bug#12350: Composites identified as primes in factor.c (when HAVE_GMP)

From: Jim Meyering <[email-masked]>
Date: Sun, 16 Sep 2012 22:43:35 +0200

Jim Meyering wrote:
...
> Here are some more suggested changes.
> Sorry about the terse commit logs.
> The changes are mostly stylistic.
>
> changeset:   121:80954440c618

Hi Torbjorn,

I've begun inserting your factor.c into coreutils.
That enables a lot more warnings, and I've made a few
changes, beginning to accommodate them.  Unfortunately,
I've also converted TABs to spaces, so I'll let you
compute your own diffs (presumably with -b).  Included below:

Would you mind changing the names of a few variables
or adjusting declarations to avoid some -Wshadow warnings?

I changed the innermost "r" to "rem" locally, but there are
others.  Also, "S".

  make  all-recursive
  make[1]: Entering directory `/h/j/w/co/cu'
  Making all in po
  make[2]: Entering directory `/h/j/w/co/cu/po'
  make[2]: Leaving directory `/h/j/w/co/cu/po'
  Making all in .
  make[2]: Entering directory `/h/j/w/co/cu'
    CC       src/factor.o
  src/factor.c: In function 'factor_using_squfof':
  src/factor.c:1896:17: error: declaration of 'S' shadows a previous local [-Werror=shadow]
         uintmax_t S, Dh, Dl, Q1, Q, P, L, L1, B;
                   ^
  src/factor.c:1860:13: error: shadowed declaration is here [-Werror=shadow]
     uintmax_t S;
               ^
  src/factor.c:1987:25: error: declaration of 'r' shadows a previous local [-Werror=shadow]
                 uintmax_t r = is_square (Q);
                           ^
  src/factor.c:1945:31: error: shadowed declaration is here [-Werror=shadow]
             uintmax_t q, P1, t, r;
                                 ^
  src/factor.c:2037:33: error: declaration of 'r' shadows a previous local [-Werror=shadow]
                         uintmax_t r;
                                   ^
  src/factor.c:1987:25: error: shadowed declaration is here [-Werror=shadow]
                 uintmax_t r = is_square (Q);
                           ^
  src/factor.c: At top level:
  src/factor.c:2291:1: error: no previous prototype for 'read_item' [-Werror=missing-prototypes]
   read_item (struct inbuf *bufstruct)
   ^
  cc1: all warnings being treated as errors
  make[2]: *** [src/factor.o] Error 1
  make[2]: Leaving directory `/h/j/w/co/cu'
  make[1]: *** [all-recursive] Error 1
  make[1]: Leaving directory `/h/j/w/co/cu'
  make: *** [all] Error 2