util: Introduce function for allocating virStorageSource

Add virStorageSourceNew and refactor places allocating that structure to
use the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Peter Krempa
2019-02-14 16:20:25 +01:00
parent 84966103be
commit dcda2bf4c1
14 changed files with 37 additions and 23 deletions

View File

@@ -55,7 +55,7 @@ testBackingXMLjsonXML(const void *args)
VIR_AUTOPTR(virStorageSource) xmlsrc = NULL;
VIR_AUTOPTR(virStorageSource) jsonsrc = NULL;
if (VIR_ALLOC(xmlsrc) < 0)
if (!(xmlsrc = virStorageSourceNew()))
return -1;
xmlsrc->type = data->type;

View File

@@ -98,7 +98,7 @@ testStorageFileGetMetadata(const char *path,
virStorageSourcePtr ret = NULL;
VIR_AUTOPTR(virStorageSource) def = NULL;
if (VIR_ALLOC(def) < 0)
if (!(def = virStorageSourceNew()))
return NULL;
def->type = VIR_STORAGE_TYPE_FILE;