[Libvirt-cim] [PATCH 3/3] ACL: Use linked list helper for filter refs
Eduardo Lima (Etrunko)
eblima at linux.vnet.ibm.com
Wed Feb 1 23:49:41 UTC 2012
On 02/01/2012 08:10 PM, Sharad Mishra wrote:
> On Tue, 2012-01-31 at 19:58 -0200, Eduardo Lima (Etrunko) wrote:
>> From: "Eduardo Lima (Etrunko)" <eblima at br.ibm.com>
>>
[snip]
>> char *filter_to_xml(struct acl_filter *filter)
>> {
>> char *xml = NULL;
>> xmlNodePtr root = NULL;
>> xmlNodePtr tmp = NULL;
>> - int i;
>>
>> root = xmlNewNode(NULL, BAD_CAST "filter");
>> if (root == NULL)
>> @@ -1494,12 +1514,8 @@ char *filter_to_xml(struct acl_filter *filter)
>> goto out;
>> }
>>
>> - for (i = 0; i < filter->ref_ct; i++) {
>> - tmp = xmlNewChild(root, NULL, BAD_CAST "filterref", NULL);
>> - if (xmlNewProp(tmp, BAD_CAST "filter",
>> - BAD_CAST filter->refs[i]) == NULL)
>> - goto out;
>> - }
>> + if (!list_foreach(filter->refs, filter_ref_foreach, (void *) root))
>
> why call list_foreach(), why not call filter_ref_foreach() directly?
Because I want to call the function for every node in the list. This is
exactly what the previous loop was doing. If I call this
filter_ref_foreach() directly, it will be called only once.
Best regards,
--
Eduardo de Barros Lima
Software Engineer, Open Virtualization
Linux Technology Center - IBM/Brazil
eblima at br.ibm.com
More information about the Libvirt-cim
mailing list