[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] Revised: Add object_property_get_child().
From: |
Alexander Barabash |
Subject: |
Re: [Qemu-devel] [PATCH v2] Revised: Add object_property_get_child(). |
Date: |
Mon, 20 Feb 2012 17:06:08 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
On 02/19/2012 07:14 PM, Andreas Färber wrote:
Am 19.02.2012 17:04, schrieb Alexander Barabash:
...
Signed-off-by: Alexander Barabash<address@hidden>
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
Thanks for the advice.
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().
OK
+/* 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.
I replaced "5" (i.e. the length "link<") with
"sizeof(LINK_PROPERTY_TYPE_PREFIX) - 1".
If we assume that "strlen("link<") is always optimized away,
then certainly using strlen is equivalent and looks better.
Andreas
Alex
- [Qemu-devel] [PATCH] Add object_property_get_child()., Alexander Barabash, 2012/02/16
- Re: [Qemu-devel] [PATCH] Add object_property_get_child()., Peter Maydell, 2012/02/16
- Re: [Qemu-devel] [PATCH] Add object_property_get_child()., Paolo Bonzini, 2012/02/17
- Re: [Qemu-devel] [PATCH] Add object_property_get_child()., Paolo Bonzini, 2012/02/20
- Re: [Qemu-devel] [PATCH] Add object_property_get_child()., Alexander Barabash, 2012/02/20
- Re: [Qemu-devel] [PATCH] Add object_property_get_child()., Paolo Bonzini, 2012/02/20