From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOoic-0003R8-HH for qemu-devel@nongnu.org; Fri, 20 Feb 2015 09:38:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOoiY-0004u1-GH for qemu-devel@nongnu.org; Fri, 20 Feb 2015 09:38:14 -0500 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:49012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOoiY-0004tv-98 for qemu-devel@nongnu.org; Fri, 20 Feb 2015 09:38:10 -0500 Received: by mail-wg0-f53.google.com with SMTP id a1so13437508wgh.12 for ; Fri, 20 Feb 2015 06:38:09 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54E746CE.7020409@redhat.com> Date: Fri, 20 Feb 2015 15:38:06 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1424441905-5735-1-git-send-email-rkrcmar@redhat.com> <1424441905-5735-2-git-send-email-rkrcmar@redhat.com> In-Reply-To: <1424441905-5735-2-git-send-email-rkrcmar@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/2] fix GCC 5.0.0 logical-not-parentheses warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , qemu-devel@nongnu.org Cc: Michael Walle 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ář > --- > 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; >