qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
	Gerd Hoffmann <kraxel@redhat.com>,
	Alistair Francis <alistair@alistair23.me>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Alexander Graf <agraf@suse.de>, Jason Wang <jasowang@redhat.com>,
	Subbaraya Sundeep <sundeep.lkml@gmail.com>,
	Stefan Berger <stefanb@linux.vnet.ibm.com>,
	Juan Quintela <quintela@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Richard Henderson <rth@twiddle.net>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	"open list:Xilinx Zynq" <qemu-arm@nongnu.org>,
	"open list:New World" <qemu-ppc@nongnu.org>,
	"open list:S390" <qemu-s390x@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 3/3] maint: Fix macros with broken 'do/while(0); ' usage
Date: Thu, 30 Nov 2017 14:54:46 +0100	[thread overview]
Message-ID: <20171130145446.3d47b906.cohuck@redhat.com> (raw)
In-Reply-To: <20171130134159.9697-4-eblake@redhat.com>

On Thu, 30 Nov 2017 07:41:59 -0600
Eric Blake <eblake@redhat.com> wrote:

> The point of writing a macro embedded in a 'do { ... } while (0)'
> loop 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;
> the use of do/while (0) in a macro is absolutely essential for the
> purpose of avoiding a syntax error on the 'else' - but it only works
> if there is no trailing ';' in the macro (as the ';' in the code
> calling the macro would then be a second statement and cause the
> 'else' to not pair to the 'if').
> 
> Many of the places touched in this code are examples of the ugly
> bit-rotting debug print statements; cleaning those up is left as
> a bite-sized task for another day.
> 
> Found mechanically via: $ git grep -B1 'while (0);' | grep -A1 \\\\
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/acpi-utils.h         | 8 ++++----
>  ui/sdl_zoom_template.h     | 8 ++++----
>  audio/paaudio.c            | 4 ++--
>  hw/adc/stm32f2xx_adc.c     | 2 +-
>  hw/block/m25p80.c          | 2 +-
>  hw/char/cadence_uart.c     | 2 +-
>  hw/char/stm32f2xx_usart.c  | 2 +-
>  hw/display/cg3.c           | 2 +-
>  hw/display/dpcd.c          | 2 +-
>  hw/display/xlnx_dp.c       | 2 +-
>  hw/dma/pl330.c             | 2 +-
>  hw/dma/xlnx-zynq-devcfg.c  | 2 +-
>  hw/dma/xlnx_dpdma.c        | 2 +-
>  hw/i2c/i2c-ddc.c           | 2 +-
>  hw/misc/auxbus.c           | 2 +-
>  hw/misc/macio/mac_dbdma.c  | 4 ++--
>  hw/misc/mmio_interface.c   | 2 +-
>  hw/misc/stm32f2xx_syscfg.c | 2 +-
>  hw/misc/zynq_slcr.c        | 2 +-
>  hw/net/cadence_gem.c       | 2 +-
>  hw/ssi/mss-spi.c           | 2 +-
>  hw/ssi/stm32f2xx_spi.c     | 2 +-
>  hw/ssi/xilinx_spi.c        | 2 +-
>  hw/ssi/xilinx_spips.c      | 2 +-
>  hw/timer/a9gtimer.c        | 2 +-
>  hw/timer/cadence_ttc.c     | 2 +-
>  hw/timer/mss-timer.c       | 2 +-
>  hw/timer/stm32f2xx_timer.c | 2 +-
>  hw/tpm/tpm_passthrough.c   | 2 +-
>  hw/tpm/tpm_tis.c           | 2 +-
>  migration/rdma.c           | 2 +-
>  target/arm/translate-a64.c | 2 +-
>  target/s390x/kvm.c         | 2 +-
>  tests/tcg/test-mmap.c      | 2 +-
>  34 files changed, 42 insertions(+), 42 deletions(-)

> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index b03f583032..06d06010a4 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -58,7 +58,7 @@
>      if (DEBUG_KVM) {                          \
>          fprintf(stderr, fmt, ## __VA_ARGS__); \
>      }                                         \
> -} while (0);
> +} while (0)
> 
>  #define kvm_vm_check_mem_attr(s, attr) \
>      kvm_vm_check_attr(s, KVM_S390_VM_MEM_CTRL, attr)

Acked-by: Cornelia Huck <cohuck@redhat.com>

  reply	other threads:[~2017-11-30 13:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 13:41 [Qemu-devel] [PATCH 0/3] macro do/while (0) cleanup Eric Blake
2017-11-30 13:41 ` [Qemu-devel] [PATCH 1/3] net: Drop unusual use of do { } while (0); Eric Blake
2017-11-30 16:08   ` Thomas Huth
2017-11-30 13:41 ` [Qemu-devel] [PATCH 2/3] mips: Tweak location of ';' in macros Eric Blake
2017-11-30 15:33   ` Philippe Mathieu-Daudé
2017-11-30 13:41 ` [Qemu-devel] [PATCH 3/3] maint: Fix macros with broken 'do/while(0); ' usage Eric Blake
2017-11-30 13:54   ` Cornelia Huck [this message]
2017-11-30 14:43   ` Michael S. Tsirkin
2017-11-30 14:55     ` Eric Blake
2017-11-30 14:56   ` Dr. David Alan Gilbert
2017-12-04  0:45   ` [Qemu-devel] [Qemu-ppc] " David Gibson
2017-11-30 14:01 ` [Qemu-devel] [PATCH 4/3] checkpatch: Enforce proper do/while (0) style Eric Blake
2017-11-30 17:00   ` Eric Blake
2017-12-01  7:31     ` Markus Armbruster
2017-12-01 14:22       ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171130145446.3d47b906.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=agraf@suse.de \
    --cc=alistair@alistair23.me \
    --cc=borntraeger@de.ibm.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=rth@twiddle.net \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=sundeep.lkml@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).