From: David Gibson <david@gibson.dropbear.id.au>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Subbaraya Sundeep <sundeep.lkml@gmail.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
Stefan Berger <stefanb@linux.vnet.ibm.com>,
qemu-trivial@nongnu.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
Alistair Francis <alistair@alistair23.me>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"open list:S390" <qemu-s390x@nongnu.org>,
"open list:Xilinx Zynq" <qemu-arm@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Kevin Wolf <kwolf@redhat.com>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Cornelia Huck <cohuck@redhat.com>, Max Reitz <mreitz@redhat.com>,
"open list:New World" <qemu-ppc@nongnu.org>,
Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-ppc] [PATCH 3/3] maint: Fix macros with broken 'do/while(0); ' usage
Date: Mon, 4 Dec 2017 11:45:26 +1100 [thread overview]
Message-ID: <20171204004526.GE2130@umbus.fritz.box> (raw)
In-Reply-To: <20171130134159.9697-4-eblake@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]
On Thu, Nov 30, 2017 at 07:41:59AM -0600, Eric Blake 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>
ppc related portions
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <david@gibson.dropbear.id.au>
To: Eric Blake <eblake@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>,
Stefan Berger <stefanb@linux.vnet.ibm.com>,
Max Reitz <mreitz@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
Juan Quintela <quintela@redhat.com>,
qemu-trivial@nongnu.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
Alistair Francis <alistair@alistair23.me>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"open list:S390" <qemu-s390x@nongnu.org>,
"open list:Xilinx Zynq" <qemu-arm@nongnu.org>,
Igor Mammedov <imammedo@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Kevin Wolf <kwolf@redhat.com>, Cornelia Huck <cohuck@redhat.com>,
Subbaraya Sundeep <sundeep.lkml@gmail.com>,
"open list:New World" <qemu-ppc@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-arm] [Qemu-ppc] [PATCH 3/3] maint: Fix macros with broken 'do/while(0); ' usage
Date: Mon, 4 Dec 2017 11:45:26 +1100 [thread overview]
Message-ID: <20171204004526.GE2130@umbus.fritz.box> (raw)
In-Reply-To: <20171130134159.9697-4-eblake@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]
On Thu, Nov 30, 2017 at 07:41:59AM -0600, Eric Blake 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>
ppc related portions
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <david@gibson.dropbear.id.au>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Subbaraya Sundeep <sundeep.lkml@gmail.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
Stefan Berger <stefanb@linux.vnet.ibm.com>,
qemu-trivial@nongnu.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
Alistair Francis <alistair@alistair23.me>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"open list:S390" <qemu-s390x@nongnu.org>,
"open list:Xilinx Zynq" <qemu-arm@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Kevin Wolf <kwolf@redhat.com>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Cornelia Huck <cohuck@redhat.com>, Max Reitz <mreitz@redhat.com>,
"open list:New World" <qemu-ppc@nongnu.org>,
Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 3/3] maint: Fix macros with broken 'do/while(0); ' usage
Date: Mon, 4 Dec 2017 11:45:26 +1100 [thread overview]
Message-ID: <20171204004526.GE2130@umbus.fritz.box> (raw)
In-Reply-To: <20171130134159.9697-4-eblake@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]
On Thu, Nov 30, 2017 at 07:41:59AM -0600, Eric Blake 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>
ppc related portions
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-12-04 1:08 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 13:41 [Qemu-trivial] [PATCH 0/3] macro do/while (0) cleanup Eric Blake
2017-11-30 13:41 ` [Qemu-devel] " Eric Blake
2017-11-30 13:41 ` [Qemu-trivial] [PATCH 1/3] net: Drop unusual use of do { } while (0); Eric Blake
2017-11-30 13:41 ` [Qemu-devel] " Eric Blake
2017-11-30 16:08 ` [Qemu-trivial] " Thomas Huth
2017-11-30 16:08 ` Thomas Huth
2017-11-30 13:41 ` [Qemu-trivial] [PATCH 2/3] mips: Tweak location of ';' in macros Eric Blake
2017-11-30 13:41 ` [Qemu-devel] " Eric Blake
2017-11-30 15:33 ` [Qemu-trivial] [Qemu-devel] [PATCH 2/3] mips: Tweak location of '; ' " Philippe Mathieu-Daudé
2017-11-30 15:33 ` [Qemu-devel] [PATCH 2/3] mips: Tweak location of ';' " Philippe Mathieu-Daudé
2017-11-30 13:41 ` [Qemu-trivial] [PATCH 3/3] maint: Fix macros with broken 'do/while(0); ' usage Eric Blake
2017-11-30 13:41 ` [Qemu-devel] " Eric Blake
2017-11-30 13:41 ` [Qemu-arm] " Eric Blake
2017-11-30 13:54 ` [Qemu-trivial] " Cornelia Huck
2017-11-30 13:54 ` [Qemu-devel] " Cornelia Huck
2017-11-30 13:54 ` [Qemu-arm] " Cornelia Huck
2017-11-30 14:43 ` [Qemu-trivial] " Michael S. Tsirkin
2017-11-30 14:43 ` [Qemu-devel] " Michael S. Tsirkin
2017-11-30 14:43 ` [Qemu-arm] " Michael S. Tsirkin
2017-11-30 14:55 ` [Qemu-trivial] " Eric Blake
2017-11-30 14:55 ` [Qemu-devel] " Eric Blake
2017-11-30 14:55 ` [Qemu-arm] " Eric Blake
2017-11-30 14:56 ` [Qemu-trivial] " Dr. David Alan Gilbert
2017-11-30 14:56 ` [Qemu-devel] " Dr. David Alan Gilbert
2017-11-30 14:56 ` [Qemu-arm] " Dr. David Alan Gilbert
2017-12-04 0:45 ` David Gibson [this message]
2017-12-04 0:45 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2017-12-04 0:45 ` [Qemu-arm] " David Gibson
2017-11-30 14:01 ` [Qemu-trivial] [PATCH 4/3] checkpatch: Enforce proper do/while (0) style Eric Blake
2017-11-30 14:01 ` [Qemu-devel] " Eric Blake
2017-11-30 17:00 ` [Qemu-trivial] " Eric Blake
2017-11-30 17:00 ` Eric Blake
2017-12-01 7:31 ` [Qemu-trivial] " Markus Armbruster
2017-12-01 7:31 ` Markus Armbruster
2017-12-01 14:22 ` [Qemu-trivial] " Eric Blake
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=20171204004526.GE2130@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=alistair@alistair23.me \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=crosthwaite.peter@gmail.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.