Fix some unused-variable warnings.

A test-build with a modern clang points out a number of 'set but not
used' variables, which clang seems to have got better at recently.

In cases where there's conditioned-out or commented-out code using the
variable, I've left it in and added a warning-suppressing cast to
void. Otherwise I've just deleted the variables.
This commit is contained in:
Simon Tatham
2023-06-16 19:03:56 +01:00
parent de13ca2874
commit c82537b457
7 changed files with 11 additions and 15 deletions

View File

@ -1590,6 +1590,7 @@ static int lay_dominoes(game_state *state, random_state *rs, int *scratch)
}
debug(("Laid %d dominoes, total %d dominoes.\n", nlaid, state->wh/2));
(void)nlaid;
game_debug(state, "Final layout");
return ret;
}

View File

@ -409,7 +409,7 @@ static void count_clues_around(const game_params *params,
static void mark_around(const game_params *params,
struct solution_cell *sol, int x, int y, int mark)
{
int i, j, marked = 0;
int i, j;
struct solution_cell *curr;
for (i = -1; i < 2; i++) {
@ -418,7 +418,6 @@ static void mark_around(const game_params *params,
if (curr) {
if (curr->cell == STATE_UNMARKED) {
curr->cell = mark;
marked++;
}
}
}
@ -585,7 +584,7 @@ static bool solve_game_actual(const game_params *params,
int board_size = params->height * params->width;
struct solution_cell *sol = snewn(board_size, struct solution_cell);
bool made_progress = true, error = false;
int solved = 0, iter = 0, curr = 0;
int solved = 0, curr = 0;
memset(sol, 0, params->height * params->width * sizeof(*sol));
solved = 0;
@ -607,7 +606,6 @@ static bool solve_game_actual(const game_params *params,
solved += curr;
}
}
iter++;
}
if (sol_return) {
*sol_return = sol;

View File

@ -634,8 +634,6 @@ static char *new_game_desc(const game_params *params, random_state *rs,
DSF *dsf = NULL;
int i, r, c;
int attempts = 0;
for (i = 0; i < wh; ++i) shuf[i] = i;
xshuffle(shuf, wh, rs);
@ -646,7 +644,6 @@ static char *new_game_desc(const game_params *params, random_state *rs,
soln[wh] = '\0';
do {
++attempts;
setmem(soln, '@', wh);
dsf_free(dsf);

View File

@ -663,7 +663,7 @@ static bool solve_puzzle(const game_state *state, unsigned char *grid,
#ifndef STANDALONE_PICTURE_GENERATOR
static unsigned char *generate_soluble(random_state *rs, int w, int h)
{
int i, j, ntries, max;
int i, j, max;
bool ok;
unsigned char *grid, *matrix, *workspace;
unsigned int *changed_h, *changed_w;
@ -679,11 +679,7 @@ static unsigned char *generate_soluble(random_state *rs, int w, int h)
changed_w = snewn(max+1, unsigned int);
rowdata = snewn(max+1, int);
ntries = 0;
do {
ntries++;
generate(rs, w, h, grid);
/*

View File

@ -865,6 +865,8 @@ static void gen_grid(int w, int h, int nc, int *grid, random_state *rs)
#if defined GENERATION_DIAGNOSTICS || defined COUNT_FAILURES
printf("%d failures\n", failures);
#else
(void)failures;
#endif
#ifdef GENERATION_DIAGNOSTICS
{

View File

@ -976,7 +976,7 @@ static int path_cmp(const void *a, const void *b) {
static char *new_game_desc(const game_params *params, random_state *rs,
char **aux, bool interactive) {
int i,count,c,w,h,r,p,g;
int count,c,w,h,r,p,g;
game_state *new;
/* Variables for puzzle generation algorithm */
@ -997,7 +997,6 @@ static char *new_game_desc(const game_params *params, random_state *rs,
char *e;
char *desc;
i = 0;
while (true) {
new = new_state(params);
abort = false;
@ -1257,7 +1256,6 @@ static char *new_game_desc(const game_params *params, random_state *rs,
* difficulty level, free memory and start from scratch */
sfree(old_guess);
free_game(new);
i++;
}
/* We have a valid puzzle! */
@ -1578,6 +1576,8 @@ static char *solve_game(const game_state *state_start, const game_state *currsta
}
/* printf("Puzzle solved at level %s, iterations %d, ambiguous %d\n", (solved_bruteforce ? "TRICKY" : "NORMAL"), iterative_depth, count_ambiguous); */
(void)iterative_depth;
(void)count_ambiguous;
move = snewn(solve_state->common->num_total * 4 +2, char);
c = move;

View File

@ -1398,6 +1398,8 @@ static char *new_game_desc(const game_params *params, random_state *rs,
temp_verbose = solver_verbose;
solver_verbose = false;
}
#else
(void)attempts;
#endif
unruly_free_scratch(scratch);