From c0271533d012f7928169ff17c42ba25365c66eea Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Sun, 10 Jul 2016 11:00:57 +0200 Subject: [PATCH] terminal: Silence maybe-uninitialized warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clients/terminal.c: In function 'redraw_handler': clients/terminal.c:213:28: warning: 'machine.unicode' may be used uninitialized in this function [-Wmaybe-uninitialized] struct utf8_state_machine machine; ^~~~~~~ clients/terminal.c: In function 'handle_char': clients/terminal.c:213:28: warning: 'machine.unicode' may be used uninitialized in this function [-Wmaybe-uninitialized] Warning produced by GCC 5.3 and 6.1, with -O3. 'I found it weird that the compiler wouldn’t see that, so I re-checked the code. I think with -O3, this specific "for" is compile-time unlooped, and utf8_next_char inlined. And there is *one* path that can keep machine.state to utf8state_start, thus triggering the warning. Without -O3, the function is globally tagged as “changing unicode”, so no warning is produced. [...] Side note: I picked 0 as the default value, but maybe in this case 0xfffd would be better?' Signed-off-by: Quentin Glidic Acked-by: Emil Velikov --- clients/terminal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/terminal.c b/clients/terminal.c index 6257cb7d..c8ea239f 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -124,6 +124,7 @@ init_state_machine(struct utf8_state_machine *machine) machine->state = utf8state_start; machine->len = 0; machine->s.ch = 0; + machine->unicode = 0; } static enum utf8_state