Message ID | 20230203180914.49112-8-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw: Set QDev properties using QDev API (part 1/3) | expand |
On Fri, 3 Feb 2023 19:09:02 +0100 Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > No need to use the low-level QOM API when an object > inherits from QDev. Directly use the QDev API to set > its properties. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/scsi/scsi-bus.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c > index ceceafb2cd..a8003126c4 100644 > --- a/hw/scsi/scsi-bus.c > +++ b/hw/scsi/scsi-bus.c > @@ -347,11 +347,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, > object_unparent(OBJECT(dev)); > return NULL; > } > - if (!object_property_set_bool(OBJECT(dev), "share-rw", share_rw, errp)) { > - object_unparent(OBJECT(dev)); > - return NULL; > - } > - > + qdev_prop_set_bit(dev, "share-rw", share_rw); likely broken, see cover letter reply (I'm stopping here, series should be rewritten to drop unjustified conversions or commit message describe why it's safe) > qdev_prop_set_enum(dev, "rerror", rerror); > qdev_prop_set_enum(dev, "werror", werror); >
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index ceceafb2cd..a8003126c4 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -347,11 +347,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, object_unparent(OBJECT(dev)); return NULL; } - if (!object_property_set_bool(OBJECT(dev), "share-rw", share_rw, errp)) { - object_unparent(OBJECT(dev)); - return NULL; - } - + qdev_prop_set_bit(dev, "share-rw", share_rw); qdev_prop_set_enum(dev, "rerror", rerror); qdev_prop_set_enum(dev, "werror", werror);
No need to use the low-level QOM API when an object inherits from QDev. Directly use the QDev API to set its properties. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/scsi/scsi-bus.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)