qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: peter.maydell@linaro.org, Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, anthony@codemonkey.ws
Subject: Re: [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming
Date: Thu, 12 Sep 2013 16:40:11 +0200	[thread overview]
Message-ID: <5231D24B.6080809@suse.de> (raw)
In-Reply-To: <5220D416.4030102@suse.de>

Am 30.08.2013 19:19, schrieb Andreas Färber:
> 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.

Clarified the commit message and applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next

Andreas

> 
> 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 <afaerber@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

  reply	other threads:[~2013-09-12 14:40 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-24  0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 01/16] qom: Fix object_initialize_with_type() argument name in documentation Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 02/16] intel-hda: Pass size to hda_codec_bus_init() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 03/16] ipack: Pass size to ipack_bus_new_inplace() Andreas Färber
2013-08-26  7:23   ` Wenchao Xia
2013-08-24  0:00 ` [Qemu-devel] [PATCH 04/16] ide: Pass size to ide_bus_new() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 05/16] pci: Pass size to pci_bus_new_inplace() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 06/16] scsi: Pass size to scsi_bus_new() Andreas Färber
2013-08-26  8:01   ` Paolo Bonzini
2013-08-24  0:00 ` [Qemu-devel] [PATCH 07/16] usb: Pass size to usb_bus_new() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 08/16] virtio-pci: Pass size to virtio_pci_bus_new() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 09/16] s390-virtio-bus: Pass size to virtio_s390_bus_new() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 10/16] virtio-ccw: Pass size to virtio_ccw_bus_new() Andreas Färber
2013-08-26  8:00   ` Cornelia Huck
2013-08-24  0:00 ` [Qemu-devel] [PATCH 11/16] virtio-mmio: Pass size to virtio_mmio_bus_new() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace() Andreas Färber
2013-08-26  7:44   ` Wenchao Xia
2013-08-30 17:12     ` Andreas Färber
2013-08-26  8:03   ` Cornelia Huck
2013-08-30 17:05     ` Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize() Andreas Färber
2013-08-26  8:09   ` Cornelia Huck
2013-08-26  8:11   ` Wenchao Xia
2013-08-30 17:14     ` Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 14/16] qom: Introduce type_get_instance_size() Andreas Färber
2013-08-24  0:00 ` [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming Andreas Färber
2013-08-26  7:52   ` Wenchao Xia
2013-08-30 17:19     ` Andreas Färber
2013-09-12 14:40       ` Andreas Färber [this message]
2013-08-24  0:00 ` [Qemu-devel] [PATCH 16/16] qdev-monitor: Avoid aborting on out-of-memory in qdev_device_add() Andreas Färber
2013-08-26  8:12 ` [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Wenchao Xia
2013-08-30 19:37 ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5231D24B.6080809@suse.de \
    --to=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=xiawenc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).