summaryrefslogtreecommitdiff
path: root/hw/usb/dump.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-03-15 17:34:06 +0100
committerPeter Wu <peter@lekensteyn.nl>2014-03-16 00:10:06 +0100
commit43d6464d410136f1c083a6df263bb71319eb2244 (patch)
treed71312c0b19da4394f8cb974d7229000616ea52f /hw/usb/dump.c
parent8002d8a662d4db7cc8c833ac960179e05f1280ed (diff)
downloadqemu-43d6464d410136f1c083a6df263bb71319eb2244.tar.gz
usbdump: fail early if dump file is not available
This allows for less less checking by the consumer and avoids unnecessary work if the capture cannot be written anyway. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'hw/usb/dump.c')
-rw-r--r--hw/usb/dump.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/usb/dump.c b/hw/usb/dump.c
index 48da328126..eb4ce336e4 100644
--- a/hw/usb/dump.c
+++ b/hw/usb/dump.c
@@ -266,7 +266,10 @@ void usb_dump_submit(UsbDumpState *s, USBPacket *p)
uint8_t pid = p->pid;
uint8_t ep_type = p->ep->type;
- assert(s != NULL);
+ /* fail early if not configured */
+ if (!s || s->fd < 0) {
+ return;
+ }
if (ep_type == USB_ENDPOINT_XFER_CONTROL) {
// cannot get called for OUT
@@ -294,7 +297,10 @@ void usb_dump_complete(UsbDumpState *s, USBPacket *p)
uint8_t pid = p->pid;
uint8_t ep_type = p->ep->type;
- assert(s != NULL);
+ /* fail early if not configured */
+ if (!s || s->fd < 0) {
+ return;
+ }
if (ep_type == USB_ENDPOINT_XFER_CONTROL) {
assert(pid == USB_TOKEN_IN || pid == USB_TOKEN_SETUP);