From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:57510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzALc-0002BA-2i for qemu-devel@nongnu.org; Sun, 19 Feb 2012 12:14:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzALa-0004xR-8M for qemu-devel@nongnu.org; Sun, 19 Feb 2012 12:14:52 -0500 Received: from cantor2.suse.de ([195.135.220.15]:53706 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzALZ-0004xM-SN for qemu-devel@nongnu.org; Sun, 19 Feb 2012 12:14:50 -0500 Message-ID: <4F412E06.8020104@suse.de> Date: Sun, 19 Feb 2012 18:14:46 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <4F3D3F67.9050506@mentor.com> <4F3E2945.3000603@redhat.com> <4F40ECC6.8000603@mentor.com> <4F411D76.9020105@mentor.com> In-Reply-To: <4F411D76.9020105@mentor.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] Revised: Add object_property_get_child(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Barabash Cc: Paolo Bonzini , qemu-devel Am 19.02.2012 17:04, schrieb Alexander Barabash: >=20 > Add object_property_get_child(). >=20 > Adding a direct accessor to a child property. >=20 > In the existing implementation, object_property_get() must be used, > with with a visitor, implementing the 'type_str' callback, > receiving the child's canonical path. >=20 > In the new implementation, the child is returned directly. > For link properties, object_property_get_link() is used > to resolve the link. >=20 > Also, in the new implementation, object_property_get_child() is use= d > as a subroutine of object_resolve_abs_path(). This changes the way > object_resolve_abs_path() operates, moving away from directly peeki= ng > the property's 'opaque' field to using object_property_get_link(). >=20 > Thus, in the mew implementation link properties are resolved in the > same way, > as they are when an absolute path is resolved. >=20 > Errors relevant to the operation, QERR_OBJECT_PROPERTY_NOT_FOUND > and QERR_OBJECT_PROPERTY_INVALID_TYPE were added. >=20 > Also, in the new implementation, some common sense refactoring was = done > in the file 'qom/object.c' in the code extracting child and link > properties. >=20 > Signed-off-by: Alexander Barabash Please use git-send-email to submit your patches: The commit message is unnecessarily indented and the first line is duplicated. Instead of "Revised: " (which v2 already indicates) the subject should mention the topic, here "qom: ". http://wiki.qemu.org/Contribute/SubmitAPatch Your patch is doing too many things at once. Please split it up into a series of easily digestable and bisectable patches, e.g.: * ..._PREFIX/SUFFIX introduction and use in _add_child/link, * ..._is_child/_is_link introduction and use in _property_del_child/_get_canonical_path/_resolve_partial_path, * link_type_to_type() and use in _set_link_property, * REPORT_OBJECT_ERROR(), * object_property_get_child(). > +/* Go from LINK_PROPERTY_TYPE_PREFIX FOO LINK_PROPERTY_TYPE_SUFFIX to > FOO. */ > +static gchar *link_type_to_type(const gchar *type) > +{ > + return g_strndup(&type[sizeof(LINK_PROPERTY_TYPE_PREFIX) - 1], > + strlen(type) > + - (sizeof(LINK_PROPERTY_TYPE_PREFIX) - 1) > + - (sizeof(LINK_PROPERTY_TYPE_SUFFIX) - 1)); Any reason not to use strlen()? I don't think this is a hot path, and repeated sizeof() - 1 does not read so nice. The alternative would be to hardcode the offsets. Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg