From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOq63-0006XU-1A for qemu-devel@nongnu.org; Fri, 20 Feb 2015 11:06:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOq62-0007Tj-2i for qemu-devel@nongnu.org; Fri, 20 Feb 2015 11:06:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOq61-0007St-Ij for qemu-devel@nongnu.org; Fri, 20 Feb 2015 11:06:29 -0500 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Fri, 20 Feb 2015 17:06:15 +0100 Message-Id: <1424448376-15599-2-git-send-email-rkrcmar@redhat.com> In-Reply-To: <1424448376-15599-1-git-send-email-rkrcmar@redhat.com> References: <1424448376-15599-1-git-send-email-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [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: qemu-devel@nongnu.org Cc: Paolo Bonzini , Michael Walle , Peter Maydell 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 =E2=80=98compare_sectors=E2=80=99: qemu-img.c:992:39: error: logical not is only applied to the left hand side of comparison [-Werror=3Dlogical-not-parentheses] if (!!memcmp(buf1, buf2, 512) !=3D res) { hw/ide/core.c:1836 doesn't throw an error, assert(!!s->error =3D=3D !!(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=C4=8Dm=C3=A1=C5=99 --- v2: swapped lines in hunk 1 to to avoid parentheses [Paolo] hw/net/virtio-net.c | 4 ++-- kvm-all.c | 2 +- qemu-img.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 45da34ad6129..93818675588e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -120,8 +120,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uin= t8_t status) return; } =20 - if (!!n->vhost_started =3D=3D - (virtio_net_started(n, status) && !nc->peer->link_down)) { + if ((virtio_net_started(n, status) && !nc->peer->link_down) =3D=3D + !!n->vhost_started) { return; } if (!n->vhost_started) { 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, } } =20 -static int kvm_set_migration_log(int enable) +static int kvm_set_migration_log(bool enable) { KVMState *s =3D 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 *bu= f, 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; =20 if (n <=3D 0) { *pnum =3D 0; --=20 2.3.0