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().
This commit is contained in:
Simon Tatham
2021-12-11 11:28:36 +00:00
parent 57fbcd2b29
commit bb1432c0ad

2
gtk.c
View File

@ -3578,7 +3578,6 @@ static void list_presets_from_menu(struct preset_menu *menu)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char *pname = argv[0]; char *pname = argv[0];
char *error;
int ngenerate = 0, px = 1, py = 1; int ngenerate = 0, px = 1, py = 1;
bool print = false; bool print = false;
bool time_generation = false, test_solve = false, list_presets = false; bool time_generation = false, test_solve = false, list_presets = false;
@ -3991,6 +3990,7 @@ int main(int argc, char **argv)
} else { } else {
frontend *fe; frontend *fe;
bool headless = screenshot_file != NULL; bool headless = screenshot_file != NULL;
char *error = NULL;
if (!headless) if (!headless)
gtk_init(&argc, &argv); gtk_init(&argc, &argv);