qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc
@ 2014-05-12  9:51 Alexander Graf
  2014-05-12  9:56 ` Thomas Huth
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alexander Graf @ 2014-05-12  9:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, Thomas Huth

Commit 40f1ee27aa1 introduced handy helpers for enable_cap calls on
vcpu and vm level. Unfortunately some older gcc versions (4.7.1, 4.6)
seem to choke on signedness detection in inline created variables:

target-ppc/kvm.c: In function 'kvmppc_booke_watchdog_enable':
target-ppc/kvm.c:1302:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
target-ppc/kvm.c: In function 'kvmppc_set_papr':
target-ppc/kvm.c:1504:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]

However - thanks to Thomas Huth for the suggestion - we can just cast the
offending potentially 0 value to a signed type, making the comparison signed.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - only do cast, leaving readability intact

---
 include/sysemu/kvm.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 192fe89..76c39cc 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -302,7 +302,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
         };                                                           \
         uint64_t args_tmp[] = { __VA_ARGS__ };                       \
         int i;                                                       \
-        for (i = 0; i < ARRAY_SIZE(args_tmp) &&                      \
+        for (i = 0; i < (int)ARRAY_SIZE(args_tmp) &&                 \
                      i < ARRAY_SIZE(cap.args); i++) {                \
             cap.args[i] = args_tmp[i];                               \
         }                                                            \
@@ -317,7 +317,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
         };                                                           \
         uint64_t args_tmp[] = { __VA_ARGS__ };                       \
         int i;                                                       \
-        for (i = 0; i < ARRAY_SIZE(args_tmp) &&                      \
+        for (i = 0; i < (int)ARRAY_SIZE(args_tmp) &&                 \
                      i < ARRAY_SIZE(cap.args); i++) {                \
             cap.args[i] = args_tmp[i];                               \
         }                                                            \
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc
  2014-05-12  9:51 [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc Alexander Graf
@ 2014-05-12  9:56 ` Thomas Huth
  2014-05-12 10:15 ` Cornelia Huck
  2014-05-20 10:53 ` Cornelia Huck
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2014-05-12  9:56 UTC (permalink / raw)
  To: Alexander Graf; +Cc: Cornelia Huck, qemu-devel

On Mon, 12 May 2014 11:51:37 +0200
Alexander Graf <agraf@suse.de> wrote:

