[libvirt] PATCH: 11/28: Reduce return points for UML driver
Ron Yorston
rmy at tigress.co.uk
Mon Dec 1 09:16:10 UTC 2008
"Daniel P. Berrange" <berrange at redhat.com> wrote:
> static int umlDomainShutdown(virDomainPtr dom) {
>- struct uml_driver *driver = (struct uml_driver *)dom->conn->privateData;
>- virDomainObjPtr vm = virDomainFindByID(&driver->domains, dom->id);
>- char* info;
>+ struct uml_driver *driver = dom->conn->privateData;
>+ virDomainObjPtr vm;
>+ char *info;
>+ int ret = -1;
>
>+ vm = virDomainFindByID(&driver->domains, dom->id);
> if (!vm) {
> umlReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
> _("no domain with matching id %d"), dom->id);
>- return -1;
>+ goto cleanup;
> }
>
> #if 0
> if (umlMonitorCommand(driver, vm, "system_powerdown", &info) < 0) {
> umlReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
> "%s", _("shutdown operation failed"));
>- return -1;
>+ goto cleanup;
> }
>+ ret = 0;
> #endif
>+
>+cleanup:
> VIR_FREE(info);
>- return 0;
>+ return ret;
>
> }
info should be initialised to NULL, otherwise the VIR_FREE will fail.
With the umlMonitorCommand if'ed out this is also broken before the
patch, which is how I came to notice it.
Ron
More information about the libvir-list
mailing list