There are multiple functions where OBJECT_GET_CLASS or OBJECT_CLASS_CHECK are being used directly for DeviceClass/TYPE_DEVICE, instead of the DEVICE_GET_CLASS or DEVICE_CLASS wrappers. There's no reason to not use the wrappers, so use them.
Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- Cc: "Michael S. Tsirkin" <m...@redhat.com> Cc: Marcel Apfelbaum <marcel.apfelb...@gmail.com> Cc: Gerd Hoffmann <kra...@redhat.com> Cc: Juan Quintela <quint...@redhat.com> Cc: "Dr. David Alan Gilbert" <dgilb...@redhat.com> Cc: Markus Armbruster <arm...@redhat.com> Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: "Daniel P. Berrangé" <berra...@redhat.com> Cc: Eduardo Habkost <ehabk...@redhat.com> Cc: qemu-devel@nongnu.org --- hw/pci/pci.c | 3 +-- hw/usb/hcd-ehci-pci.c | 2 +- migration/savevm.c | 3 +-- monitor/misc.c | 3 +-- softmmu/qdev-monitor.c | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 23d2ae2ab23..9af32ef4cb8 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1915,8 +1915,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus, list = object_class_get_list_sorted(TYPE_PCI_DEVICE, false); pci_nic_models = g_ptr_array_new(); while (list) { - DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, list->data, - TYPE_DEVICE); + DeviceClass *dc = DEVICE_CLASS(list->data); GSList *next; if (test_bit(DEVICE_CATEGORY_NETWORK, dc->categories) && dc->user_creatable) { diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 4c37c8e2271..345444a5739 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -74,7 +74,7 @@ static void usb_ehci_pci_realize(PCIDevice *dev, Error **errp) static void usb_ehci_pci_init(Object *obj) { - DeviceClass *dc = OBJECT_GET_CLASS(DeviceClass, obj, TYPE_DEVICE); + DeviceClass *dc = DEVICE_GET_CLASS(obj); EHCIPCIState *i = PCI_EHCI(obj); EHCIState *s = &i->ehci; diff --git a/migration/savevm.c b/migration/savevm.c index 7b7b64bd13e..23cc55b8533 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -663,8 +663,7 @@ void dump_vmstate_json_to_file(FILE *out_file) first = true; list = object_class_get_list(TYPE_DEVICE, true); for (elt = list; elt; elt = elt->next) { - DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data, - TYPE_DEVICE); + DeviceClass *dc = DEVICE_CLASS(elt->data); const char *name; int indent = 2; diff --git a/monitor/misc.c b/monitor/misc.c index ffe79668706..98202d12e7f 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1549,8 +1549,7 @@ void device_add_completion(ReadLineState *rs, int nb_args, const char *str) list = elt = object_class_get_list(TYPE_DEVICE, false); while (elt) { const char *name; - DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data, - TYPE_DEVICE); + DeviceClass *dc = DEVICE_CLASS(elt->data); name = object_class_get_name(OBJECT_CLASS(dc)); if (dc->user_creatable diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 721dec2d820..82d164c6539 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -165,8 +165,7 @@ static void qdev_print_devinfos(bool show_no_user) for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) { cat_printed = false; for (elt = list; elt; elt = elt->next) { - DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data, - TYPE_DEVICE); + DeviceClass *dc = DEVICE_CLASS(elt->data); if ((i < DEVICE_CATEGORY_MAX ? !test_bit(i, dc->categories) : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX)) -- 2.31.1