|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 7/7] tools/kdd: mute spurious gcc warning
On Fri, Apr 06, 2018 at 08:39:53AM -0400, Boris Ostrovsky wrote:
> On 04/04/2018 09:50 PM, Marek Marczykowski-Górecki wrote:
> > gcc-8 complains:
> >
> > kdd.c:698:13: error: 'memcpy' offset [-204, -717] is out of the bounds
> > [0, 216] of object 'ctrl' with type 'kdd_ctrl' {aka 'union <anonymous>'}
> > [-Werror=array-bounds]
> > memcpy(buf, ((uint8_t *)&ctrl.c32) + offset, len);
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > kdd.c: In function 'kdd_select_callback':
> > kdd.c:642:14: note: 'ctrl' declared here
> > kdd_ctrl ctrl;
> > ^~~~
> >
> > But this is impossible - 'offset' is unsigned and correctly validated
> > few lines before.
> >
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> > ---
> > tools/debugger/kdd/kdd.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/tools/debugger/kdd/kdd.c b/tools/debugger/kdd/kdd.c
> > index 1bd5dd5..61d769e 100644
> > --- a/tools/debugger/kdd/kdd.c
> > +++ b/tools/debugger/kdd/kdd.c
> > @@ -695,7 +695,10 @@ static void kdd_handle_read_ctrl(kdd_state *s)
> > KDD_LOG(s, "Request outside of known control space\n");
> > len = 0;
> > } else {
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Warray-bounds"
> > memcpy(buf, ((uint8_t *)&ctrl.c32) + offset, len);
> > +#pragma GCC diagnostic pop
> > }
> > }
> >
>
>
> Breaks 32-bit build, at least with my (ancient, gcc version 4.4.5
> 20101112 (Red Hat 4.4.5-2) (GCC)) compiler:
>
>
>
> kdd.c: In function ‘kdd_handle_read_ctrl’:
> kdd.c:698: error: #pragma GCC diagnostic not allowed inside functions
> kdd.c:699: error: #pragma GCC diagnostic not allowed inside functions
> kdd.c:701: error: #pragma GCC diagnostic not allowed inside functions
> make[5]: *** [kdd.o] Error 1
>
Does moving the relevant #pragma's outside of the function fix it?
Wei.
>
> -boris
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |