qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Alistair Francis <Alistair.Francis@wdc.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"alistair23@gmail.com" <alistair23@gmail.com>,
	"kraxel@redhat.com" <kraxel@redhat.com>,
	"riku.voipio@iki.fi" <riku.voipio@iki.fi>,
	"laurent@vivier.eu" <laurent@vivier.eu>,
	"qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning
Date: Wed, 1 May 2019 10:43:31 +0100	[thread overview]
Message-ID: <20190501094331.GP29808@redhat.com> (raw)
In-Reply-To: <ff51c73e3095fa503d14aafece54f8565fe99900.1556666645.git.alistair.francis@wdc.com>

On Tue, Apr 30, 2019 at 11:28:31PM +0000, 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 <alistair.francis@wdc.com>
> ---
>  hw/usb/hcd-xhci.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index ec28bee319..2b061772b2 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -3322,6 +3322,7 @@ static void usb_xhci_init(XHCIState *xhci)
>      usb_bus_new(&xhci->bus, sizeof(xhci->bus), &xhci_bus_ops, dev);
>  
>      for (i = 0; i < usbports; i++) {
> +        g_assert(i < MAX(MAXPORTS_2, MAXPORTS_3));
>          speedmask = 0;
>          if (i < xhci->numports_2) {
>              if (xhci_get_flag(xhci, XHCI_FLAG_SS_FIRST)) {

I proposed a slightly different fix here:

  https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02125.html

but both have the same effect


  Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

WARNING: multiple messages have this Message-ID (diff)
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Alistair Francis <Alistair.Francis@wdc.com>
Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
	"riku.voipio@iki.fi" <riku.voipio@iki.fi>,
	"laurent@vivier.eu" <laurent@vivier.eu>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"kraxel@redhat.com" <kraxel@redhat.com>,
	"alistair23@gmail.com" <alistair23@gmail.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning
Date: Wed, 1 May 2019 10:43:31 +0100	[thread overview]
Message-ID: <20190501094331.GP29808@redhat.com> (raw)
Message-ID: <20190501094331.q5jhKb4n9_tln4M4NBT6jtgd9Ey9lzM4NBRWkfybkuc@z> (raw)
In-Reply-To: <ff51c73e3095fa503d14aafece54f8565fe99900.1556666645.git.alistair.francis@wdc.com>

On Tue, Apr 30, 2019 at 11:28:31PM +0000, 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 <alistair.francis@wdc.com>
> ---
>  hw/usb/hcd-xhci.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index ec28bee319..2b061772b2 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -3322,6 +3322,7 @@ static void usb_xhci_init(XHCIState *xhci)
>      usb_bus_new(&xhci->bus, sizeof(xhci->bus), &xhci_bus_ops, dev);
>  
>      for (i = 0; i < usbports; i++) {
> +        g_assert(i < MAX(MAXPORTS_2, MAXPORTS_3));
>          speedmask = 0;
>          if (i < xhci->numports_2) {
>              if (xhci_get_flag(xhci, XHCI_FLAG_SS_FIRST)) {

I proposed a slightly different fix here:

  https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02125.html

but both have the same effect


  Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


  parent reply	other threads:[~2019-05-01  9:43 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30 23:28 [Qemu-devel] [PATCH v2 0/5] Fix some GCC 9 build warnings Alistair Francis
2019-04-30 23:28 ` Alistair Francis
2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 1/5] util/qemu-sockets: Fix " Alistair Francis
2019-04-30 23:28   ` Alistair Francis
2019-05-01  9:35   ` Laurent Vivier
2019-05-01  9:35     ` Laurent Vivier
2019-05-01  9:41   ` Daniel P. Berrangé
2019-05-01  9:41     ` Daniel P. Berrangé
2019-05-02 17:57     ` Alistair Francis
2019-05-02 17:57       ` Alistair Francis
2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning Alistair Francis
2019-04-30 23:28   ` Alistair Francis
2019-05-01  9:37   ` Laurent Vivier
2019-05-01  9:37     ` Laurent Vivier
2019-05-01  9:43   ` Daniel P. Berrangé [this message]
2019-05-01  9:43     ` Daniel P. Berrangé
2019-05-01 14:12   ` Richard Henderson
2019-05-01 14:12     ` Richard Henderson
2019-05-01 15:21     ` Philippe Mathieu-Daudé
2019-05-01 15:21       ` Philippe Mathieu-Daudé
2019-05-02 17:53     ` Alistair Francis
2019-05-02 17:53       ` Alistair Francis
2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 3/5] hw/usb/dev-mtp: " Alistair Francis
2019-04-30 23:28   ` Alistair Francis
2019-05-01  7:12   ` Thomas Huth
2019-05-01  7:12     ` Thomas Huth
2019-05-01  9:40   ` Daniel P. Berrangé
2019-05-01  9:40     ` Daniel P. Berrangé
2019-05-02 17:48     ` Alistair Francis
2019-05-02 17:48       ` Alistair Francis
2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 4/5] linux-user/uname: Fix GCC 9 build warnings Alistair Francis
2019-04-30 23:28   ` Alistair Francis
2019-05-01  9:40   ` Laurent Vivier
2019-05-01  9:40     ` Laurent Vivier
2019-05-01  9:44     ` Daniel P. Berrangé
2019-05-01  9:44       ` Daniel P. Berrangé
2019-05-01  9:46       ` Laurent Vivier
2019-05-01  9:46         ` Laurent Vivier
2019-05-01 12:00     ` Eric Blake
2019-05-01 12:00       ` Eric Blake
2019-05-02 17:24       ` Alistair Francis
2019-05-02 17:24         ` Alistair Francis
2019-04-30 23:29 ` [Qemu-devel] [PATCH v2 5/5] linux-user/elfload: " Alistair Francis
2019-04-30 23:29   ` Alistair Francis
2019-05-01  9:40   ` Laurent Vivier
2019-05-01  9:40     ` Laurent Vivier
2019-05-01 14:15   ` Richard Henderson
2019-05-01 14:15     ` Richard Henderson
2019-05-02  8:14   ` Laurent Vivier
2019-05-02  8:14     ` Laurent Vivier

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=20190501094331.GP29808@redhat.com \
    --to=berrange@redhat.com \
    --cc=Alistair.Francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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).