From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjmyn-0007zj-B0 for qemu-devel@nongnu.org; Mon, 12 May 2014 05:57:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wjmyf-0000om-GA for qemu-devel@nongnu.org; Mon, 12 May 2014 05:57:05 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:41274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjmyf-0000oi-8H for qemu-devel@nongnu.org; Mon, 12 May 2014 05:56:57 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 May 2014 10:56:55 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 1148717D8047 for ; Mon, 12 May 2014 10:58:00 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4C9uqMs2753022 for ; Mon, 12 May 2014 09:56:52 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4C9uprN003368 for ; Mon, 12 May 2014 03:56:51 -0600 Date: Mon, 12 May 2014 11:56:49 +0200 From: Thomas Huth Message-ID: <20140512115649.7a58f82d@oc7435384737.ibm.com> In-Reply-To: <1399888297-4751-1-git-send-email-agraf@suse.de> References: <1399888297-4751-1-git-send-email-agraf@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] kvm: Fix enable_cap helpers on older gcc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Cornelia Huck , qemu-devel@nongnu.org On Mon, 12 May 2014 11:51:37 +0200 Alexander Graf 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 > > --- > > 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