From: Paolo Bonzini <pbonzini@redhat.com>
To: "Richard W.M. Jones" <rjones@redhat.com>, qemu-trivial@nongnu.org
Cc: lersek@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com
Subject: Re: [Qemu-trivial] [PATCH] Fix comparisons between implicit booleans and integers.
Date: Fri, 30 Jan 2015 13:13:39 +0100 [thread overview]
Message-ID: <54CB7573.2040607@redhat.com> (raw)
In-Reply-To: <1422618777-8832-1-git-send-email-rjones@redhat.com>
On 30/01/2015 12:52, Richard W.M. Jones wrote:
> In GCC 5 there is a new warning (-Wlogical-not-parentheses) which
> prevents you from writing:
>
> if (<some implicitly boolean expression> == <an int>) ...
>
> A typical error would be:
>
> kvm-all.c: In function ‘kvm_set_migration_log’:
> kvm-all.c:383:54: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
> if (!!(mem->flags & KVM_MEM_LOG_DIRTY_PAGES) == enable) {
>
> Fix a few places where the build is now broken in GCC 5.
>
> The warning isn't even consistent, as with the place in
> hw/net/virtio-net.c where I had to cast an obviously boolean
> expression to bool.
The other two places are fine cleanups, but really I would just suppress
the warning in configure...
Paolo
> Signed-off-by: Richard W.M. Jones <rjones@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 45da34a..ba6afb8 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -121,7 +121,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> }
>
> if (!!n->vhost_started ==
> - (virtio_net_started(n, status) && !nc->peer->link_down)) {
> + (bool) (virtio_net_started(n, status) && !nc->peer->link_down)) {
> return;
> }
> if (!n->vhost_started) {
> diff --git a/kvm-all.c b/kvm-all.c
> index 2f21a4e..b6d4387 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 4e9a7f5..acf70fa 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;
>
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Richard W.M. Jones" <rjones@redhat.com>, qemu-trivial@nongnu.org
Cc: lersek@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com
Subject: Re: [Qemu-devel] [PATCH] Fix comparisons between implicit booleans and integers.
Date: Fri, 30 Jan 2015 13:13:39 +0100 [thread overview]
Message-ID: <54CB7573.2040607@redhat.com> (raw)
In-Reply-To: <1422618777-8832-1-git-send-email-rjones@redhat.com>
On 30/01/2015 12:52, Richard W.M. Jones wrote:
> In GCC 5 there is a new warning (-Wlogical-not-parentheses) which
> prevents you from writing:
>
> if (<some implicitly boolean expression> == <an int>) ...
>
> A typical error would be:
>
> kvm-all.c: In function ‘kvm_set_migration_log’:
> kvm-all.c:383:54: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
> if (!!(mem->flags & KVM_MEM_LOG_DIRTY_PAGES) == enable) {
>
> Fix a few places where the build is now broken in GCC 5.
>
> The warning isn't even consistent, as with the place in
> hw/net/virtio-net.c where I had to cast an obviously boolean
> expression to bool.
The other two places are fine cleanups, but really I would just suppress
the warning in configure...
Paolo
> Signed-off-by: Richard W.M. Jones <rjones@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 45da34a..ba6afb8 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -121,7 +121,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
> }
>
> if (!!n->vhost_started ==
> - (virtio_net_started(n, status) && !nc->peer->link_down)) {
> + (bool) (virtio_net_started(n, status) && !nc->peer->link_down)) {
> return;
> }
> if (!n->vhost_started) {
> diff --git a/kvm-all.c b/kvm-all.c
> index 2f21a4e..b6d4387 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 4e9a7f5..acf70fa 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-01-30 12:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 11:52 [Qemu-trivial] [PATCH] Fix comparisons between implicit booleans and integers Richard W.M. Jones
2015-01-30 11:52 ` [Qemu-devel] " Richard W.M. Jones
2015-01-30 12:13 ` Paolo Bonzini [this message]
2015-01-30 12:13 ` Paolo Bonzini
2015-02-10 19:15 ` [Qemu-trivial] " Michael Tokarev
2015-02-10 19:15 ` [Qemu-devel] " Michael Tokarev
2015-02-10 19:33 ` Richard W.M. Jones
2015-02-10 19:33 ` [Qemu-devel] " Richard W.M. Jones
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=54CB7573.2040607@redhat.com \
--to=pbonzini@redhat.com \
--cc=dgilbert@redhat.com \
--cc=lersek@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rjones@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 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.