mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virsh-completer: unify cleanup of items in name completers
Merge the cleanup of fetched items for the success and the error paths. Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3b16c3a10b
commit
81723acebd
@ -104,20 +104,17 @@ virshDomainNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virshDomainFree(domains[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(domains);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < ndomains; i++)
|
||||||
|
virshDomainFree(domains[i]);
|
||||||
|
VIR_FREE(domains);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < ndomains; i++)
|
|
||||||
virshDomainFree(domains[i]);
|
|
||||||
VIR_FREE(domains);
|
|
||||||
for (i = 0; i < ndomains; i++)
|
for (i = 0; i < ndomains; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -257,20 +254,17 @@ virshStoragePoolNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virStoragePoolFree(pools[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(pools);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < npools; i++)
|
||||||
|
virStoragePoolFree(pools[i]);
|
||||||
|
VIR_FREE(pools);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < npools; i++)
|
|
||||||
virStoragePoolFree(pools[i]);
|
|
||||||
VIR_FREE(pools);
|
|
||||||
for (i = 0; i < npools; i++)
|
for (i = 0; i < npools; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -312,26 +306,21 @@ virshStorageVolNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virStorageVolFree(vols[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(vols);
|
|
||||||
virStoragePoolFree(pool);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virStoragePoolFree(pool);
|
||||||
|
for (i = 0; i < nvols; i++)
|
||||||
|
virStorageVolFree(vols[i]);
|
||||||
|
VIR_FREE(vols);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < nvols; i++)
|
|
||||||
virStorageVolFree(vols[i]);
|
|
||||||
VIR_FREE(vols);
|
|
||||||
for (i = 0; i < nvols; i++)
|
for (i = 0; i < nvols; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
virStoragePoolFree(pool);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,20 +355,17 @@ virshInterfaceNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virInterfaceFree(ifaces[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(ifaces);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < nifaces; i++)
|
||||||
|
virInterfaceFree(ifaces[i]);
|
||||||
|
VIR_FREE(ifaces);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < nifaces; i++)
|
|
||||||
virInterfaceFree(ifaces[i]);
|
|
||||||
VIR_FREE(ifaces);
|
|
||||||
for (i = 0; i < nifaces; i++)
|
for (i = 0; i < nifaces; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -418,20 +404,17 @@ virshNetworkNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virNetworkFree(nets[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(nets);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < nnets; i++)
|
||||||
|
virNetworkFree(nets[i]);
|
||||||
|
VIR_FREE(nets);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < nnets; i++)
|
|
||||||
virNetworkFree(nets[i]);
|
|
||||||
VIR_FREE(nets);
|
|
||||||
for (i = 0; i < nnets; i++)
|
for (i = 0; i < nnets; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -497,20 +480,17 @@ virshNodeDeviceNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virNodeDeviceFree(devs[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(devs);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < ndevs; i++)
|
||||||
|
virNodeDeviceFree(devs[i]);
|
||||||
|
VIR_FREE(devs);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < ndevs; i++)
|
|
||||||
virNodeDeviceFree(devs[i]);
|
|
||||||
VIR_FREE(devs);
|
|
||||||
for (i = 0; i < ndevs; i++)
|
for (i = 0; i < ndevs; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -546,20 +526,17 @@ virshNWFilterNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virNWFilterFree(nwfilters[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(nwfilters);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < nnwfilters; i++)
|
||||||
|
virNWFilterFree(nwfilters[i]);
|
||||||
|
VIR_FREE(nwfilters);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < nnwfilters; i++)
|
|
||||||
virNWFilterFree(nwfilters[i]);
|
|
||||||
VIR_FREE(nwfilters);
|
|
||||||
for (i = 0; i < nnwfilters; i++)
|
for (i = 0; i < nnwfilters; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -595,20 +572,17 @@ virshNWFilterBindingNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virNWFilterBindingFree(bindings[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(bindings);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < nbindings; i++)
|
||||||
|
virNWFilterBindingFree(bindings[i]);
|
||||||
|
VIR_FREE(bindings);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < nbindings; i++)
|
|
||||||
virNWFilterBindingFree(bindings[i]);
|
|
||||||
VIR_FREE(bindings);
|
|
||||||
for (i = 0; i < nbindings; i++)
|
for (i = 0; i < nbindings; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -645,20 +619,17 @@ virshSecretUUIDCompleter(vshControl *ctl,
|
|||||||
if (virSecretGetUUIDString(secrets[i], uuid) < 0 ||
|
if (virSecretGetUUIDString(secrets[i], uuid) < 0 ||
|
||||||
VIR_STRDUP(tmp[i], uuid) < 0)
|
VIR_STRDUP(tmp[i], uuid) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virSecretFree(secrets[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(secrets);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < nsecrets; i++)
|
||||||
|
virSecretFree(secrets[i]);
|
||||||
|
VIR_FREE(secrets);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < nsecrets; i++)
|
|
||||||
virSecretFree(secrets[i]);
|
|
||||||
VIR_FREE(secrets);
|
|
||||||
for (i = 0; i < nsecrets; i++)
|
for (i = 0; i < nsecrets; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -700,25 +671,21 @@ virshSnapshotNameCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
if (VIR_STRDUP(tmp[i], name) < 0)
|
if (VIR_STRDUP(tmp[i], name) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
virshDomainSnapshotFree(snapshots[i]);
|
|
||||||
}
|
}
|
||||||
VIR_FREE(snapshots);
|
|
||||||
virshDomainFree(dom);
|
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, tmp);
|
VIR_STEAL_PTR(ret, tmp);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virshDomainFree(dom);
|
||||||
|
for (i = 0; i < nsnapshots; i++)
|
||||||
|
virshDomainSnapshotFree(snapshots[i]);
|
||||||
|
VIR_FREE(snapshots);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
for (; i < nsnapshots; i++)
|
|
||||||
virshDomainSnapshotFree(snapshots[i]);
|
|
||||||
VIR_FREE(snapshots);
|
|
||||||
for (i = 0; i < nsnapshots; i++)
|
for (i = 0; i < nsnapshots; i++)
|
||||||
VIR_FREE(tmp[i]);
|
VIR_FREE(tmp[i]);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
virshDomainFree(dom);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user