提交 c8230c4d 编写于 作者: J John Ferlan

Replace virDomainSnapshotFree with virObjectUnref

Since virDomainSnapshotFree will call virObjectUnref anyway, let's just use
that directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.
上级 c56a591a
......@@ -992,7 +992,7 @@ sc_prohibit_system_error_with_vir_err:
# functions. There's a corresponding exclude to allow usage within tests,
# docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h
sc_prohibit_virXXXFree:
@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool|Stream|Secret|NWFilter|Interface)Free\b' \
@prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool|Stream|Secret|NWFilter|Interface|DomainSnapshot)Free\b' \
exclude='sc_prohibit_virXXXFree' \
halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
$(_sc_search_regexp)
......@@ -1186,4 +1186,4 @@ exclude_file_name_regexp--sc_prohibit_devname = \
^(tools/virsh.pod|cfg.mk|docs/.*)$$
exclude_file_name_regexp--sc_prohibit_virXXXFree = \
^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream|secret|nwfilter|interface).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret|nwfilter|interface).c$$)
^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).c$$)
......@@ -4535,7 +4535,7 @@ remoteDispatchDomainListAllSnapshots(virNetServerPtr server ATTRIBUTE_UNUSED,
virObjectUnref(dom);
if (snaps && nsnaps > 0) {
for (i = 0; i < nsnaps; i++)
virDomainSnapshotFree(snaps[i]);
virObjectUnref(snaps[i]);
VIR_FREE(snaps);
}
return rv;
......@@ -4600,12 +4600,11 @@ remoteDispatchDomainSnapshotListAllChildren(virNetServerPtr server ATTRIBUTE_UNU
cleanup:
if (rv < 0)
virNetMessageSaveError(rerr);
if (snapshot)
virDomainSnapshotFree(snapshot);
virObjectUnref(snapshot);
virObjectUnref(dom);
if (snaps && nsnaps > 0) {
for (i = 0; i < nsnaps; i++)
virDomainSnapshotFree(snaps[i]);
virObjectUnref(snaps[i]);
VIR_FREE(snaps);
}
return rv;
......
......@@ -14079,7 +14079,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
cfg->snapshotDir) < 0) {
/* if writing of metadata fails, error out rather than trying
* to silently carry on without completing the snapshot */
virDomainSnapshotFree(snapshot);
virObjectUnref(snapshot);
snapshot = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to save metadata for snapshot %s"),
......
......@@ -6766,8 +6766,7 @@ remoteDomainListAllSnapshots(virDomainPtr dom,
cleanup:
if (snaps) {
for (i = 0; i < ret.snapshots.snapshots_len; i++)
if (snaps[i])
virDomainSnapshotFree(snaps[i]);
virObjectUnref(snaps[i]);
VIR_FREE(snaps);
}
......@@ -6833,8 +6832,7 @@ remoteDomainSnapshotListAllChildren(virDomainSnapshotPtr parent,
cleanup:
if (snaps) {
for (i = 0; i < ret.snapshots.snapshots_len; i++)
if (snaps[i])
virDomainSnapshotFree(snaps[i]);
virObjectUnref(snaps[i]);
VIR_FREE(snaps);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册