qemu-e2k/hw/usb
Daniel P. Berrangé ccb799313a 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>
2019-05-03 08:56:58 +02:00
..
bus.c hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str() 2019-04-01 08:53:44 +02:00
ccid-card-emulated.c
ccid-card-passthru.c
ccid.h
chipidea.c
combined-packet.c
core.c usb: remove unnecessary NULL device check from usb_ep_get() 2019-02-20 09:41:23 +01:00
desc-msos.c
desc.c
desc.h
dev-audio.c audio: use qapi AudioFormat instead of audfmt_e 2019-03-11 10:29:26 +01:00
dev-bluetooth.c
dev-hid.c
dev-hub.c
dev-mtp.c usb-mtp: change default to success for usb_mtp_update_object 2019-05-02 08:29:33 +02:00
dev-network.c
dev-serial.c char: allow specifying a GMainContext at opening time 2019-02-13 14:23:39 +01:00
dev-smartcard-reader.c qdev: pass an Object * to qbus_set_hotplug_handler() 2019-02-17 21:54:02 +11:00
dev-storage.c
dev-uas.c
dev-wacom.c
hcd-ehci-pci.c
hcd-ehci-sysbus.c
hcd-ehci.c ehci: check device is not NULL before calling usb_ep_get() 2019-02-20 09:41:23 +01:00
hcd-ehci.h
hcd-musb.c usb: check device is not NULL before calling usb_ep_get() 2019-02-20 09:41:23 +01:00
hcd-ohci-pci.c hw/usb/hcd-ohci: Move PCI-related code into a separate file 2019-05-02 08:42:17 +02:00
hcd-ohci.c hw/usb/hcd-ohci: Move PCI-related code into a separate file 2019-05-02 08:42:17 +02:00
hcd-ohci.h hw/usb/hcd-ohci: Move PCI-related code into a separate file 2019-05-02 08:42:17 +02:00
hcd-uhci.c uhci: check device is not NULL before calling usb_ep_get() 2019-02-20 09:41:23 +01:00
hcd-xhci-nec.c
hcd-xhci.c hw/usb: avoid format truncation warning when formatting port name 2019-05-03 08:56:58 +02:00
hcd-xhci.h usb: implement XHCI underrun/overrun events 2019-01-30 06:47:52 +01:00
host-libusb.c Introduce new "no_guest_reset" parameter for usb-host device 2019-03-07 10:03:54 +01:00
host-stub.c
host.h
Kconfig hw/usb/hcd-ohci: Move PCI-related code into a separate file 2019-05-02 08:42:17 +02:00
libhw.c
Makefile.objs hw/usb/hcd-ohci: Move PCI-related code into a separate file 2019-05-02 08:42:17 +02:00
quirks-ftdi-ids.h
quirks-pl2303-ids.h
quirks.c
quirks.h
redirect.c usb: add device checks before redirector calls to usb_ep_get() 2019-02-20 09:41:23 +01:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
tusb6010.c hw: Remove unused 'hw/devices.h' include 2019-03-07 22:16:11 +01:00
xen-usb.c