From: Paolo Bonzini <pbonzini@redhat.com>
To: "Radim Krčmář" <rkrcmar@redhat.com>, qemu-devel@nongnu.org
Cc: Michael Walle <michael@walle.cc>
Subject: Re: [Qemu-devel] [PATCH 1/2] fix GCC 5.0.0 logical-not-parentheses warnings
Date: Fri, 20 Feb 2015 15:38:06 +0100 [thread overview]
Message-ID: <54E746CE.7020409@redhat.com> (raw)
In-Reply-To: <1424441905-5735-2-git-send-email-rkrcmar@redhat.com>
On 20/02/2015 15:18, Radim Krčmář wrote:
> man gcc:
> Warn about logical not used on the left hand side operand of a
> comparison. This option does not warn if the RHS operand is of a
> boolean type.
>
> By preferring bool over int where sensible, but without modifying any
> depending code, make GCC happy in cases like this,
> qemu-img.c: In function ‘compare_sectors’:
> qemu-img.c:992:39: error: logical not is only applied to the left hand
> side of comparison [-Werror=logical-not-parentheses]
> if (!!memcmp(buf1, buf2, 512) != res) {
>
> hw/ide/core.c:1836 doesn't throw an error,
> assert(!!s->error == !!(s->status & ERR_STAT));
> even thought the second operand is int (and first hunk of this patch has
> a very similar case), maybe GCC developers still have a little faith in
> C programmers.
>
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
> hw/net/virtio-net.c | 2 +-
> kvm-all.c | 2 +-
> qemu-img.c | 3 ++-
> 3 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 45da34ad6129..ee234c963b6e 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -120,7 +120,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> return;
> }
>
> - if (!!n->vhost_started ==
> + if ((!!n->vhost_started) ==
> (virtio_net_started(n, status) && !nc->peer->link_down)) {
Does it still break if you just swap the terms?
Paolo
> return;
> }
> diff --git a/kvm-all.c b/kvm-all.c
> index 05a79c20e0bb..07ef62cb3227 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -366,7 +366,7 @@ static void kvm_log_stop(MemoryListener *listener,
> }
> }
>
> -static int kvm_set_migration_log(int enable)
> +static int kvm_set_migration_log(bool enable)
> {
> KVMState *s = kvm_state;
> KVMSlot *mem;
> diff --git a/qemu-img.c b/qemu-img.c
> index e148af8a3e64..21fff2ad53d5 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -977,7 +977,8 @@ static int is_allocated_sectors_min(const uint8_t *buf, int n, int *pnum,
> static int compare_sectors(const uint8_t *buf1, const uint8_t *buf2, int n,
> int *pnum)
> {
> - int res, i;
> + bool res;
> + int i;
>
> if (n <= 0) {
> *pnum = 0;
>
next prev parent reply other threads:[~2015-02-20 14:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 14:18 [Qemu-devel] [PATCH 0/2] Fix GCC 5.0.0 build errors Radim Krčmář
2015-02-20 14:18 ` [Qemu-devel] [PATCH 1/2] fix GCC 5.0.0 logical-not-parentheses warnings Radim Krčmář
2015-02-20 14:38 ` Paolo Bonzini [this message]
2015-02-20 15:43 ` Radim Krčmář
2015-02-20 14:18 ` [Qemu-devel] [PATCH 2/2] milkymist-pfpu: fix GCC 5.0.0 aggressive-loop-optimizations warning Radim Krčmář
2015-02-20 14:24 ` Radim Krčmář
2015-02-20 14:36 ` Paolo Bonzini
2015-02-20 14:52 ` Michael Walle
2015-02-20 14:55 ` Paolo Bonzini
2015-02-20 15:48 ` Radim Krčmář
2015-02-20 14:40 ` Peter Maydell
2015-02-20 15:37 ` Radim Krčmář
2015-02-20 16:10 ` Michael Walle
-- strict thread matches above, loose matches on Subject: below --
2015-02-20 16:06 [Qemu-devel] [PATCH 0/2] Fix GCC 5.0.0 build errors Radim Krčmář
2015-02-20 16:06 ` [Qemu-devel] [PATCH 1/2] fix GCC 5.0.0 logical-not-parentheses warnings Radim Krčmář
2015-03-04 14:36 ` Michael Tokarev
2015-03-04 16:27 ` Radim Krčmář
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=54E746CE.7020409@redhat.com \
--to=pbonzini@redhat.com \
--cc=michael@walle.cc \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@redhat.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).