qemu-patch-raspberry4/hw/misc
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
..
macio maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
a9scu.c
applesmc.c
arm11scu.c
arm_integrator_debug.c
arm_l2x0.c
arm_sysctl.c
aspeed_scu.c hw/arm/aspeed: Unlock SCU when running kernel 2017-11-20 13:47:49 +00:00
aspeed_sdmc.c
auxbus.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
bcm2835_mbox.c
bcm2835_property.c
bcm2835_rng.c
cbus.c
debugexit.c
eccmemctl.c
edu.c pci: Add INTERFACE_CONVENTIONAL_PCI_DEVICE to Conventional PCI devices 2017-10-15 05:54:43 +03:00
exynos4210_clk.c
exynos4210_pmu.c
exynos4210_rng.c
hyperv_testdev.c
imx6_ccm.c Remove empty statements 2017-12-18 17:07:02 +03:00
imx6_src.c
imx25_ccm.c
imx31_ccm.c
imx_ccm.c
ivshmem.c misc: remove old i386 dependency 2017-12-18 17:07:02 +03:00
Makefile.objs i386/pc: move vmport.c to hw/i386/ 2017-12-18 17:07:02 +03:00
max111x.c
milkymist-hpdmc.c
milkymist-pfpu.c
mips_cmgcr.c
mips_cpc.c
mips_itu.c
mmio_interface.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
mps2-scc.c
msf2-sysreg.c
mst_fpga.c
omap_clk.c
omap_gpmc.c
omap_l4.c
omap_sdrc.c
omap_tap.c
pc-testdev.c
pci-testdev.c pci: Add INTERFACE_CONVENTIONAL_PCI_DEVICE to Conventional PCI devices 2017-10-15 05:54:43 +03:00
puv3_pm.c
pvpanic.c hw/misc/pvpanic: extract public API from i386/pc to "hw/misc/pvpanic.h" 2017-12-18 17:07:02 +03:00
sga.c misc: remove old i386 dependency 2017-12-18 17:07:02 +03:00
slavio_misc.c
stm32f2xx_syscfg.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
tmp105.c
tmp105.h
tmp421.c
trace-events
unimp.c
vmcoreinfo.c dump-guest-memory.py: fix "You can't do that without a process to debug" 2018-01-02 14:49:54 +01:00
zynq-xadc.c
zynq_slcr.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00