[libvirt] [PATCH v3 06/34] Adapt to VIR_STRDUP and VIR_STRNDUP in src/hyperv/*

Eric Blake eblake at redhat.com
Tue May 7 03:52:48 UTC 2013


On 05/03/2013 08:53 AM, Michal Privoznik wrote:
> ---
>  src/hyperv/hyperv_driver.c | 50 ++++++++++------------------------------------
>  src/hyperv/hyperv_util.c   | 18 +++++------------
>  2 files changed, 15 insertions(+), 53 deletions(-)
> 

> @@ -908,21 +895,12 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
>          return NULL;
>      }
>  
> -    def->name = strdup(computerSystem->data->ElementName);
> -
> -    if (def->name == NULL) {
> -        virReportOOMError();
> +    if (VIR_STRDUP(def->name, computerSystem->data->ElementName) < 0)
>          goto cleanup;
> -    }
> -
> -    if (virtualSystemSettingData->data->Notes != NULL) {
> -        def->description = strdup(virtualSystemSettingData->data->Notes);
>  
> -        if (def->description == NULL) {
> -            virReportOOMError();
> -            goto cleanup;
> -        }
> -    }
> +    if (virtualSystemSettingData->data->Notes &&
> +        VIR_STRDUP(def->description, virtualSystemSettingData->data->Notes) < 0)

Could be simplified by allowing a NULL source (and this time, I actually
posted that proposal:
https://www.redhat.com/archives/libvir-list/2013-May/msg00458.html)

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130506/1f9e5bca/attachment-0001.sig>


More information about the libvir-list mailing list