shithub: puzzles

Download patch

ref: c82537b4574d45aa16e50b7f8dc1f075cfdb69f9
parent: de13ca2874e673b426efcf04f734ae6625635396
author: Simon Tatham <anakin@pobox.com>
date: Fri Jun 16 15:03:56 EDT 2023

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.

--- a/magnets.c
+++ b/magnets.c
@@ -1590,6 +1590,7 @@
     }
 
     debug(("Laid %d dominoes, total %d dominoes.\n", nlaid, state->wh/2));
+    (void)nlaid;
     game_debug(state, "Final layout");
     return ret;
 }
--- a/mosaic.c
+++ b/mosaic.c
@@ -409,7 +409,7 @@
 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 @@
             if (curr) {
                 if (curr->cell == STATE_UNMARKED) {
                     curr->cell = mark;
-                    marked++;
                 }
             }
         }
@@ -585,7 +584,7 @@
     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 @@
                 solved += curr;
             }
         }
-        iter++;
     }
     if (sol_return) {
         *sol_return = sol;
--- a/palisade.c
+++ b/palisade.c
@@ -634,8 +634,6 @@
     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 @@
     soln[wh] = '\0';
 
     do {
-        ++attempts;
         setmem(soln, '@', wh);
 
         dsf_free(dsf);
--- a/pattern.c
+++ b/pattern.c
@@ -663,7 +663,7 @@
 #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 @@
     changed_w = snewn(max+1, unsigned int);
     rowdata = snewn(max+1, int);
 
-    ntries = 0;
-
     do {
-        ntries++;
-
         generate(rs, w, h, grid);
 
         /*
--- a/samegame.c
+++ b/samegame.c
@@ -865,6 +865,8 @@
 
 #if defined GENERATION_DIAGNOSTICS || defined COUNT_FAILURES
     printf("%d failures\n", failures);
+#else
+    (void)failures;
 #endif
 #ifdef GENERATION_DIAGNOSTICS
     {
--- a/undead.c
+++ b/undead.c
@@ -976,7 +976,7 @@
 
 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 @@
     char *e;
     char *desc; 
 
-    i = 0;
     while (true) {
         new = new_state(params);
         abort = false;
@@ -1257,7 +1256,6 @@
          * difficulty level, free memory and start from scratch */    
         sfree(old_guess);
         free_game(new);
-        i++;
     }
     
     /* We have a valid puzzle! */
@@ -1578,6 +1576,8 @@
     }
 
 /*  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;
--- a/unruly.c
+++ b/unruly.c
@@ -1398,6 +1398,8 @@
             temp_verbose = solver_verbose;
             solver_verbose = false;
         }
+#else
+        (void)attempts;
 #endif
 
         unruly_free_scratch(scratch);