mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 08:48:00 +02:00
terminal: Silence maybe-uninitialized warning
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 <sardemff7+git@sardemff7.net>
Acked-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
parent
df84dbe382
commit
c0271533d0
1 changed files with 1 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue