From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK84E-0002c3-Et for qemu-devel@nongnu.org; Thu, 12 Sep 2013 10:40:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK849-0007mV-5v for qemu-devel@nongnu.org; Thu, 12 Sep 2013 10:40:22 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40202 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK848-0007mJ-SP for qemu-devel@nongnu.org; Thu, 12 Sep 2013 10:40:17 -0400 Message-ID: <5231D24B.6080809@suse.de> Date: Thu, 12 Sep 2013 16:40:11 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1377302436-25193-1-git-send-email-afaerber@suse.de> <1377302436-25193-16-git-send-email-afaerber@suse.de> <521B0925.6080300@linux.vnet.ibm.com> <5220D416.4030102@suse.de> In-Reply-To: <5220D416.4030102@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: peter.maydell@linaro.org, Stefan Hajnoczi , qemu-devel@nongnu.org, anthony@codemonkey.ws Am 30.08.2013 19:19, schrieb Andreas F=C3=A4rber: > Am 26.08.2013 09:52, schrieb Wenchao Xia: >> =E4=BA=8E 2013-8-24 8:00, Andreas F=C3=A4rber =E5=86=99=E9=81=93: >>> Avoid confusion between object and object class. >> between object class and device class? >=20 > No the issue is that by convention we usually use >=20 > Object *obj; > ObjectClass *oc; /* previously: klass or k */ >=20 > rather than >=20 > ObjectClass *obj; >=20 > 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 >=20 > This part of the series is not so important yet, so we can give it some > more review and thought. >=20 > Regards, > Andreas >=20 >> >>> Tidy DeviceClass variable while at it. >>> >>> Signed-off-by: Andreas F=C3=A4rber >>> --- >>> 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 =3D NULL; >>> @@ -457,22 +457,22 @@ DeviceState *qdev_device_add(QemuOpts *opts) >>> } >>> >>> /* find driver */ >>> - obj =3D object_class_by_name(driver); >>> - if (!obj) { >>> + oc =3D object_class_by_name(driver); >>> + if (!oc) { >>> const char *typename =3D find_typename_by_alias(driver); >>> >>> if (typename) { >>> driver =3D typename; >>> - obj =3D object_class_by_name(driver); >>> + oc =3D object_class_by_name(driver); >>> } >>> } >>> >>> - if (!obj) { >>> + if (!oc) { >>> qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", >>> "device type"); >>> return NULL; >>> } >>> >>> - k =3D DEVICE_CLASS(obj); >>> + dc =3D DEVICE_CLASS(oc); >>> >>> /* find bus */ >>> path =3D 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 !=3D NULL) { >>> - bus =3D qbus_find_recursive(sysbus_get_default(), NULL, >>> k->bus_type); >>> + } else if (dc->bus_type !=3D NULL) { >>> + bus =3D 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; >>> } >>> } >>> >> >> >=20 >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg