Am 26.08.2013 09:52, schrieb Wenchao Xia: > 于 2013-8-24 8:00, Andreas Färber 写道: >> Avoid confusion between object and object class. > between object class and device class?
No the issue is that by convention we usually use Object *obj; ObjectClass *oc; /* previously: klass or k */ rather than ObjectClass *obj; That makes the code more difficult to read. This part of the series is not so important yet, so we can give it some more review and thought. Regards, Andreas > >> Tidy DeviceClass variable while at it. >> >> Signed-off-by: Andreas Färber <afaer...@suse.de> >> --- >> qdev-monitor.c | 22 +++++++++++----------- >> 1 file changed, 11 insertions(+), 11 deletions(-) >> >> diff --git a/qdev-monitor.c b/qdev-monitor.c >> index 410cdcb..51bfec0 100644 >> --- a/qdev-monitor.c >> +++ b/qdev-monitor.c >> @@ -444,8 +444,8 @@ static BusState *qbus_find(const char *path) >> >> DeviceState *qdev_device_add(QemuOpts *opts) >> { >> - ObjectClass *obj; >> - DeviceClass *k; >> + ObjectClass *oc; >> + DeviceClass *dc; >> const char *driver, *path, *id; >> DeviceState *qdev; >> BusState *bus = NULL; >> @@ -457,22 +457,22 @@ DeviceState *qdev_device_add(QemuOpts *opts) >> } >> >> /* find driver */ >> - obj = object_class_by_name(driver); >> - if (!obj) { >> + oc = object_class_by_name(driver); >> + if (!oc) { >> const char *typename = find_typename_by_alias(driver); >> >> if (typename) { >> driver = typename; >> - obj = object_class_by_name(driver); >> + oc = object_class_by_name(driver); >> } >> } >> >> - if (!obj) { >> + if (!oc) { >> qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", >> "device type"); >> return NULL; >> } >> >> - k = DEVICE_CLASS(obj); >> + dc = DEVICE_CLASS(oc); >> >> /* find bus */ >> path = qemu_opt_get(opts, "bus"); >> @@ -481,16 +481,16 @@ DeviceState *qdev_device_add(QemuOpts *opts) >> if (!bus) { >> return NULL; >> } >> - if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) { >> + if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) { >> qerror_report(QERR_BAD_BUS_FOR_DEVICE, >> driver, object_get_typename(OBJECT(bus))); >> return NULL; >> } >> - } else if (k->bus_type != NULL) { >> - bus = qbus_find_recursive(sysbus_get_default(), NULL, >> k->bus_type); >> + } else if (dc->bus_type != NULL) { >> + bus = qbus_find_recursive(sysbus_get_default(), NULL, >> dc->bus_type); >> if (!bus) { >> qerror_report(QERR_NO_BUS_FOR_DEVICE, >> - k->bus_type, driver); >> + dc->bus_type, driver); >> return NULL; >> } >> } >> > > -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg