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. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- cfg.mk | 4 ++-- daemon/remote.c | 7 +++---- src/qemu/qemu_driver.c | 2 +- src/remote/remote_driver.c | 6 ++---- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cfg.mk b/cfg.mk index e8ff5f5..21f83c3 100644 --- a/cfg.mk +++ b/cfg.mk @@ -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$$) diff --git a/daemon/remote.c b/daemon/remote.c index 3e4dc1f..d657a09 100644 --- a/daemon/remote.c +++ b/daemon/remote.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; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8d4b393..1130474 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14090,7 +14090,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"), diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3dc3ecb..999f16d 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -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); } -- 1.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list