]> xenbits.xensource.com Git - libvirt.git/commit
maint: improve VIR_ERR_INVALID_DOMAIN usage
authorEric Blake <eblake@redhat.com>
Tue, 7 Jan 2014 21:38:12 +0000 (14:38 -0700)
committerEric Blake <eblake@redhat.com>
Tue, 7 Jan 2014 21:38:12 +0000 (14:38 -0700)
commit6e130ddc4d06620c5567a13311542421a732e084
treebd1355654221117b41fa05b0aa42ed7403c7391a
parent36dd0bd88af9388107bf2ab4f5f9af24a91dc66a
maint: improve VIR_ERR_INVALID_DOMAIN usage

In datatype.c, virGetDomainSnapshot could result in the message:

error: invalid domain pointer in bad domain

Furthermore, while there are a few functions in libvirt.c that
only care about a virDomainPtr without regards to the connection
(such as virDomainGetName), most functions also require a valid
connection.  Yet several functions were blindly dereferencing
the conn member without checking it for validity first (such as
virDomainOpenConsole).  Rather than try and correct all usage
of VIR_IS_DOMAIN vs. VIR_IS_CONNECTED_DOMAIN, it is easier to
just blindly require that a valid domain object always has a
valid connection object (which should be true anyways, since
every domain object holds a reference to its connection, so the
connection will not be closed until all domain objects have
also been closed to release their reference).

After this patch, all places that validate a domain consistently
report:

error: invalid domain pointer in someFunc

* src/datatypes.h (virCheckDomainReturn, virCheckDomainGoto): New
macros.
* src/datatypes.c (virGetDomainSnapshot): Use new macro.
(virLibConnError): Delete unused macro.

Signed-off-by: Eric Blake <eblake@redhat.com>
po/POTFILES.in
src/datatypes.c
src/datatypes.h
src/libvirt-lxc.c
src/libvirt-qemu.c
src/libvirt.c