diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-07-20 17:52:48 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-07-20 17:52:48 +0100 |
commit | 4439e1f1563a36e3bad31e5d2327d500c1aea109 (patch) | |
tree | 95f672283775e50e0b3cd23d1f8052f384bfcb2e | |
parent | 25d0233c1ac6cd14a15fcc834f1de3b179037b1d (diff) | |
parent | 121829cb2160e9cd82482c1542699fa589688106 (diff) |
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20170720-pull-request' into staging
usb: Fix build with newer gcc
# gpg: Signature made Thu 20 Jul 2017 09:44:55 BST
# gpg: using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138
* remotes/kraxel/tags/usb-20170720-pull-request:
usb: Fix build with newer gcc
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | hw/usb/bus.c | 6 |
1 files 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); |