diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-03-15 17:34:06 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-03-16 00:10:06 +0100 |
commit | 43d6464d410136f1c083a6df263bb71319eb2244 (patch) | |
tree | d71312c0b19da4394f8cb974d7229000616ea52f /hw/usb/dump.c | |
parent | 8002d8a662d4db7cc8c833ac960179e05f1280ed (diff) | |
download | qemu-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.c | 10 |
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); |