qemu/hw/block
Eric Blake 2562755ee7 maint: Fix macros with broken 'do/while(0); ' usage
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>
2018-01-16 14:54:52 +01:00
..
dataplane hw/block: Fix the return type 2017-12-19 09:25:28 +00:00
block.c hw/block: Fix the return type 2017-12-19 09:25:28 +00:00
cdrom.c block: Clean up includes 2016-01-20 13:36:23 +01:00
ecc.c block: Clean up includes 2016-01-20 13:36:23 +01:00
fdc.c hw/block: Use errp directly rather than local_err 2017-12-19 10:25:03 +00:00
hd-geometry.c qemu-common: stop including qemu/bswap.h from qemu-common.h 2016-05-19 16:42:28 +02:00
m25p80.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
Makefile.objs xen: do not build backends for targets that do not support xen 2017-03-19 11:12:12 +01:00
nand.c migration: pre_save return int 2017-09-27 11:35:59 +01:00
nvme.c nvme: Add tracing 2017-12-22 15:03:41 +01:00
nvme.h nvme: Add support for Read Data and Write Data in CMBs. 2017-06-26 14:51:13 +02:00
onenand.c hw/block/onenand: Remove dead code block 2017-10-06 16:28:58 +02:00
pflash_cfi01.c hw/block/pflash_cfi01, pflash_cfi02: Use memory_region_init_rom_device() 2017-07-14 17:59:42 +01:00
pflash_cfi02.c hw/block/pflash_cfi01, pflash_cfi02: Use memory_region_init_rom_device() 2017-07-14 17:59:42 +01:00
tc58128.c block: Use DIV_ROUND_UP 2016-06-07 18:19:24 +03:00
trace-events nvme: Add tracing 2017-12-22 15:03:41 +01:00
virtio-blk.c virtio-blk: reject configs with logical block size > physical block size 2017-12-19 10:25:09 +00:00
xen_blkif.h xen: import ring.h from xen 2017-04-21 12:41:29 -07:00
xen_disk.c xen-disk: use an IOThread per instance 2017-12-14 15:24:22 -08:00