shithub: puzzles

Download patch

ref: bb1432c0ad0ba2955df9483dde67a987fb946ed8
parent: 57fbcd2b29aa74423d47a9efd783a1508ab1bfc5
author: Simon Tatham <anakin@pobox.com>
date: Sat Dec 11 06:28:36 EST 2021

gtk.c: squelch uninitialised-variable warning.

Apparently some compilers can't work out that new_window() will always
write to its error-message parameter if it returns failure, so they
complain at the call site that 'error' might be used uninitialised.

Fix by explicitly initialising it. (To NULL, which really _shouldn't_
stop the compiler from warning, because surely that's just as bad if
it reaches the following printf!)

Also, while I'm at it, move it into the block where it's used, so it
doesn't look as if it might pervade the whole of main().

--- a/gtk.c
+++ b/gtk.c
@@ -3578,7 +3578,6 @@
 int main(int argc, char **argv)
 {
     char *pname = argv[0];
-    char *error;
     int ngenerate = 0, px = 1, py = 1;
     bool print = false;
     bool time_generation = false, test_solve = false, list_presets = false;
@@ -3991,6 +3990,7 @@
     } else {
 	frontend *fe;
         bool headless = screenshot_file != NULL;
+        char *error = NULL;
 
         if (!headless)
             gtk_init(&argc, &argv);