[Libvirt-cim] [PATCH 02/47] Add others and unknown_device clean up

Boris Fiuczynski fiuczy at linux.vnet.ibm.com
Mon Oct 14 08:48:43 UTC 2013



Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

On 10/08/2013 08:13 AM, Xu Wang wrote:
> Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
> ---
>   libxkutil/device_parsing.c |   53 ++++++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 53 insertions(+), 0 deletions(-)
>
> diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
> index 7900e06..ea84d07 100644
> --- a/libxkutil/device_parsing.c
> +++ b/libxkutil/device_parsing.c
> @@ -52,6 +52,49 @@
>   /* Device parse function */
>   typedef int (*dev_parse_func_t)(xmlNode *, struct virt_device **);
>
> +static void cleanup_node_of_others(struct others *others)
> +{
> +        if (others == NULL) {
> +                return;
> +        }
remove curly brackets
> +
> +        if (others->name) {
> +                free(others->name);
> +        }
> +
> +        if (others->parent) {
> +                free(others->parent);
> +        }
> +
> +        if (others->value) {
> +                free(others->value);
> +        }
All other cleanup methods neglect the NULL check.
> +
> +        free(others);
> +}
> +
> +static void cleanup_others(struct others *others)
> +{
> +        struct others *head = others;
> +
> +        if (others == NULL)
> +                return;
> +
> +        while (head) {
You could join the three lines above into "while (others) {"
> +                head = others->next;
> +                cleanup_node_of_others(others);
> +                others = head;
> +        }
> +}
> +
> +static void cleanup_unknown_device(struct unknown_device *dev)
> +{
> +        if (dev == NULL)
> +                return;
free(dev->name); ???
> +
> +        cleanup_others(dev->others);
> +}
> +
>   static void cleanup_disk_device(struct disk_device *dev)
>   {
>           if (dev == NULL)
> @@ -66,6 +109,7 @@ static void cleanup_disk_device(struct disk_device *dev)
>           free(dev->virtual_dev);
>           free(dev->bus_type);
>           free(dev->access_mode);
> +        cleanup_others(dev->others);
>   }
>
>   static void cleanup_vsi_device(struct vsi_device *dev)
> @@ -94,6 +138,7 @@ static void cleanup_net_device(struct net_device *dev)
>           free(dev->device);
>           free(dev->net_mode);
>           free(dev->filter_ref);
> +        cleanup_others(dev->others);
>   }
>
>   static void cleanup_emu_device(struct emu_device *dev)
> @@ -102,6 +147,7 @@ static void cleanup_emu_device(struct emu_device *dev)
>                   return;
>
>           free(dev->path);
> +        cleanup_others(dev->others);
>   }
>
>   static void cleanup_vnc_device(struct graphics_device *dev)
> @@ -110,6 +156,7 @@ static void cleanup_vnc_device(struct graphics_device *dev)
>           free(dev->dev.vnc.host);
>           free(dev->dev.vnc.keymap);
>           free(dev->dev.vnc.passwd);
> +        cleanup_others(dev->dev.vnc.others);
>   }
>
>   static void cleanup_sdl_device(struct graphics_device *dev)
> @@ -117,6 +164,7 @@ static void cleanup_sdl_device(struct graphics_device *dev)
>           free(dev->dev.sdl.display);
>           free(dev->dev.sdl.xauth);
>           free(dev->dev.sdl.fullscreen);
> +        cleanup_others(dev->dev.sdl.others);
>   }
>
>   static void cleanup_graphics_device(struct graphics_device *dev)
> @@ -130,6 +178,7 @@ static void cleanup_graphics_device(struct graphics_device *dev)
>                   cleanup_vnc_device(dev);
>
>           free(dev->type);
> +        cleanup_others(dev->others);
>   }
>
>   static void cleanup_input_device(struct input_device *dev)
> @@ -139,6 +188,7 @@ static void cleanup_input_device(struct input_device *dev)
>
>           free(dev->type);
>           free(dev->bus);
> +        cleanup_others(dev->others);
>   }
>
>   void cleanup_virt_device(struct virt_device *dev)
> @@ -156,6 +206,8 @@ void cleanup_virt_device(struct virt_device *dev)
>                   cleanup_graphics_device(&dev->dev.graphics);
>           else if (dev->type == CIM_RES_TYPE_INPUT)
>                   cleanup_input_device(&dev->dev.input);
> +        else if (dev->type == CIM_RES_TYPE_UNKNOWN)
> +                cleanup_unknown_device(&dev->dev.unknown);
>
>           free(dev->id);
>
> @@ -1351,6 +1403,7 @@ void cleanup_dominfo(struct domain **dominfo)
>           cleanup_virt_devices(&dom->dev_vcpu, dom->dev_vcpu_ct);
>           cleanup_virt_devices(&dom->dev_graphics, dom->dev_graphics_ct);
>           cleanup_virt_devices(&dom->dev_input, dom->dev_input_ct);
> +        cleanup_virt_devices(&dom->dev_unknown, dom->dev_unknown_ct);
>
cleanup_others(dom->others); ???
>           free(dom);
>




More information about the Libvirt-cim mailing list