* [Qemu-devel] [PULL 0/1] Usb 20170720 patches @ 2017-07-20 8:45 Gerd Hoffmann 2017-07-20 8:45 ` [Qemu-devel] [PULL 1/1] usb: Fix build with newer gcc Gerd Hoffmann 2017-07-21 9:31 ` [Qemu-devel] [PULL 0/1] Usb 20170720 patches Peter Maydell 0 siblings, 2 replies; 3+ messages in thread From: Gerd Hoffmann @ 2017-07-20 8:45 UTC (permalink / raw) To: qemu-devel; +Cc: Gerd Hoffmann The following changes since commit d4e59218ab80e86015753782fb5378767a51ccd0: Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2017-07-18-2' into staging (2017-07-19 20:45:37 +0100) are available in the git repository at: git://git.kraxel.org/qemu tags/usb-20170720-pull-request for you to fetch changes up to 121829cb2160e9cd82482c1542699fa589688106: usb: Fix build with newer gcc (2017-07-20 10:02:11 +0200) ---------------------------------------------------------------- usb: Fix build with newer gcc ---------------------------------------------------------------- Eric Blake (1): usb: Fix build with newer gcc hw/usb/bus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.9.3 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PULL 1/1] usb: Fix build with newer gcc 2017-07-20 8:45 [Qemu-devel] [PULL 0/1] Usb 20170720 patches Gerd Hoffmann @ 2017-07-20 8:45 ` Gerd Hoffmann 2017-07-21 9:31 ` [Qemu-devel] [PULL 0/1] Usb 20170720 patches Peter Maydell 1 sibling, 0 replies; 3+ messages in thread From: Gerd Hoffmann @ 2017-07-20 8:45 UTC (permalink / raw) To: qemu-devel; +Cc: Eric Blake, Gerd Hoffmann From: Eric Blake <eblake@redhat.com> gcc 7 is pickier about our sources: hw/usb/bus.c: In function ‘usb_port_location’: hw/usb/bus.c:410:66: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 15 [-Werror=format-truncation=] snprintf(downstream->path, sizeof(downstream->path), "%s.%d", ^~ hw/usb/bus.c:410:9: note: ‘snprintf’ output between 3 and 28 bytes into a destination of size 16 snprintf(downstream->path, sizeof(downstream->path), "%s.%d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ upstream->path, portnr); ~~~~~~~~~~~~~~~~~~~~~~~ But we know that there are at most 5 levels of USB hubs, with at most two digits per level; that plus the separating dots means we use at most 15 bytes (including trailing NUL) of our 16-byte field. Adding an assertion to show gcc that we checked for truncation is enough to shut up the false-positive warning. Inspired by an idea by Dr. David Alan Gilbert <dgilbert@redhat.com>. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20170717151334.17954-1-eblake@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- hw/usb/bus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 5939b273b9..d910f849e7 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -407,8 +407,10 @@ void usb_register_companion(const char *masterbus, USBPort *ports[], void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr) { if (upstream) { - snprintf(downstream->path, sizeof(downstream->path), "%s.%d", - upstream->path, portnr); + int l = snprintf(downstream->path, sizeof(downstream->path), "%s.%d", + upstream->path, portnr); + /* Max string is nn.nn.nn.nn.nn, which fits in 16 bytes */ + assert(l < sizeof(downstream->path)); downstream->hubcount = upstream->hubcount + 1; } else { snprintf(downstream->path, sizeof(downstream->path), "%d", portnr); -- 2.9.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PULL 0/1] Usb 20170720 patches 2017-07-20 8:45 [Qemu-devel] [PULL 0/1] Usb 20170720 patches Gerd Hoffmann 2017-07-20 8:45 ` [Qemu-devel] [PULL 1/1] usb: Fix build with newer gcc Gerd Hoffmann @ 2017-07-21 9:31 ` Peter Maydell 1 sibling, 0 replies; 3+ messages in thread From: Peter Maydell @ 2017-07-21 9:31 UTC (permalink / raw) To: Gerd Hoffmann; +Cc: QEMU Developers On 20 July 2017 at 09:45, Gerd Hoffmann <kraxel@redhat.com> wrote: > The following changes since commit d4e59218ab80e86015753782fb5378767a51ccd0: > > Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2017-07-18-2' into staging (2017-07-19 20:45:37 +0100) > > are available in the git repository at: > > git://git.kraxel.org/qemu tags/usb-20170720-pull-request > > for you to fetch changes up to 121829cb2160e9cd82482c1542699fa589688106: > > usb: Fix build with newer gcc (2017-07-20 10:02:11 +0200) > > ---------------------------------------------------------------- > usb: Fix build with newer gcc > > ---------------------------------------------------------------- > > Eric Blake (1): > usb: Fix build with newer gcc > > hw/usb/bus.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) Applied, thanks. -- PMM ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-21 9:31 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-20 8:45 [Qemu-devel] [PULL 0/1] Usb 20170720 patches Gerd Hoffmann 2017-07-20 8:45 ` [Qemu-devel] [PULL 1/1] usb: Fix build with newer gcc Gerd Hoffmann 2017-07-21 9:31 ` [Qemu-devel] [PULL 0/1] Usb 20170720 patches Peter Maydell
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).