qemu-devel
[Top][All Lists]
Advanced

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

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


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH v3] hw/usb/hcd-xhci: Fix GCC 9 build warning
Date: Fri, 3 May 2019 09:04:31 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 03/05/2019 02:42, Alistair Francis wrote:
> 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);
>       |                                                      ^~~~~~~~~~~~~~~
> 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>
> Reviewed-by: Laurent Vivier <address@hidden>
> Reviewed-by: Daniel P. Berrangé <address@hidden>
> Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> This is the onl patch left if my original series "Fix some GCC 9 build
> warnings" that hasn't either been accepeted into a maintainers tree or
> fixed by someone else.
> 
>  hw/usb/hcd-xhci.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index ec28bee319..a15b103b65 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -3321,6 +3321,8 @@ static void usb_xhci_init(XHCIState *xhci)
>  
>      usb_bus_new(&xhci->bus, sizeof(xhci->bus), &xhci_bus_ops, dev);
>  
> +    g_assert(usbports <= MAX(MAXPORTS_2, MAXPORTS_3));
> +
>      for (i = 0; i < usbports; i++) {
>          speedmask = 0;
>          if (i < xhci->numports_2) {
> 
Reviewed-by: Laurent Vivier <address@hidden>




reply via email to

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