shithub: puzzles

Download patch

ref: 26c7f3aa285a45176c940afebe3885ad2be2ed65
parent: 3c3468355f8cf3dd644058ab239b948f8facebfa
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sat Feb 18 18:14:12 EST 2023

Miscellaneous const fixes

These are cases where -Wcast-qual complained and the only change needed
was to add or remove a "const" (or sometimes an entire cast).

--- a/loopy.c
+++ b/loopy.c
@@ -1370,7 +1370,7 @@
 {
     bool ret;
     solver_state *sstate_new;
-    solver_state *sstate = new_solver_state((game_state *)state, diff);
+    solver_state *sstate = new_solver_state(state, diff);
 
     sstate_new = solve_game_rec(sstate);
 
--- a/magnets.c
+++ b/magnets.c
@@ -551,7 +551,7 @@
 {
     const char *prob;
     game_state *st = new_game_int(params, desc, &prob);
-    if (!st) return (char*)prob;
+    if (!st) return prob;
     free_game(st);
     return NULL;
 }
@@ -2590,7 +2590,7 @@
     sfree(aux);
 }
 
-int main(int argc, const char *argv[])
+int main(int argc, char *argv[])
 {
     bool print = false, soak = false, solved = false;
     int ret;
--- a/random.c
+++ b/random.c
@@ -109,7 +109,7 @@
 
 void SHA_Bytes(SHA_State * s, const void *p, int len)
 {
-    unsigned char *q = (unsigned char *) p;
+    const unsigned char *q = (const unsigned char *) p;
     uint32 wordblock[16];
     uint32 lenw = len;
     int i;
--- a/signpost.c
+++ b/signpost.c
@@ -1031,8 +1031,8 @@
 
 static int compare_heads(const void *a, const void *b)
 {
-    struct head_meta *ha = (struct head_meta *)a;
-    struct head_meta *hb = (struct head_meta *)b;
+    const struct head_meta *ha = (const struct head_meta *)a;
+    const struct head_meta *hb = (const struct head_meta *)b;
 
     /* Heads with preferred colours first... */
     if (ha->preference && !hb->preference) return -1;
@@ -2421,7 +2421,7 @@
     thegame.free_params(p);
 }
 
-int main(int argc, const char *argv[])
+int main(int argc, char *argv[])
 {
     char *id = NULL, *desc, *aux = NULL;
     const char *err;
--- a/untangle.c
+++ b/untangle.c
@@ -444,8 +444,8 @@
 
 static int vertcmpC(const void *av, const void *bv)
 {
-    const vertex *a = (vertex *)av;
-    const vertex *b = (vertex *)bv;
+    const vertex *a = (const vertex *)av;
+    const vertex *b = (const vertex *)bv;
 
     if (a->param < b->param)
 	return -1;