xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Charles Arnold <CARNOLD@suse.com>,
	Juergen Gross <jgross@suse.com>, Wei Liu <wei.liu2@citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 1/2] x86/e820: fix build with gcc9
Date: Thu, 7 Mar 2019 10:55:34 +0000	[thread overview]
Message-ID: <20190307105534.42f4byw4l3k4cu65@zion.uk.xensource.com> (raw)
In-Reply-To: <20190307104608.dsexwz7dn6qceel7@Air-de-Roger>

On Thu, Mar 07, 2019 at 11:46:08AM +0100, Roger Pau Monné wrote:
> On Thu, Mar 07, 2019 at 03:31:43AM -0700, Jan Beulich wrote:
> > e820.c: In function ‘clip_to_limit’:
> > .../xen/include/asm/string.h:10:26: error: ‘__builtin_memmove’ offset [-16, -36] is out of the bounds [0, 20484] of
> > object ‘e820’ with type ‘struct e820map’ [-Werror=array-bounds]
> >    10 | #define memmove(d, s, n) __builtin_memmove(d, s, n)
> >       |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
> > e820.c:404:13: note: in expansion of macro ‘memmove’
> >   404 |             memmove(&e820.map[i], &e820.map[i+1],
> >       |             ^~~~~~~
> > e820.c:36:16: note: ‘e820’ declared here
> >    36 | struct e820map e820;
> >       |                ^~~~
> > 
> > While I can't see where the negative offsets would come from, converting
> > the loop index to unsigned type helps. Take the opportunity and also
> > convert several other local variables and copy_e820_map()'s second
> > parameter to unsigned int (and bool in one case).
> 
> I also cannot see how you can end up with negative offsets, but
> changing to unsigned int is definitely and improvement IMO.

Gcc is becoming more and more aggressive in inferring what you mean with
your code. There are definitely bugs in that area.

This one comes to mind:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86827

Although I'm not sure if -Warray-bounds is the culprit in this case.

> 
> > Reported-by: Charles Arnold <carnold@suse.com>
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Thanks.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-03-07 10:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07 10:23 [PATCH 0/2] x86: fix build with gcc9 Jan Beulich
2019-03-07 10:31 ` [PATCH 1/2] x86/e820: " Jan Beulich
2019-03-07 10:46   ` Roger Pau Monné
2019-03-07 10:55     ` Wei Liu [this message]
2019-03-15 16:07   ` Andrew Cooper
2019-03-18 10:00     ` Jan Beulich
2019-03-07 10:32 ` [PATCH 2/2] x86/mtrr: " Jan Beulich
2019-03-07 10:55   ` Roger Pau Monné
2019-03-07 11:22     ` Jan Beulich
2019-03-07 14:20       ` Roger Pau Monné
2019-03-15 16:21   ` Andrew Cooper
2019-03-18 10:11     ` Jan Beulich
2019-03-18 10:30       ` Andrew Cooper
2019-03-18 10:53         ` Jan Beulich
     [not found]   ` <5C80F32C0200000000103FF7@prv1-mh.provo.novell.com>
     [not found]     ` <5C80F32C0200007800232900@prv1-mh.provo.novell.com>
     [not found]       ` <5C80F32C0200000000104D67@prv1-mh.provo.novell.com>
     [not found]         ` <5C80F32C0200007800238665@prv1-mh.provo.novell.com>
2019-06-14 15:56           ` [Xen-devel] Ping: " Jan Beulich
2019-06-17 15:47             ` Andrew Cooper
2019-06-17 16:08               ` Jan Beulich
2019-03-07 11:12 ` [PATCH 0/2] x86: " Wei Liu
2019-03-07 11:37 ` M A Young
2019-03-07 11:57   ` Jan Beulich
2019-03-15 12:33 ` Ping: " Jan Beulich

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=20190307105534.42f4byw4l3k4cu65@zion.uk.xensource.com \
    --to=wei.liu2@citrix.com \
    --cc=CARNOLD@suse.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jgross@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 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).