[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tools/kdd: use mute -Warray-bounds only on new gcc version



On Fri, Apr 06, 2018 at 06:12:50PM +0100, Wei Liu wrote:
> On Fri, Apr 06, 2018 at 05:32:57PM +0200, Marek Marczykowski-Górecki wrote:
> > "#pragma GCC diagnostic push" is supported only on gcc >= 4.6. But since
> > muting this the warning is needed only on gcc >= 8, do it only then,
> > instead of tricking the compiler about this code (and making it less
> > readable to the human too).
> > 
> > This fixes 5888eecca0 "tools/kdd: mute spurious gcc warning".
> > 
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> > ---
> >  tools/debugger/kdd/kdd.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/debugger/kdd/kdd.c b/tools/debugger/kdd/kdd.c
> > index 61d769ece9..95c3a949ec 100644
> > --- a/tools/debugger/kdd/kdd.c
> > +++ b/tools/debugger/kdd/kdd.c
> > @@ -695,10 +695,14 @@ static void kdd_handle_read_ctrl(kdd_state *s)
> >              KDD_LOG(s, "Request outside of known control space\n");
> >              len = 0;
> >          } else {
> > +#if __GNUC__ >= 8
> >  #pragma GCC diagnostic push
> >  #pragma GCC diagnostic ignored "-Warray-bounds"
> > +#endif
> >              memcpy(buf, ((uint8_t *)&ctrl.c32) + offset, len);
> > +#if __GNUC__ >= 8
> >  #pragma GCC diagnostic pop
> > +#endif
> 
> Oh thanks for the quick turnaround.
> 
> Since Tim thinks it is better to not disable the warning -- how about
> using assert() to give the compiler a hint? Would that work?

No, it doesn't.

Changing offset type to uint32_t, or unsigned int works. Also adding
"offset &= 0x2ff" helps (but changes behavior). And now I wonder if
this warning isn't legitimate - maybe there is some int overflow case
that I don't see?

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Attachment: signature.asc
Description: PGP signature

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.