[libvirt] PATCH: 11/28: Reduce return points for UML driver

Daniel P. Berrange berrange at redhat.com
Mon Dec 1 10:45:50 UTC 2008


On Mon, Dec 01, 2008 at 09:16:10AM +0000, Ron Yorston wrote:
> "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.

Yes indeed this entire method is on my hit list, since it actually
needs implementing for real !

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list