shithub: puzzles

Download patch

ref: a58c1b216bb1d4547f7b2ef2703fe2d0cd3b5cac
parent: 3276376d1be74b66970b88c3e941dcedf8d22474
author: Simon Tatham <anakin@pobox.com>
date: Sun Oct 1 10:45:12 EDT 2017

Make the code base clean under -Wwrite-strings.

I've also added that warning option and -Werror to the build script,
so that I'll find out if I break this property in future.

--- a/Buildscr
+++ b/Buildscr
@@ -25,7 +25,7 @@
 in puzzles do perl -i -pe 's/Unidentified build/$(Version)/' osx-info.plist
 
 # First build some local binaries, to run the icon build.
-in puzzles do perl mkfiles.pl -U
+in puzzles do perl mkfiles.pl -U CFLAGS='-Wwrite-strings -Werror'
 in puzzles do make
 
 # Now build the screenshots and icons.
@@ -45,7 +45,7 @@
 # Build the OS X .dmg archive.
 delegate osx
   in puzzles do make -f Makefile.osx clean
-  in puzzles do make -f Makefile.osx release VER=-DVER=$(Version)
+  in puzzles do make -f Makefile.osx release VER=-DVER=$(Version) XFLAGS='-Wwrite-strings -Werror'
   return puzzles/Puzzles.dmg
 enddelegate
 
@@ -56,7 +56,7 @@
 in puzzles do perl winiss.pl $(Version) gamedesc.txt > puzzles.iss
 ifneq "$(VISUAL_STUDIO)" "yes" then
   in puzzles with clangcl64 do Platform=x64 make -f Makefile.clangcl clean
-  in puzzles with clangcl64 do Platform=x64 make -f Makefile.clangcl VER=-DVER=$(Version)
+  in puzzles with clangcl64 do Platform=x64 make -f Makefile.clangcl VER=-DVER=$(Version) XFLAGS='-Wwrite-strings -Werror'
   # Code-sign the binaries, if the local bob config provides a script
   # to do so. We assume here that the script accepts an -i option to
   # provide a 'more info' URL, and an optional -n option to provide a
@@ -144,7 +144,7 @@
 
 # Build the Java applets.
 delegate nestedvm
-  in puzzles do make -f Makefile.nestedvm NESTEDVM="$$NESTEDVM" VER=-DVER=$(Version)
+  in puzzles do make -f Makefile.nestedvm NESTEDVM="$$NESTEDVM" VER=-DVER=$(Version) XFLAGS="-Wwrite-strings -Werror"
   return puzzles/*.jar
 enddelegate
 
@@ -154,7 +154,7 @@
 in puzzles do mkdir js # so we can tell output .js files from emcc*.js
 delegate emscripten
   in puzzles do make -f Makefile.emcc OUTPREFIX=js/ clean
-  in puzzles do make -f Makefile.emcc OUTPREFIX=js/
+  in puzzles do make -f Makefile.emcc OUTPREFIX=js/ XFLAGS="-Wwrite-strings -Werror"
   return puzzles/js/*.js
 enddelegate
 
--- a/blackbox.c
+++ b/blackbox.c
@@ -251,7 +251,7 @@
 {
     int nballs, dlen = strlen(desc), i;
     unsigned char *bmp;
-    char *ret;
+    const char *ret;
 
     /* the bitmap is 2+(nballs*2) long; the hex version is double that. */
     nballs = ((dlen/2)-2)/2;
--- a/cube.c
+++ b/cube.c
@@ -238,7 +238,7 @@
 static int game_fetch_preset(int i, char **name, game_params **params)
 {
     game_params *ret = snew(game_params);
-    char *str;
+    const char *str;
 
     switch (i) {
       case 0:
--- a/devel.but
+++ b/devel.but
@@ -3296,8 +3296,7 @@
 \H{midend-serialise} \cw{midend_serialise()}
 
 \c void midend_serialise(midend *me,
-\c                       void (*write)(void *ctx, void *buf, int len),
-\c                       void *wctx);
+\c     void (*write)(void *ctx, const void *buf, int len), void *wctx);
 
 Calling this function causes the mid-end to convert its entire
 internal state into a long ASCII text string, and to pass that
--- a/dominosa.c
+++ b/dominosa.c
@@ -749,7 +749,7 @@
     int n = params->n, w = n+2, h = n+1, wh = w*h;
     int *occurrences;
     int i, j;
-    char *ret;
+    const char *ret;
 
     ret = NULL;
     occurrences = snewn(n+1, int);
--- a/emcc.c
+++ b/emcc.c
@@ -787,7 +787,7 @@
     size_t pos;
 };
 
