提交 94b57a9d 编写于 作者: J Ján Tomko

Use size_t for ndevice in pool source definition

This allows it to be used by the VIR_*_ELEMENT macros.

Also use them for parsing the definiton and remove the redundant
freeing of 'nodeset' before jumping to the cleanup label.
上级 20f0cd4c
...@@ -642,23 +642,20 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, ...@@ -642,23 +642,20 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
if (nsource < 0) if (nsource < 0)
goto cleanup; goto cleanup;
if (nsource > 0) { for (i = 0; i < nsource; i++) {
if (VIR_ALLOC_N(source->devices, nsource) < 0) { virStoragePoolSourceDevice dev = { .path = NULL };
VIR_FREE(nodeset); dev.path = virXMLPropString(nodeset[i], "path");
if (dev.path == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing storage pool source device path"));
goto cleanup; goto cleanup;
} }
for (i = 0; i < nsource; i++) { if (VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev) < 0) {
char *path = virXMLPropString(nodeset[i], "path"); virStoragePoolSourceDeviceClear(&dev);
if (path == NULL) { goto cleanup;
VIR_FREE(nodeset);
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing storage pool source device path"));
goto cleanup;
}
source->devices[i].path = path;
} }
source->ndevice = nsource;
} }
source->dir = virXPathString("string(./dir/@path)", ctxt); source->dir = virXPathString("string(./dir/@path)", ctxt);
......
...@@ -266,7 +266,7 @@ struct _virStoragePoolSource { ...@@ -266,7 +266,7 @@ struct _virStoragePoolSource {
virStoragePoolSourceHostPtr hosts; virStoragePoolSourceHostPtr hosts;
/* And either one or more devices ... */ /* And either one or more devices ... */
int ndevice; size_t ndevice;
virStoragePoolSourceDevicePtr devices; virStoragePoolSourceDevicePtr devices;
/* Or a directory */ /* Or a directory */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册