ref: 2efc77d2fde7e53604f8490b57f18a36eec5c4fb
parent: 4bab5e531b4b49c9b41d2140dd570d05947e7c40
author: Simon Tatham <anakin@pobox.com>
date: Wed May 4 14:22:14 EDT 2011
Fix warnings generated by gcc 4.6.0 about variables set but not 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!). [originally from svn r9164]
--- a/bridges.c
+++ b/bridges.c
@@ -513,7 +513,6 @@
{
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 @@
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;
--- a/cube.c
+++ b/cube.c
@@ -1546,7 +1546,6 @@
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 @@
pkey = state->spkey;
gkey = state->sgkey;
}
- newstate = state;
state = oldstate;
for (i = 0; i < state->grid->nsquares; i++) {
--- a/guess.c
+++ b/guess.c
@@ -1210,10 +1210,9 @@
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);
--- a/keen.c
+++ b/keen.c
@@ -995,7 +995,7 @@
/* 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 @@
{
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 @@
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++;
--- a/lightup.c
+++ b/lightup.c
@@ -1402,6 +1402,7 @@
}
}
}
+ debug(("Stripped %d unused numbers.\n", n));
return n;
}
@@ -1475,7 +1476,7 @@
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 @@
/* 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);
--- a/loopy.c
+++ b/loopy.c
@@ -3548,7 +3548,6 @@
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])
@@ -3567,11 +3566,6 @@
/* Convert from grid to screen coordinates */
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;
--- a/magnets.c
+++ b/magnets.c
@@ -1046,7 +1046,7 @@
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 @@
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_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 @@
(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 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 @@
/* ...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 @@
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 @@
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]);
}
}
--- a/mines.c
+++ b/mines.c
@@ -2170,7 +2170,7 @@
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 @@
}
if (x >= 0 && y >= 0)
- ret = open_square(state, x, y);
+ open_square(state, x, y);
sfree(bmp);
}
--- a/netslide.c
+++ b/netslide.c
@@ -1059,7 +1059,7 @@
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 @@
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 @@
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 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 @@
t = ANIM_TIME - t;
}
- tx = ty = -1;
if (oldstate && (t < ANIM_TIME)) {
/*
* We're animating a slide, of row/column number
--- a/tents.c
+++ b/tents.c
@@ -459,7 +459,7 @@
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 @@
* 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;
--- a/towers.c
+++ b/towers.c
@@ -1225,7 +1225,7 @@
}
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])
@@ -1232,7 +1232,6 @@
continue;
best = n = 0;
- k = 0;
for (j = 0; j < w; j++) {
int number = grid[start+j*step];
if (!number)
--- a/twiddle.c
+++ b/twiddle.c
@@ -432,12 +432,11 @@
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')
--- a/unequal.c
+++ b/unequal.c
@@ -951,7 +951,7 @@
{
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 @@
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 @@
(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
}
}
--- a/unfinished/slide.c
+++ b/unfinished/slide.c
@@ -895,7 +895,7 @@
{
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 @@
link[i] = -1;
if (strchr("mM", c) != NULL) {
mains++;
- mpos = i;
}
i++;
}
@@ -2363,14 +2362,17 @@
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);