qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v1 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning


From: Alistair Francis
Subject: Re: [Qemu-devel] [PATCH v1 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning
Date: Tue, 30 Apr 2019 13:59:06 -0700

On Tue, Apr 30, 2019 at 1:24 PM Laurent Vivier <address@hidden> wrote:
>
> Le 30/04/2019 à 22:09, Alistair Francis a écrit :
> > Fix this build warning with GCC 9 on Fedora 30:
> > hw/usb/hcd-xhci.c:3339:66: error: ‘%d’ directive output may be truncated 
> > writing between 1 and 10 bytes into a region of size 5 
> > [-Werror=format-truncation=]
> >  3339 |             snprintf(port->name, sizeof(port->name), "usb2 port 
> > #%d", i+1);
> >       |                                                                  ^~
> > hw/usb/hcd-xhci.c:3339:54: note: directive argument in the range [1, 
> > 2147483647]
> >  3339 |             snprintf(port->name, sizeof(port->name), "usb2 port 
> > #%d", i+1);
>
> "i" cannot be greater than 15.
>
> perhaps an "assert(i <= MAX(MAXPORTS_2, MAXPORTS_3))" can fix the warning ?

It does seem to stop the warnings, I'll change this patch to use a g_assert().

Alistair

>
> Thanks,
> Laurent
>
> >       |                                                      ^~~~~~~~~~~~~~~
> > In file included from /usr/include/stdio.h:867,
> >                  from /home/alistair/qemu/include/qemu/osdep.h:99,
> >                  from hw/usb/hcd-xhci.c:21:
> > /usr/include/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output 
> > between 13 and 22 bytes into a destination of size 16
> >    67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 
> > 1,
> >       |          
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    68 |        __bos (__s), __fmt, __va_arg_pack ());
> >       |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Signed-off-by: Alistair Francis <address@hidden>
> > ---
> >  hw/usb/hcd-xhci.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h
> > index 240caa4e51..9e4988abb6 100644
> > --- a/hw/usb/hcd-xhci.h
> > +++ b/hw/usb/hcd-xhci.h
> > @@ -133,7 +133,7 @@ typedef struct XHCIPort {
> >      uint32_t portnr;
> >      USBPort  *uport;
> >      uint32_t speedmask;
> > -    char name[16];
> > +    char name[24];
> >      MemoryRegion mem;
> >  } XHCIPort;
> >
> >
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]