mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-24 00:18:36 -07:00
The point of writing a macro embedded in a 'do { ... } while (0)'
loop (particularly if the macro has multiple statements or would
otherwise end with an 'if' statement) is so that the macro can be
used as a drop-in statement with the caller supplying the
trailing ';'. Although our coding style frowns on brace-less 'if':
if (cond)
statement;
else
something else;
that is the classic case where failure to use do/while(0) wrapping
would cause the 'else' to pair with any embedded 'if' in the macro
rather than the intended outer 'if'. But conversely, if the macro
includes an embedded ';', then the same brace-less coding style
would now have two statements, making the 'else' a syntax error
rather than pairing with the outer 'if'. Thus, even though our
coding style with required braces is not impacted, ending a macro
with ';' makes our code harder to port to projects that use
brace-less styles.
The change should have no semantic impact. I was not able to
fully compile-test all of the changes (as some of them are
examples of the ugly bit-rotting debug print statements that are
completely elided by default, and I didn't want to recompile
with the necessary -D witnesses - cleaning those up is left as a
bite-sized task for another day); I did, however, audit that for
all files touched, all callers of the changed macros DID supply
a trailing ';' at the callsite, and did not appear to be used
as part of a brace-less conditional.
Found mechanically via: $ git grep -B1 'while (0);' | grep -A1 \\\\
Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20171201232433.25193-7-eblake@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
||
|---|---|---|
| .. | ||
| keycodemapdb@10739aa260 | ||
| shader | ||
| cocoa.m | ||
| console-gl.c | ||
| console.c | ||
| curses.c | ||
| curses_keys.h | ||
| cursor.c | ||
| cursor_hidden.xpm | ||
| cursor_left_ptr.xpm | ||
| egl-context.c | ||
| egl-headless.c | ||
| egl-helpers.c | ||
| gtk-egl.c | ||
| gtk-gl-area.c | ||
| gtk.c | ||
| input-keymap.c | ||
| input-legacy.c | ||
| input-linux.c | ||
| input.c | ||
| keymaps.c | ||
| keymaps.h | ||
| Makefile.objs | ||
| qemu-pixman.c | ||
| qemu-x509.h | ||
| sdl.c | ||
| sdl2-2d.c | ||
| sdl2-gl.c | ||
| sdl2-input.c | ||
| sdl2-keymap.h | ||
| sdl2.c | ||
| sdl_keysym.h | ||
| sdl_zoom.c | ||
| sdl_zoom.h | ||
| sdl_zoom_template.h | ||
| shader.c | ||
| spice-core.c | ||
| spice-display.c | ||
| spice-input.c | ||
| trace-events | ||
| vgafont.h | ||
| vnc-auth-sasl.c | ||
| vnc-auth-sasl.h | ||
| vnc-auth-vencrypt.c | ||
| vnc-auth-vencrypt.h | ||
| vnc-enc-hextile-template.h | ||
| vnc-enc-hextile.c | ||
| vnc-enc-tight.c | ||
| vnc-enc-tight.h | ||
| vnc-enc-zlib.c | ||
| vnc-enc-zrle-template.c | ||
| vnc-enc-zrle.c | ||
| vnc-enc-zrle.h | ||
| vnc-enc-zywrle-template.c | ||
| vnc-enc-zywrle.h | ||
| vnc-jobs.c | ||
| vnc-jobs.h | ||
| vnc-palette.c | ||
| vnc-palette.h | ||
| vnc-ws.c | ||
| vnc-ws.h | ||
| vnc.c | ||
| vnc.h | ||
| vnc_keysym.h | ||
| x_keymap.c | ||
| x_keymap.h | ||