aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/dev-audio.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2019-04-12 13:16:25 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-05-03 08:56:58 +0200
commitccb799313a5926a6aa49018bbc67fe6165fad7f3 (patch)
tree5a71bcb613d19cb2b439426097352df777f38b6a /hw/usb/dev-audio.c
parent34d97308f6d54d1f329267952533d25e6c8928ff (diff)
hw/usb: avoid format truncation warning when formatting port name
hw/usb/hcd-xhci.c: In function ‘usb_xhci_realize’: hw/usb/hcd-xhci.c:3339:66: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 5 [-Wformat-trunca\ tion=] 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); | ^~~~~~~~~~~~~~~ The xhci code formats the port name into a fixed length buffer which is only large enough to hold port numbers upto 5 digits in decimal representation. We're never going to have a port number that large, so aserting the port number is sensible is sufficient to tell GCC the formatted string won't be truncated. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20190412121626.19829-5-berrange@redhat.com> [ kraxel: also s/int/unsigned int/ to tell gcc they can't go negative. ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/dev-audio.c')
0 files changed, 0 insertions, 0 deletions