Patchwork [7/7] Clean up test for qdev_init() failure

login
register
mail settings
Submitter Markus Armbruster
Date Oct. 6, 2009, 11:16 p.m.
Message ID <0a20f6c853f7819bf9161c63c4a004855d2f99c8.1254867902.git.armbru@redhat.com>
Download mbox | patch
Permalink /patch/35171/
State Accepted
Headers show

Comments

Markus Armbruster - Oct. 6, 2009, 11:16 p.m.
Some callers test for != 0, some for < 0.  Normalize to < 0.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/fdc.c      |    2 +-
 hw/ide/isa.c  |    2 +-
 hw/ide/qdev.c |    2 +-
 hw/parallel.c |    2 +-
 hw/qdev.c     |    2 +-
 hw/serial.c   |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/fdc.c b/hw/fdc.c
index f1b2f9a..a21e05f 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1847,7 +1847,7 @@  fdctrl_t *fdctrl_init_isa(DriveInfo **fds)
     dev = isa_create("isa-fdc");
     qdev_prop_set_drive(&dev->qdev, "driveA", fds[0]);
     qdev_prop_set_drive(&dev->qdev, "driveB", fds[1]);
-    if (qdev_init(&dev->qdev) != 0)
+    if (qdev_init(&dev->qdev) < 0)
         return NULL;
     return &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
 }
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 3205f40..9f0fdd6 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -85,7 +85,7 @@  int isa_ide_init(int iobase, int iobase2, int isairq,
     qdev_prop_set_uint32(&dev->qdev, "iobase",  iobase);
     qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2);
     qdev_prop_set_uint32(&dev->qdev, "irq",     isairq);
-    if (qdev_init(&dev->qdev) != 0)
+    if (qdev_init(&dev->qdev) < 0)
         return -1;
 
     s = DO_UPCAST(ISAIDEState, dev, dev);
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index c562bc6..81e7995 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -85,7 +85,7 @@  IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive)
     dev = qdev_create(&bus->qbus, "ide-drive");
     qdev_prop_set_uint32(dev, "unit", unit);
     qdev_prop_set_drive(dev, "drive", drive);
-    if (qdev_init(dev) != 0)
+    if (qdev_init(dev) < 0)
         return NULL;
     return DO_UPCAST(IDEDevice, qdev, dev);
 }
diff --git a/hw/parallel.c b/hw/parallel.c
index 2635edc..92eecb1 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -493,7 +493,7 @@  ParallelState *parallel_init(int index, CharDriverState *chr)
     qdev_prop_set_uint32(&dev->qdev, "iobase", isa_parallel_io[index]);
     qdev_prop_set_uint32(&dev->qdev, "irq", 7);
     qdev_prop_set_chr(&dev->qdev, "chardev", chr);
-    if (qdev_init(&dev->qdev) != 0)
+    if (qdev_init(&dev->qdev) < 0)
         return NULL;
     return &DO_UPCAST(ISAParallelState, dev, dev)->state;
 }
diff --git a/hw/qdev.c b/hw/qdev.c
index ca60923..906e897 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -214,7 +214,7 @@  DeviceState *qdev_device_add(QemuOpts *opts)
         qdev_free(qdev);
         return NULL;
     }
-    if (qdev_init(qdev) != 0) {
+    if (qdev_init(qdev) < 0) {
         qemu_error("Error initializing device %s\n", driver);
         return NULL;
     }
diff --git a/hw/serial.c b/hw/serial.c
index e044923..eb14f11 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -759,7 +759,7 @@  SerialState *serial_isa_init(int index, CharDriverState *chr)
     qdev_prop_set_uint32(&dev->qdev, "iobase", isa_serial_io[index]);
     qdev_prop_set_uint32(&dev->qdev, "irq", isa_serial_irq[index]);
     qdev_prop_set_chr(&dev->qdev, "chardev", chr);
-    if (qdev_init(&dev->qdev) != 0)
+    if (qdev_init(&dev->qdev) < 0)
         return NULL;
     return &DO_UPCAST(ISASerialState, dev, dev)->state;
 }