From: Keir Fraser Subject: Re: [PATCH] compat/memory: fix build with old gcc Date: Fri, 17 Jan 2014 18:03:49 +0000 Message-ID: References: <52D673E60200007800113C11@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1W4Dlu-0003AU-V7 for xen-devel@lists.xenproject.org; Fri, 17 Jan 2014 18:03:59 +0000 Received: by mail-pd0-f179.google.com with SMTP id q10so2252353pdj.10 for ; Fri, 17 Jan 2014 10:03:55 -0800 (PST) In-Reply-To: <52D673E60200007800113C11@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich , xen-devel List-Id: xen-devel@lists.xenproject.org On 15/01/2014 10:41, "Jan Beulich" wrote: > struct xen_add_to_physmap_batch's size field being uint16_t causes old > compiler versions to warn about the pointless range check done inside > compat_handle_okay(). > > Signed-off-by: Jan Beulich > Tested-by: Andrew Cooper Acked-by: Keir Fraser > --- a/xen/common/compat/memory.c > +++ b/xen/common/compat/memory.c > @@ -206,18 +206,20 @@ int compat_memory_op(unsigned int cmd, X > { > unsigned int limit = (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.atpb)) > / (sizeof(nat.atpb->idxs.p) + > sizeof(nat.atpb->gpfns.p)); > + /* Use an intermediate variable to suppress warnings on old gcc: > */ > + unsigned int size = cmp.atpb.size; > xen_ulong_t *idxs = (void *)(nat.atpb + 1); > xen_pfn_t *gpfns = (void *)(idxs + limit); > > if ( copy_from_guest(&cmp.atpb, compat, 1) || > - !compat_handle_okay(cmp.atpb.idxs, cmp.atpb.size) || > - !compat_handle_okay(cmp.atpb.gpfns, cmp.atpb.size) || > - !compat_handle_okay(cmp.atpb.errs, cmp.atpb.size) ) > + !compat_handle_okay(cmp.atpb.idxs, size) || > + !compat_handle_okay(cmp.atpb.gpfns, size) || > + !compat_handle_okay(cmp.atpb.errs, size) ) > return -EFAULT; > > end_extent = start_extent + limit; > - if ( end_extent > cmp.atpb.size ) > - end_extent = cmp.atpb.size; > + if ( end_extent > size ) > + end_extent = size; > > idxs -= start_extent; > gpfns -= start_extent; > > >