> Commit 40f1ee27aa1 introduced handy helpers for enable_cap calls on
> vcpu and vm level. Unfortunately some older gcc versions (4.7.1, 4.6)
> seem to choke on signedness detection in inline created variables:
> 
> target-ppc/kvm.c: In function 'kvmppc_booke_watchdog_enable':
> target-ppc/kvm.c:1302:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> target-ppc/kvm.c: In function 'kvmppc_set_papr':
> target-ppc/kvm.c:1504:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> 
> However - thanks to Thomas Huth for the suggestion - we can just cast the
> offending potentially 0 value to a signed type, making the comparison signed.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> 
> ---
> 
> v1 -> v2:
> 
>   - only do cast, leaving readability intact
> 
> ---
>  include/sysemu/kvm.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 192fe89..76c39cc 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -302,7 +302,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
>          };                                                           \
>          uint64_t args_tmp[] = { __VA_ARGS__ };                       \
>          int i;                                                       \
> -        for (i = 0; i < ARRAY_SIZE(args_tmp) &&                      \
> +        for (i = 0; i < (int)ARRAY_SIZE(args_tmp) &&                 \
>                       i < ARRAY_SIZE(cap.args); i++) {                \
>              cap.args[i] = args_tmp[i];                               \
>          }                                                            \
> @@ -317,7 +317,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
>          };                                                           \
>          uint64_t args_tmp[] = { __VA_ARGS__ };                       \
>          int i;                                                       \
> -        for (i = 0; i < ARRAY_SIZE(args_tmp) &&                      \
> +        for (i = 0; i < (int)ARRAY_SIZE(args_tmp) &&                 \
>                       i < ARRAY_SIZE(cap.args); i++) {                \
>              cap.args[i] = args_tmp[i];                               \
>          }                                                            \

Looks much better this way :-)

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc
  2014-05-12  9:51 [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc Alexander Graf
  2014-05-12  9:56 ` Thomas Huth
@ 2014-05-12 10:15 ` Cornelia Huck
  2014-05-12 10:17   ` Alexander Graf
  2014-05-20 10:53 ` Cornelia Huck
  2 siblings, 1 reply; 6+ messages in thread
From: Cornelia Huck @ 2014-05-12 10:15 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-devel, Thomas Huth

On Mon, 12 May 2014 11:51:37 +0200
Alexander Graf <agraf@suse.de> wrote:

> Commit 40f1ee27aa1 introduced handy helpers for enable_cap calls on
> vcpu and vm level. Unfortunately some older gcc versions (4.7.1, 4.6)
> seem to choke on signedness detection in inline created variables:
> 
> target-ppc/kvm.c: In function 'kvmppc_booke_watchdog_enable':
> target-ppc/kvm.c:1302:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> target-ppc/kvm.c: In function 'kvmppc_set_papr':
> target-ppc/kvm.c:1504:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> 
> However - thanks to Thomas Huth for the suggestion - we can just cast the
> offending potentially 0 value to a signed type, making the comparison signed.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>

I assume you will take this through your tree?

> 
> ---
> 
> v1 -> v2:
> 
>   - only do cast, leaving readability intact
> 
> ---
>  include/sysemu/kvm.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 192fe89..76c39cc 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -302,7 +302,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
>          };                                                           \
>          uint64_t args_tmp[] = { __VA_ARGS__ };                       \
>          int i;                                                       \
> -        for (i = 0; i < ARRAY_SIZE(args_tmp) &&                      \
> +        for (i = 0; i < (int)ARRAY_SIZE(args_tmp) &&                 \
>                       i < ARRAY_SIZE(cap.args); i++) {                \
>              cap.args[i] = args_tmp[i];                               \
>          }                                                            \
> @@ -317,7 +317,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
>          };                                                           \
>          uint64_t args_tmp[] = { __VA_ARGS__ };                       \
>          int i;                                                       \
> -        for (i = 0; i < ARRAY_SIZE(args_tmp) &&                      \
> +        for (i = 0; i < (int)ARRAY_SIZE(args_tmp) &&                 \
>                       i < ARRAY_SIZE(cap.args); i++) {                \
>              cap.args[i] = args_tmp[i];                               \
>          }                                                            \

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc
  2014-05-12 10:15 ` Cornelia Huck
@ 2014-05-12 10:17   ` Alexander Graf
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2014-05-12 10:17 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: qemu-devel, Thomas Huth


On 12.05.14 12:15, Cornelia Huck wrote:
> On Mon, 12 May 2014 11:51:37 +0200
> Alexander Graf <agraf@suse.de> wrote:
>
>> Commit 40f1ee27aa1 introduced handy helpers for enable_cap calls on
>> vcpu and vm level. Unfortunately some older gcc versions (4.7.1, 4.6)
>> seem to choke on signedness detection in inline created variables:
>>
>> target-ppc/kvm.c: In function 'kvmppc_booke_watchdog_enable':
>> target-ppc/kvm.c:1302:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
>> target-ppc/kvm.c: In function 'kvmppc_set_papr':
>> target-ppc/kvm.c:1504:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
>>
>> However - thanks to Thomas Huth for the suggestion - we can just cast the
>> offending potentially 0 value to a signed type, making the comparison signed.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>
> I assume you will take this through your tree?

Yeah, without I can't compile :)


Alex

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc
  2014-05-12  9:51 [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc Alexander Graf
  2014-05-12  9:56 ` Thomas Huth
  2014-05-12 10:15 ` Cornelia Huck
@ 2014-05-20 10:53 ` Cornelia Huck
  2014-05-20 10:53   ` Alexander Graf
  2 siblings, 1 reply; 6+ messages in thread
From: Cornelia Huck @ 2014-05-20 10:53 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-devel, Thomas Huth

On Mon, 12 May 2014 11:51:37 +0200
Alexander Graf <agraf@suse.de> wrote:

> Commit 40f1ee27aa1 introduced handy helpers for enable_cap calls on
> vcpu and vm level. Unfortunately some older gcc versions (4.7.1, 4.6)
> seem to choke on signedness detection in inline created variables:
> 
> target-ppc/kvm.c: In function 'kvmppc_booke_watchdog_enable':
> target-ppc/kvm.c:1302:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> target-ppc/kvm.c: In function 'kvmppc_set_papr':
> target-ppc/kvm.c:1504:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> 
> However - thanks to Thomas Huth for the suggestion - we can just cast the
> offending potentially 0 value to a signed type, making the comparison signed.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> 

Mind if I take this through s390-next instead of your tree, so I can
send a pull request with clean conscience?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc
  2014-05-20 10:53 ` Cornelia Huck
@ 2014-05-20 10:53   ` Alexander Graf
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2014-05-20 10:53 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: qemu-devel, Thomas Huth


On 20.05.14 12:53, Cornelia Huck wrote:
> On Mon, 12 May 2014 11:51:37 +0200
> Alexander Graf <agraf@suse.de> wrote:
>
>> Commit 40f1ee27aa1 introduced handy helpers for enable_cap calls on
>> vcpu and vm level. Unfortunately some older gcc versions (4.7.1, 4.6)
>> seem to choke on signedness detection in inline created variables:
>>
>> target-ppc/kvm.c: In function 'kvmppc_booke_watchdog_enable':
>> target-ppc/kvm.c:1302:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
>> target-ppc/kvm.c: In function 'kvmppc_set_papr':
>> target-ppc/kvm.c:1504:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
>>
>> However - thanks to Thomas Huth for the suggestion - we can just cast the
>> offending potentially 0 value to a signed type, making the comparison signed.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>>
> Mind if I take this through s390-next instead of your tree, so I can
> send a pull request with clean conscience?
>

Sure, whoever hits master first wins ;)


Alex

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-20 10:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-12  9:51 [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc Alexander Graf
2014-05-12  9:56 ` Thomas Huth
2014-05-12 10:15 ` Cornelia Huck
2014-05-12 10:17   ` Alexander Graf
2014-05-20 10:53 ` Cornelia Huck
2014-05-20 10:53   ` Alexander Graf

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).