diff options
author | Markus Armbruster <armbru@redhat.com> | 2009-10-07 01:15:57 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-10-07 08:54:54 -0500 |
commit | 33e66b86d89040f0a9e99aa53deb74ce8936a649 (patch) | |
tree | a356cfe20774dbc9e6107d8824414c1ea75599ce /hw | |
parent | 18cfeb52d17825dddadfc74e99255530aa889136 (diff) |
Check return value of qdev_init()
But do so only where it may actually fail. Leave the rest for the
next commit.
Patchworks-ID: 35167
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/pci-hotplug.c | 4 | ||||
-rw-r--r-- | hw/pci.c | 1 | ||||
-rw-r--r-- | hw/scsi-bus.c | 4 | ||||
-rw-r--r-- | hw/usb-msd.c | 3 |
4 files changed, 8 insertions, 4 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index c38a127394..ccd2cf3cac 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -172,8 +172,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, default: dev = NULL; } - if (dev) - qdev_init(&dev->qdev); + if (!dev || qdev_init(&dev->qdev) < 0) + return NULL; return dev; } @@ -833,6 +833,7 @@ static const char * const pci_nic_names[] = { }; /* Initialize a PCI NIC. */ +/* FIXME callers should check for failure, but don't */ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model, const char *default_devaddr) { diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index fe8991e9ce..41992e52df 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -82,6 +82,7 @@ void scsi_qdev_register(SCSIDeviceInfo *info) } /* handle legacy '-drive if=scsi,...' cmd line args */ +/* FIXME callers should check for failure, but don't */ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit) { const char *driver; @@ -91,7 +92,8 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit) dev = qdev_create(&bus->qbus, driver); qdev_prop_set_uint32(dev, "scsi-id", unit); qdev_prop_set_drive(dev, "drive", dinfo); - qdev_init(dev); + if (qdev_init(dev) < 0) + return NULL; return DO_UPCAST(SCSIDevice, qdev, dev); } diff --git a/hw/usb-msd.c b/hw/usb-msd.c index e090014f74..dd3010e006 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -571,7 +571,8 @@ USBDevice *usb_msd_init(const char *filename) /* create guest device */ dev = usb_create(NULL /* FIXME */, "QEMU USB MSD"); qdev_prop_set_drive(&dev->qdev, "drive", dinfo); - qdev_init(&dev->qdev); + if (qdev_init(&dev->qdev) < 0) + return NULL; return dev; } |