Re: [PATCH 06/10] conf: Introduce virDomainDeviceInfoNew()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 29, 2017 at 20:03:59 +0200, Andrea Bolognani wrote:
> It allocates and initializes a virDomainDeviceInfo struct
> in one fell swoop.
> 
> Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
> ---
>  src/conf/device_conf.c | 13 +++++++++++++
>  src/conf/device_conf.h |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
> index 4644580..6ead830 100644
> --- a/src/conf/device_conf.c
> +++ b/src/conf/device_conf.c
> @@ -32,6 +32,19 @@
>  
>  #define VIR_FROM_THIS VIR_FROM_DEVICE
>  
> +virDomainDeviceInfoPtr
> +virDomainDeviceInfoNew(void)
> +{
> +    virDomainDeviceInfoPtr info;
> +
> +    if (VIR_ALLOC(info) < 0)
> +        return NULL;
> +
> +    virDomainDeviceInfoClear(info);

This is a lot of duplicated 0 setting. Given a quick scroll to the other
*New function ... we only set parameters which are non-null. 

The only code path calling the clearing fucntion which is not in a
fucntion which then frees the object completely is in
virDomainDeviceInfoParseXML. I don't think we need to do it here and
additionally the objects are not reused thus you should not need to set
anything non-null anywhere else.

ACK to the wrapper except for the call to virDomainDeviceInfoClear

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux