Fix warnings generated by gcc 4.6.0 about variables set but not
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 4 May 2011 18:22:14 +0000 (18:22 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 4 May 2011 18:22:14 +0000 (18:22 +0000)
thereafter read. Most of these changes are just removal of pointless
stuff or trivial reorganisations; one change is actually substantive,
and fixes a bug in Keen's clue selection (the variable 'bad' was
unreferenced not because I shouldn't have set it, but because I
_should_ have referenced it!).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9164 cda61777-01e9-0310-a592-d414129be87e

14 files changed:
bridges.c
cube.c
guess.c
keen.c
lightup.c
loopy.c
magnets.c
mines.c
netslide.c
tents.c
towers.c
twiddle.c
unequal.c
unfinished/slide.c

index 0da6b44..8e61400 100644 (file)
--- a/bridges.c
+++ b/bridges.c
@@ -513,7 +513,6 @@ static int island_impossible(struct island *is, int strict)
 {
     int curr = island_countbridges(is), nspc = is->count - curr, nsurrspc;
     int i, poss;
-    grid_type v;
     struct island *is_orth;
 
     if (nspc < 0) {
@@ -533,7 +532,6 @@ static int island_impossible(struct island *is, int strict)
         int ifree, dx = is->adj.points[i].dx;
 
         if (!is->adj.points[i].off) continue;
-        v = GRID(is->state, is->adj.points[i].x, is->adj.points[i].y);
         poss = POSSIBLES(is->state, dx,
                          is->adj.points[i].x, is->adj.points[i].y);
         if (poss == 0) continue;
diff --git a/cube.c b/cube.c
index 8fa1608..9b70487 100644 (file)
--- a/cube.c
+++ b/cube.c
@@ -1546,7 +1546,6 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
     int *pkey, *gkey;
     float t[3];
     float angle;
-    game_state *newstate;
     int square;
 
     draw_rect(dr, 0, 0, XSIZE(GRID_SCALE, bb, state->solid),
@@ -1580,7 +1579,6 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
         pkey = state->spkey;
         gkey = state->sgkey;
     }
-    newstate = state;
     state = oldstate;
 
     for (i = 0; i < state->grid->nsquares; i++) {
diff --git a/guess.c b/guess.c
index a1d9841..8cab1a4 100644 (file)
--- a/guess.c
+++ b/guess.c
@@ -1210,10 +1210,9 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
                        game_state *state, int dir, game_ui *ui,
                        float animtime, float flashtime)
 {
-    int i, new_move, last_go;
+    int i, new_move;
 
     new_move = (state->next_go != ds->next_go) || !ds->started;
-    last_go = (state->next_go == state->params.nguesses-1);
 
     if (!ds->started) {
       draw_rect(dr, 0, 0, ds->w, ds->h, COL_BACKGROUND);
diff --git a/keen.c b/keen.c
index da55fb2..175db55 100644 (file)
--- a/keen.c
+++ b/keen.c
@@ -995,7 +995,7 @@ done
                    /* didn't find a nice one, use a nasty one */
                    for (i = 0; i < a; i++) {
                        j = order[i];
-                       if (singletons[j] & good) {
+                       if (singletons[j] & bad) {
                            clues[j] = clue;
                            singletons[j] = 0;
                            break;
@@ -1188,7 +1188,6 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
 {
     int w = params->w, a = w*w;
     game_state *state = snew(game_state);
-    char *err;
     const char *p = desc;
     int i;
 
@@ -1197,7 +1196,7 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
     state->clues->refcount = 1;
     state->clues->w = w;
     state->clues->dsf = snew_dsf(a);
-    err = parse_block_structure(&p, w, state->clues->dsf);
+    parse_block_structure(&p, w, state->clues->dsf);
 
     assert(*p == ',');
     p++;
index 5b97b2b..5d27fde 100644 (file)
--- a/lightup.c
+++ b/lightup.c
@@ -1402,6 +1402,7 @@ static int strip_unused_nums(game_state *state)
             }
         }
     }
+    debug(("Stripped %d unused numbers.\n", n));
     return n;
 }
 
@@ -1475,7 +1476,7 @@ static char *new_game_desc(game_params *params, random_state *rs,
                           char **aux, int interactive)
 {
     game_state *news = new_state(params), *copys;
-    int nsol, i, j, run, x, y, wh = params->w*params->h, num;
+    int i, j, run, x, y, wh = params->w*params->h, num;
     char *ret, *p;
     int *numindices;
 
@@ -1499,8 +1500,7 @@ static char *new_game_desc(game_params *params, random_state *rs,
             /* Take a copy, remove numbers we didn't use and check there's
              * still a unique solution; if so, use the copy subsequently. */
             copys = dup_game(news);
-            nsol = strip_unused_nums(copys);
-            debug(("Stripped %d unused numbers.\n", nsol));
+            strip_unused_nums(copys);
             if (!puzzle_is_good(copys, params->difficulty)) {
                 debug(("Stripped grid is not good, reverting.\n"));
                 free_game(copys);
diff --git a/loopy.c b/loopy.c
index 43e96a7..8617c72 100644 (file)
--- a/loopy.c
+++ b/loopy.c
@@ -3548,7 +3548,6 @@ static void game_redraw_line(drawing *dr, game_drawstate *ds,
     grid *g = state->game_grid;
     grid_edge *e = g->edges + i;
     int x1, x2, y1, y2;
-    int xmin, ymin, xmax, ymax;
     int line_colour;
 
     if (state->line_errors[i])
@@ -3568,11 +3567,6 @@ static void game_redraw_line(drawing *dr, game_drawstate *ds,
     grid_to_screen(ds, g, e->dot1->x, e->dot1->y, &x1, &y1);
     grid_to_screen(ds, g, e->dot2->x, e->dot2->y, &x2, &y2);
 
-    xmin = min(x1, x2);
-    xmax = max(x1, x2);
-    ymin = min(y1, y2);
-    ymax = max(y1, y2);
-
     if (line_colour == COL_FAINT) {
        static int draw_faint_lines = -1;
        if (draw_faint_lines < 0) {
index 1df2caf..7d71518 100644 (file)
--- a/magnets.c
+++ b/magnets.c
@@ -1046,7 +1046,7 @@ static int solve_rowcols(game_state *state, rowcolfn fn)
 
 static int solve_force(game_state *state)
 {
-    int x, y, i, which, didsth = 0;
+    int i, which, didsth = 0;
     unsigned long f;
 
     for (i = 0; i < state->wh; i++) {
@@ -1062,7 +1062,6 @@ static int solve_force(game_state *state)
         if (f == (GS_NOTNEGATIVE|GS_NOTNEUTRAL))
             which = POSITIVE;
         if (which != -1) {
-            x = i%state->w; y = i/state->w;
             if (solve_set(state, i, which, "forced by flags", NULL) < 0)
                 return -1;
             didsth = 1;
@@ -1073,7 +1072,7 @@ static int solve_force(game_state *state)
 
 static int solve_neither(game_state *state)
 {
-    int x, y, i, j, didsth = 0;
+    int i, j, didsth = 0;
 
     for (i = 0; i < state->wh; i++) {
         if (state->flags[i] & GS_SET) continue;
@@ -1084,7 +1083,6 @@ static int solve_neither(game_state *state)
              (state->flags[j] & GS_NOTPOSITIVE)) ||
             ((state->flags[i] & GS_NOTNEGATIVE) &&
              (state->flags[j] & GS_NOTNEGATIVE))) {
-            x = i%state->w; y = i/state->w;
             if (solve_set(state, i, NEUTRAL, "neither tile magnet", NULL) < 0)
                 return -1;
             didsth = 1;
@@ -1494,7 +1492,7 @@ static int solve_unnumbered(game_state *state)
 
 static int lay_dominoes(game_state *state, random_state *rs, int *scratch)
 {
-    int n, i, ret = 0, x, y, nlaid = 0, n_initial_neutral;
+    int n, i, ret = 0, nlaid = 0, n_initial_neutral;
 
     for (i = 0; i < state->wh; i++) {
         scratch[i] = i;
@@ -1513,8 +1511,7 @@ static int lay_dominoes(game_state *state, random_state *rs, int *scratch)
 
         /* ...and lay a domino if we can. */
 
-        x = i%state->w; y = i/state->w;
-        debug(("Laying domino at i:%d, (%d,%d)\n", i, x, y));
+        debug(("Laying domino at i:%d, (%d,%d)\n", i, i%state->w, i/state->w));
 
         /* The choice of which type of domino to lay here leads to subtle differences
          * in the sorts of boards that get produced. Too much bias towards magnets
@@ -2262,7 +2259,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
     int w = state->w, h = state->h;
     int ink = print_mono_colour(dr, 0);
     int paper = print_mono_colour(dr, 1);
-    int x, y, target, count, which, i, j;
+    int x, y, which, i, j;
 
     /* Ick: fake up `ds->tilesize' for macro expansion purposes */
     game_drawstate ads, *ds = &ads;
@@ -2277,16 +2274,12 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
     draw_sym(dr, ds, state->w, state->h, NEGATIVE, ink);
     for (which = POSITIVE, j = 0; j < 2; which = OPPOSITE(which), j++) {
         for (i = 0; i < w; i++) {
-            target = state->common->colcount[i*3+which];
-            count = count_rowcol(state, i, COLUMN, which);
             draw_num_col(dr, ds, COLUMN, which, i, paper, ink,
-                     state->common->colcount[i*3+which]);
+                         state->common->colcount[i*3+which]);
         }
         for (i = 0; i < h; i++) {
-            target = state->common->rowcount[i*3+which];
-            count = count_rowcol(state, i, ROW, which);
             draw_num_col(dr, ds, ROW, which, i, paper, ink,
-                     state->common->rowcount[i*3+which]);
+                         state->common->rowcount[i*3+which]);
         }
     }
 
diff --git a/mines.c b/mines.c
index 1d72bb2..80d2337 100644 (file)
--- a/mines.c
+++ b/mines.c
@@ -2170,7 +2170,7 @@ static int open_square(game_state *state, int x, int y)
 static game_state *new_game(midend *me, game_params *params, char *desc)
 {
     game_state *state = snew(game_state);
-    int i, wh, x, y, ret, masked;
+    int i, wh, x, y, masked;
     unsigned char *bmp;
 
     state->w = params->w;
@@ -2265,7 +2265,7 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
        }
 
        if (x >= 0 && y >= 0)
-           ret = open_square(state, x, y);
+           open_square(state, x, y);
         sfree(bmp);
     }
 
index 436b786..27a3934 100644 (file)
@@ -1059,7 +1059,7 @@ static char *interpret_move(game_state *state, game_ui *ui,
                            game_drawstate *ds, int x, int y, int button)
 {
     int cx, cy;
-    int n, dx, dy;
+    int dx, dy;
     char buf[80];
 
     button &= ~MOD_MASK;
@@ -1101,7 +1101,6 @@ static char *interpret_move(game_state *state, game_ui *ui,
         if (cx == -1) dx = +1;
         else if (cx == state->width) dx = -1;
         else return NULL;
-        n = state->width;
         dy = 0;
     }
     else if (cx >= 0 && cx < state->width && cx != state->cx)
@@ -1109,7 +1108,6 @@ static char *interpret_move(game_state *state, game_ui *ui,
         if (cy == -1) dy = +1;
         else if (cy == state->height) dy = -1;
         else return NULL;
-        n = state->height;
         dx = 0;
     }
     else
@@ -1585,7 +1583,7 @@ static void draw_arrow_for_cursor(drawing *dr, game_drawstate *ds,
 static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
                  game_state *state, int dir, game_ui *ui, float t, float ft)
 {
-    int x, y, tx, ty, frame;
+    int x, y, frame;
     unsigned char *active;
     float xshift = 0.0;
     float yshift = 0.0;
@@ -1677,7 +1675,6 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
         t = ANIM_TIME - t;
     }
 
-    tx = ty = -1;
     if (oldstate && (t < ANIM_TIME)) {
         /*
          * We're animating a slide, of row/column number
diff --git a/tents.c b/tents.c
index 2a87248..6cf406d 100644 (file)
--- a/tents.c
+++ b/tents.c
@@ -459,7 +459,7 @@ static int tents_solve(int w, int h, const char *grid, int *numbers,
                       char *soln, struct solver_scratch *sc, int diff)
 {
     int x, y, d, i, j;
-    char *mrow, *mrow1, *mrow2, *trow, *trow1, *trow2;
+    char *mrow, *trow, *trow1, *trow2;
 
     /*
      * Set up solver data.
@@ -746,8 +746,6 @@ static int tents_solve(int w, int h, const char *grid, int *numbers,
             * hasn't been set up yet.
             */
            mrow = sc->mrows;
-           mrow1 = sc->mrows + len;
-           mrow2 = sc->mrows + 2*len;
            trow = sc->trows;
            trow1 = sc->trows + len;
            trow2 = sc->trows + 2*len;
index 7beaf87..94ed1a7 100644 (file)
--- a/towers.c
+++ b/towers.c
@@ -1225,14 +1225,13 @@ static int check_errors(game_state *state, int *errors)
     }
 
     for (i = 0; i < 4*w; i++) {
-       int start, step, j, k, n, best;
+       int start, step, j, n, best;
        STARTSTEP(start, step, i, w);
 
        if (!clues[i])
            continue;
 
        best = n = 0;
-       k = 0;
        for (j = 0; j < w; j++) {
            int number = grid[start+j*step];
            if (!number)
index 6acf4cf..c5f89f8 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -432,12 +432,11 @@ static char *new_game_desc(game_params *params, random_state *rs,
 
 static char *validate_desc(game_params *params, char *desc)
 {
-    char *p, *err;
+    char *p;
     int w = params->w, h = params->h, wh = w*h;
     int i;
 
     p = desc;
-    err = NULL;
 
     for (i = 0; i < wh; i++) {
        if (*p < '0' || *p > '9')
index 099f0f8..1c272da 100644 (file)
--- a/unequal.c
+++ b/unequal.c
@@ -951,7 +951,7 @@ static int gg_best_clue(game_state *state, int *scratch, digit *latin)
 {
     int ls = state->order * state->order * 5;
     int maxposs = 0, minclues = 5, best = -1, i, j;
-    int nposs, nclues, loc, x, y;
+    int nposs, nclues, loc;
 
 #ifdef STANDALONE_SOLVER
     if (solver_show_working) {
@@ -964,7 +964,6 @@ static int gg_best_clue(game_state *state, int *scratch, digit *latin)
         if (!gg_place_clue(state, scratch[i], latin, 1)) continue;
 
         loc = scratch[i] / 5;
-        x = loc % state->order; y = loc / state->order;
         for (j = nposs = 0; j < state->order; j++) {
             if (state->hints[loc*state->order + j]) nposs++;
         }
@@ -975,9 +974,11 @@ static int gg_best_clue(game_state *state, int *scratch, digit *latin)
             (nposs == maxposs && nclues < minclues)) {
             best = i; maxposs = nposs; minclues = nclues;
 #ifdef STANDALONE_SOLVER
-            if (solver_show_working)
+            if (solver_show_working) {
+                int x = loc % state->order, y = loc / state->order;
                 printf("gg_best_clue: b%d (%d,%d) new best [%d poss, %d clues].\n",
                        best, x+1, y+1, nposs, nclues);
+            }
 #endif
         }
     }
index 3ea3c95..fbaa630 100644 (file)
@@ -895,7 +895,7 @@ static char *validate_desc(game_params *params, char *desc)
 {
     int w = params->w, h = params->h, wh = w*h;
     int *active, *link;
-    int mains = 0, mpos = -1;
+    int mains = 0;
     int i, tx, ty, minmoves;
     char *ret;
 
@@ -966,7 +966,6 @@ static char *validate_desc(game_params *params, char *desc)
                link[i] = -1;
                if (strchr("mM", c) != NULL) {
                    mains++;
-                   mpos = i;
                }
                i++;
            }
@@ -2363,14 +2362,17 @@ int main(int argc, char **argv)
     game_state *s;
     char *id = NULL, *desc, *err;
     int count = FALSE;
-    int ret, really_verbose = FALSE;
+    int ret;
     int *moves;
 
     while (--argc > 0) {
         char *p = *++argv;
+        /*
         if (!strcmp(p, "-v")) {
-            really_verbose = TRUE;
-        } else if (!strcmp(p, "-c")) {
+            verbose = TRUE;
+        } else
+        */
+        if (!strcmp(p, "-c")) {
             count = TRUE;
         } else if (*p == '-') {
             fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);