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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]