-static void savefile_write(void *vctx, void *buf, int len)
+static void savefile_write(void *vctx, const void *buf, int len)
 {
     struct savefile_write_ctx *ctx = (struct savefile_write_ctx *)vctx;
     if (ctx->buffer)
--- a/fifteen.c
+++ b/fifteen.c
@@ -273,7 +273,7 @@
 static const char *validate_desc(const game_params *params, const char *desc)
 {
     const char *p;
-    char *err;
+    const char *err;
     int i, area;
     int *used;
 
--- a/filling.c
+++ b/filling.c
@@ -68,7 +68,7 @@
 
 static unsigned char verbose;
 
-static void printv(char *fmt, ...) {
+static void printv(const char *fmt, ...) {
 #ifndef PALM
     if (verbose) {
 	va_list va;
--- a/galaxies.c
+++ b/galaxies.c
@@ -667,7 +667,8 @@
                        int issolve)
 {
     int movelen = 0, movesize = 256, x, y, len;
-    char *move = snewn(movesize, char), buf[80], *sep = "";
+    char *move = snewn(movesize, char), buf[80];
+    const char *sep = "";
     char achar = issolve ? 'a' : 'A';
     space *sps, *spd;
 
@@ -1523,10 +1524,10 @@
 }
 
 static game_state *load_game(const game_params *params, const char *desc,
-                             char **why_r)
+                             const char **why_r)
 {
     game_state *state = blank_game(params->w, params->h);
-    char *why = NULL;
+    const char *why = NULL;
     int i, x, y, n;
     unsigned int df;
 
@@ -1572,7 +1573,7 @@
 
 static const char *validate_desc(const game_params *params, const char *desc)
 {
-    char *why = NULL;
+    const char *why = NULL;
     game_state *dummy = load_game(params, desc, &why);
     if (dummy) {
         free_game(dummy);
--- a/grid.c
+++ b/grid.c
@@ -1529,8 +1529,8 @@
     *yextent = height * vec_y;
 }
 
-static char *grid_validate_desc_triangular(grid_type type, int width,
-                                           int height, const char *desc)
+static const char *grid_validate_desc_triangular(grid_type type, int width,
+                                                 int height, const char *desc)
 {
     /*
      * Triangular grids: an absent description is valid (indicating
@@ -2855,8 +2855,9 @@
     return dupstr(gd);
 }
 
-static char *grid_validate_desc_penrose(grid_type type, int width, int height,
-                                        const char *desc)
+static const char *grid_validate_desc_penrose(grid_type type,
+                                              int width, int height,
+                                              const char *desc)
 {
     int tilesize = PENROSE_TILESIZE, startsz, depth, xoff, yoff, aoff, inner_radius;
     double outer_radius;
@@ -3032,8 +3033,8 @@
     }
 }
 
-char *grid_validate_desc(grid_type type, int width, int height,
-                         const char *desc)
+const char *grid_validate_desc(grid_type type, int width, int height,
+                               const char *desc)
 {
     if (type == GRID_PENROSE_P2 || type == GRID_PENROSE_P3) {
         return grid_validate_desc_penrose(type, width, height, desc);
@@ -3048,7 +3049,7 @@
 
 grid *grid_new(grid_type type, int width, int height, const char *desc)
 {
-    char *err = grid_validate_desc(type, width, height, desc);
+    const char *err = grid_validate_desc(type, width, height, desc);
     if (err) assert(!"Invalid grid description.");
 
     return grid_news[type](width, height, desc);
--- a/grid.h
+++ b/grid.h
@@ -116,8 +116,8 @@
 /* Free directly after use if non-NULL. Will never contain an underscore
  * (so clients can safely use that as a separator). */
 char *grid_new_desc(grid_type type, int width, int height, random_state *rs);
-char *grid_validate_desc(grid_type type, int width, int height,
-                         const char *desc);
+const char *grid_validate_desc(grid_type type, int width, int height,
+                               const char *desc);
 
 grid *grid_new(grid_type type, int width, int height, const char *desc);
 
--- a/gtk.c
+++ b/gtk.c
@@ -2168,7 +2168,7 @@
     fe->filesel_name = dupstr(name);
 }
 
-static char *file_selector(frontend *fe, char *title, int save)
+static char *file_selector(frontend *fe, const char *title, int save)
 {
     GtkWidget *filesel =
         gtk_file_selection_new(title);
@@ -2199,7 +2199,7 @@
 
 #else
 
-static char *file_selector(frontend *fe, char *title, int save)
+static char *file_selector(frontend *fe, const char *title, int save)
 {
     char *filesel_name = NULL;
 
@@ -2231,7 +2231,7 @@
     int error;
 };
 
-static void savefile_write(void *wctx, void *buf, int len)
+static void savefile_write(void *wctx, const void *buf, int len)
 {
     struct savefile_write_ctx *ctx = (struct savefile_write_ctx *)wctx;
     if (fwrite(buf, 1, len, ctx->fp) < len)
@@ -2396,7 +2396,7 @@
 }
 
 static GtkWidget *add_menu_ui_item(
-    frontend *fe, GtkContainer *cont, char *text, int action,
+    frontend *fe, GtkContainer *cont, const char *text, int action,
     int accel_key, int accel_keyqual)
 {
     GtkWidget *menuitem = gtk_menu_item_new_with_label(text);
@@ -2928,7 +2928,7 @@
     int soln = FALSE, colour = FALSE;
     float scale = 1.0F;
     float redo_proportion = 0.0F;
-    char *savefile = NULL, *savesuffix = NULL;
+    const char *savefile = NULL, *savesuffix = NULL;
     char *arg = NULL;
     int argtype = ARG_EITHER;
     char *screenshot_file = NULL;
--- a/guess.c
+++ b/guess.c
@@ -74,7 +74,7 @@
 }
 
 static const struct {
-    char *name;
+    const char *name;
     game_params params;
 } guess_presets[] = {
     {"Standard", {6, 4, 10, FALSE, TRUE}},
@@ -440,7 +440,8 @@
 
 static char *encode_ui(const game_ui *ui)
 {
-    char *ret, *p, *sep;
+    char *ret, *p;
+    const char *sep;
     int i;
 
     /*
@@ -614,7 +615,8 @@
 
 static char *encode_move(const game_state *from, game_ui *ui)
 {
-    char *buf, *p, *sep;
+    char *buf, *p;
+    const char *sep;
     int len, i;
 
     len = ui->curr_pegs->npegs * 20 + 2;
--- a/inertia.c
+++ b/inertia.c
@@ -738,7 +738,8 @@
     int *unvisited;
     int circuitlen, circuitsize;
     int head, tail, pass, i, j, n, x, y, d, dd;
-    char *err, *soln, *p;
+    const char *err;
+    char *soln, *p;
 
     /*
      * Before anything else, deal with the special case in which
--- a/keen.c
+++ b/keen.c
@@ -727,7 +727,7 @@
     return q;
 }
 
-static char *parse_block_structure(const char **p, int w, int *dsf)
+static const char *parse_block_structure(const char **p, int w, int *dsf)
 {
     int a = w*w;
     int pos = 0;
@@ -1207,7 +1207,7 @@
 {
     int w = params->w, a = w*w;
     int *dsf;
-    char *ret;
+    const char *ret;
     const char *p = desc;
     int i;
 
--- a/latin.c
+++ b/latin.c
@@ -73,7 +73,7 @@
 
 int latin_solver_elim(struct latin_solver *solver, int start, int step
 #ifdef STANDALONE_SOLVER
-		      , char *fmt, ...
+		      , const char *fmt, ...
 #endif
 		      )
 {
@@ -150,7 +150,7 @@
                      struct latin_solver_scratch *scratch,
                      int start, int step1, int step2
 #ifdef STANDALONE_SOLVER
-                     , char *fmt, ...
+                     , const char *fmt, ...
 #endif
                      )
 {
@@ -499,7 +499,7 @@
                                 (xt == x || yt == y)) {
 #ifdef STANDALONE_SOLVER
                                 if (solver_show_working) {
-                                    char *sep = "";
+                                    const char *sep = "";
                                     int xl, yl;
                                     printf("%*sforcing chain, %s at ends of ",
                                            solver_recurse_depth*4, "",
@@ -775,7 +775,7 @@
 
 #ifdef STANDALONE_SOLVER
         if (solver_show_working) {
-            char *sep = "";
+            const char *sep = "";
             printf("%*srecursing on (%d,%d) [",
                    solver_recurse_depth*4, "", x+1, y+1);
             for (i = 0; i < j; i++) {
--- a/latin.h
+++ b/latin.h
@@ -39,7 +39,7 @@
 /* Positional elimination. */
 int latin_solver_elim(struct latin_solver *solver, int start, int step
 #ifdef STANDALONE_SOLVER
-                      , char *fmt, ...
+                      , const char *fmt, ...
 #endif
                       );
 
@@ -49,7 +49,7 @@
                      struct latin_solver_scratch *scratch,
                      int start, int step1, int step2
 #ifdef STANDALONE_SOLVER
-                     , char *fmt, ...
+                     , const char *fmt, ...
 #endif
                      );
 
--- a/loopy.c
+++ b/loopy.c
@@ -295,7 +295,7 @@
 #define NUM_GRID_TYPES (sizeof(grid_types) / sizeof(grid_types[0]))
 static const struct {
     int amin, omin;
-    char *aerr, *oerr;
+    const char *aerr, *oerr;
 } grid_size_limits[] = { GRIDLIST(GRID_SIZES) };
 
 /* Generates a (dynamically allocated) new grid, according to the
@@ -760,7 +760,8 @@
 {
     int count = 0;
     grid *g;
-    char *grid_desc, *ret;
+    char *grid_desc;
+    const char *ret;
 
     /* It's pretty inefficient to do this just for validation. All we need to
      * know is the precise number of faces. */
--- a/map.c
+++ b/map.c
@@ -873,7 +873,7 @@
 static int place_colour(struct solver_scratch *sc,
 			int *colouring, int index, int colour
 #ifdef SOLVER_DIAGNOSTICS
-                        , char *verb
+                        , const char *verb
 #endif
                         )
 {
@@ -920,7 +920,7 @@
 {
     int i;
     char *p = buf;
-    char *sep = "";
+    const char *sep = "";
 
     for (i = 0; i < FOUR; i++)
         if (set & (1 << i)) {
@@ -1214,7 +1214,8 @@
                                 (sc->possible[k] & currc)) {
 #ifdef SOLVER_DIAGNOSTICS
                                 if (verbose) {
-                                    char buf[80], *sep = "";
+                                    char buf[80];
+                                    const char *sep = "";
                                     int r;
 
                                     printf("%*sforcing chain, colour %s, ",
@@ -1699,8 +1700,8 @@
     return ret;
 }
 
-static char *parse_edge_list(const game_params *params, const char **desc,
-                             int *map)
+static const char *parse_edge_list(const game_params *params,
+                                   const char **desc, int *map)
 {
     int w = params->w, h = params->h, wh = w*h, n = params->n;
     int i, k, pos, state;
@@ -1781,7 +1782,7 @@
     int w = params->w, h = params->h, wh = w*h, n = params->n;
     int area;
     int *map;
-    char *ret;
+    const char *ret;
 
     map = snewn(2*wh, int);
     ret = parse_edge_list(params, &desc, map);
@@ -1841,7 +1842,7 @@
     p = desc;
 
     {
-	char *ret;
+	const char *ret;
 	ret = parse_edge_list(params, &p, state->map->map);
 	assert(!ret);
     }
--- a/midend.c
+++ b/midend.c
@@ -118,7 +118,7 @@
  */
 static const char *midend_deserialise_internal(
     midend *me, int (*read)(void *ctx, void *buf, int len), void *rctx,
-    char *(*check)(void *ctx, midend *, const struct deserialise_data *),
+    const char *(*check)(void *ctx, midend *, const struct deserialise_data *),
     void *cctx);
 
 void midend_reset_tilesize(midend *me)
@@ -384,7 +384,7 @@
     midend_redraw(me);
 }
 
-static void newgame_serialise_write(void *ctx, void *buf, int len)
+static void newgame_serialise_write(void *ctx, const void *buf, int len)
 {
     midend *const me = ctx;
     int new_len;
@@ -547,7 +547,7 @@
     int refused;
 };
 
-static char *newgame_undo_deserialise_check(
+static const char *newgame_undo_deserialise_check(
     void *vctx, midend *me, const struct deserialise_data *data)
 {
     struct newgame_undo_deserialise_check_ctx *ctx =
@@ -1333,7 +1333,8 @@
 
 config_item *midend_get_config(midend *me, int which, char **wintitle)
 {
-    char *titlebuf, *parstr, *rest;
+    char *titlebuf, *parstr;
+    const char *rest;
     config_item *ret;
     char sep;
 
@@ -1765,7 +1766,7 @@
 #define SERIALISE_VERSION "1"
 
 void midend_serialise(midend *me,
-                      void (*write)(void *ctx, void *buf, int len),
+                      void (*write)(void *ctx, const void *buf, int len),
                       void *wctx)
 {
     int i;
@@ -1781,7 +1782,7 @@
      */
 #define wr(h,s) do { \
     char hbuf[80]; \
-    char *str = (s); \
+    const char *str = (s); \
     char lbuf[9];                               \
     copy_left_justified(lbuf, sizeof(lbuf), h); \
     sprintf(hbuf, "%s:%d:", lbuf, (int)strlen(str)); \
@@ -1922,7 +1923,7 @@
  */
 static const char *midend_deserialise_internal(
     midend *me, int (*read)(void *ctx, void *buf, int len), void *rctx,
-    char *(*check)(void *ctx, midend *, const struct deserialise_data *data),
+    const char *(*check)(void *ctx, midend *, const struct deserialise_data *),
     void *cctx)
 {
     struct deserialise_data data;
@@ -1932,7 +1933,7 @@
 
     char *val = NULL;
     /* Initially all errors give the same report */
-    char *ret = "Data does not appear to be a saved game file";
+    const char *ret = "Data does not appear to be a saved game file";
 
     data.seed = data.parstr = data.desc = data.privdesc = NULL;
     data.auxinfo = data.uistr = data.cparstr = NULL;
@@ -2309,7 +2310,7 @@
 
     char *val = NULL;
     /* Initially all errors give the same report */
-    char *ret = "Data does not appear to be a saved game file";
+    const char *ret = "Data does not appear to be a saved game file";
 
     *name = NULL;
 
--- a/mines.c
+++ b/mines.c
@@ -2558,7 +2558,7 @@
 		 * can.
 		 */
 		char *p = buf;
-		char *sep = "";
+		const char *sep = "";
 
 		for (dy = -1; dy <= +1; dy++)
 		    for (dx = -1; dx <= +1; dx++)
--- a/osx.m
+++ b/osx.m
@@ -152,7 +152,7 @@
     *randseedsize = sizeof(time_t);
 }
 
-static void savefile_write(void *wctx, void *buf, int len)
+static void savefile_write(void *wctx, const void *buf, int len)
 {
     FILE *fp = (FILE *)wctx;
     fwrite(buf, 1, len, fp);
--- a/ps.c
+++ b/ps.c
@@ -21,7 +21,7 @@
     drawing *drawing;
 };
 
-static void ps_printf(psdata *ps, char *fmt, ...)
+static void ps_printf(psdata *ps, const char *fmt, ...)
 {
     va_list ap;
 
@@ -73,7 +73,7 @@
     }
 }
 
-static void ps_setcolour_internal(psdata *ps, int colour, char *suffix)
+static void ps_setcolour_internal(psdata *ps, int colour, const char *suffix)
 {
     int hatch;
     float r, g, b;
--- a/puzzles.h
+++ b/puzzles.h
@@ -325,7 +325,7 @@
                                 const char *privdesc);
 char *midend_rewrite_statusbar(midend *me, const char *text);
 void midend_serialise(midend *me,
-                      void (*write)(void *ctx, void *buf, int len),
+                      void (*write)(void *ctx, const void *buf, int len),
                       void *wctx);
 const char *midend_deserialise(midend *me,
                                int (*read)(void *ctx, void *buf, int len),
--- a/range.c
+++ b/range.c
@@ -66,7 +66,7 @@
 
 #define setmember(obj, field) ( (obj) . field = field )
 
-static char *nfmtstr(int n, char *fmt, ...) {
+static char *nfmtstr(int n, const char *fmt, ...) {
     va_list va;
     char *ret = snewn(n+1, char);
     va_start(va, fmt);
--- a/samegame.c
+++ b/samegame.c
@@ -1108,7 +1108,8 @@
 static char *sel_movedesc(game_ui *ui, const game_state *state)
 {
     int i;
-    char *ret, *sep, buf[80];
+    char *ret, buf[80];
+    const char *sep;
     int retlen, retsize;
 
     retsize = 256;
--- a/signpost.c
+++ b/signpost.c
@@ -497,10 +497,11 @@
 }
 
 static void unpick_desc(const game_params *params, const char *desc,
-                        game_state **sout, char **mout)
+                        game_state **sout, const char **mout)
 {
     game_state *state = blank_game(params->w, params->h);
-    char *msg = NULL, c;
+    const char *msg = NULL;
+    char c;
     int num = 0, i = 0;
 
     while (*desc) {
@@ -845,7 +846,7 @@
 
 static const char *validate_desc(const game_params *params, const char *desc)
 {
-    char *ret = NULL;
+    const char *ret = NULL;
 
     unpick_desc(params, desc, NULL, &ret);
     return ret;
--- a/singles.c
+++ b/singles.c
@@ -330,10 +330,10 @@
 }
 
 static void unpick_desc(const game_params *params, const char *desc,
-                        game_state **sout, char **mout)
+                        game_state **sout, const char **mout)
 {
     game_state *state = blank_game(params->w, params->h);
-    char *msg = NULL;
+    const char *msg = NULL;
     int num = 0, i = 0;
 
     if (strlen(desc) != state->n) {
@@ -1412,7 +1412,7 @@
 
 static const char *validate_desc(const game_params *params, const char *desc)
 {
-    char *ret = NULL;
+    const char *ret = NULL;
 
     unpick_desc(params, desc, NULL, &ret);
     return ret;
--- a/sixteen.c
+++ b/sixteen.c
@@ -398,8 +398,7 @@
 
 static const char *validate_desc(const game_params *params, const char *desc)
 {
-    const char *p;
-    char *err;
+    const char *p, *err;
     int i, area;
     int *used;
 
--- a/slant.c
+++ b/slant.c
@@ -413,7 +413,7 @@
 }
 
 static int vbitmap_clear(int w, int h, struct solver_scratch *sc,
-                         int x, int y, int vbits, char *reason, ...)
+                         int x, int y, int vbits, const char *reason, ...)
 {
     int done_something = FALSE;
     int vbit;
@@ -734,7 +734,7 @@
 		int fs, bs, v;
 		int c1, c2;
 #ifdef SOLVER_DIAGNOSTICS
-		char *reason = "<internal error>";
+		const char *reason = "<internal error>";
 #endif
 
 		if (soln[y*w+x])
--- a/solo.c
+++ b/solo.c
@@ -299,9 +299,9 @@
 static int game_fetch_preset(int i, char **name, game_params **params)
 {
     static struct {
-        char *title;
+        const char *title;
         game_params params;
-    } presets[] = {
+    } const presets[] = {
         { "2x2 Trivial", { 2, 2, SYMM_ROT2, DIFF_BLOCK, DIFF_KMINMAX, FALSE, FALSE } },
         { "2x3 Basic", { 2, 3, SYMM_ROT2, DIFF_SIMPLE, DIFF_KMINMAX, FALSE, FALSE } },
         { "3x3 Trivial", { 3, 3, SYMM_ROT2, DIFF_BLOCK, DIFF_KMINMAX, FALSE, FALSE } },
@@ -831,19 +831,20 @@
  */
 struct solver_scratch;
 static int solver_elim(struct solver_usage *usage, int *indices,
-                       char *fmt, ...) __attribute__((format(printf,3,4)));
+                       const char *fmt, ...)
+    __attribute__((format(printf,3,4)));
 static int solver_intersect(struct solver_usage *usage,
-                            int *indices1, int *indices2, char *fmt, ...)
+                            int *indices1, int *indices2, const char *fmt, ...)
     __attribute__((format(printf,4,5)));
 static int solver_set(struct solver_usage *usage,
                       struct solver_scratch *scratch,
-                      int *indices, char *fmt, ...)
+                      int *indices, const char *fmt, ...)
     __attribute__((format(printf,4,5)));
 #endif
 
 static int solver_elim(struct solver_usage *usage, int *indices
 #ifdef STANDALONE_SOLVER
-                       , char *fmt, ...
+                       , const char *fmt, ...
 #endif
                        )
 {
@@ -907,7 +908,7 @@
 static int solver_intersect(struct solver_usage *usage,
                             int *indices1, int *indices2
 #ifdef STANDALONE_SOLVER
-                            , char *fmt, ...
+                            , const char *fmt, ...
 #endif
                             )
 {
@@ -985,7 +986,7 @@
                       struct solver_scratch *scratch,
                       int *indices
 #ifdef STANDALONE_SOLVER
-                      , char *fmt, ...
+                      , const char *fmt, ...
 #endif
                       )
 {
@@ -1351,7 +1352,7 @@
 						  (ondiag1(yt*cr+xt) && ondiag1(y*cr+x)))))) {
 #ifdef STANDALONE_SOLVER
                                 if (solver_show_working) {
-                                    char *sep = "";
+                                    const char *sep = "";
                                     int xl, yl;
                                     printf("%*sforcing chain, %d at ends of ",
                                            solver_recurse_depth*4, "", orign);
@@ -2516,7 +2517,7 @@
 
 #ifdef STANDALONE_SOLVER
 	    if (solver_show_working) {
-		char *sep = "";
+		const char *sep = "";
 		printf("%*srecursing on (%d,%d) [",
 		       solver_recurse_depth*4, "", x + 1, y + 1);
 		for (i = 0; i < j; i++) {
@@ -3154,7 +3155,8 @@
 static char *encode_solve_move(int cr, digit *grid)
 {
     int i, len;
-    char *ret, *p, *sep;
+    char *ret, *p;
+    const char *sep;
 
     /*
      * It's surprisingly easy to work out _exactly_ how long this
--- a/tents.c
+++ b/tents.c
@@ -1561,7 +1561,8 @@
     if ((IS_MOUSE_DRAG(button) || IS_MOUSE_RELEASE(button)) &&
         ui->drag_button > 0) {
         int xmin, ymin, xmax, ymax;
-        char *buf, *sep;
+        char *buf;
+        const char *sep;
         int buflen, bufsize, tmplen;
 
         x = FROMCOORD(x);
--- a/twiddle.c
+++ b/twiddle.c
@@ -80,9 +80,9 @@
 static int game_fetch_preset(int i, char **name, game_params **params)
 {
     static struct {
-        char *title;
+        const char *title;
         game_params params;
-    } presets[] = {
+    } const presets[] = {
         { "3x3 rows only", { 3, 3, 2, TRUE, FALSE } },
         { "3x3 normal", { 3, 3, 2, FALSE, FALSE } },
         { "3x3 orientable", { 3, 3, 2, FALSE, TRUE } },
--- a/unequal.c
+++ b/unequal.c
@@ -1195,12 +1195,12 @@
 }
 
 static game_state *load_game(const game_params *params, const char *desc,
-                             char **why_r)
+                             const char **why_r)
 {
     game_state *state = blank_game(params->order, params->adjacent);
     const char *p = desc;
     int i = 0, n, o = params->order, x, y;
-    char *why = NULL;
+    const char *why = NULL;
 
     while (*p) {
         while (*p >= 'a' && *p <= 'z') {
@@ -1293,7 +1293,7 @@
 
 static const char *validate_desc(const game_params *params, const char *desc)
 {
-    char *why = NULL;
+    const char *why = NULL;
     game_state *dummy = load_game(params, desc, &why);
     if (dummy) {
         free_game(dummy);
--- a/windows.c
+++ b/windows.c
@@ -1551,7 +1551,7 @@
     return fe;
 }
 
-static void savefile_write(void *wctx, void *buf, int len)
+static void savefile_write(void *wctx, const void *buf, int len)
 {
     FILE *fp = (FILE *)wctx;
     fwrite(buf, 1, len, fp);