From bb1432c0ad0ba2955df9483dde67a987fb946ed8 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 11 Dec 2021 11:28:36 +0000 Subject: [PATCH] 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(). --- gtk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk.c b/gtk.c index 7710b4e..c3ab732 100644 --- a/gtk.c +++ b/gtk.c @@ -3578,7 +3578,6 @@ static void list_presets_from_menu(struct preset_menu *menu) 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 @@ int main(int argc, char **argv) } else { frontend *fe; bool headless = screenshot_file != NULL; + char *error = NULL; if (!headless) gtk_init(&argc, &argv);