Since virSecretFree 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(a)redhat.com>
---
cfg.mk | 4 ++--
daemon/remote.c | 5 ++---
src/remote/remote_driver.c | 3 +--
src/secret/secret_driver.c | 6 ++----
src/storage/storage_backend.c | 4 ++--
src/storage/storage_backend_fs.c | 4 ++--
src/storage/storage_backend_rbd.c | 3 +--
7 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index c7dfb76..e91cddf 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)Free\b' \
+ @prohibit='\bvir(Domain|Network|NodeDevice|StorageVol|StoragePool|Stream|Secret)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).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream).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).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret).c$$)
diff --git a/daemon/remote.c b/daemon/remote.c
index b2f1c46..60d05e1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3565,8 +3565,7 @@ remoteDispatchSecretGetValue(virNetServerPtr server
ATTRIBUTE_UNUSED,
cleanup:
if (rv < 0)
virNetMessageSaveError(rerr);
- if (secret)
- virSecretFree(secret);
+ virObjectUnref(secret);
return rv;
}
@@ -5024,7 +5023,7 @@ remoteDispatchConnectListAllSecrets(virNetServerPtr server
ATTRIBUTE_UNUSED,
virNetMessageSaveError(rerr);
if (secrets && nsecrets > 0) {
for (i = 0; i < nsecrets; i++)
- virSecretFree(secrets[i]);
+ virObjectUnref(secrets[i]);
VIR_FREE(secrets);
}
return rv;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2eb251a..431a092 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3518,8 +3518,7 @@ remoteConnectListAllSecrets(virConnectPtr conn,
cleanup:
if (tmp_secrets) {
for (i = 0; i < ret.secrets.secrets_len; i++)
- if (tmp_secrets[i])
- virSecretFree(tmp_secrets[i]);
+ virObjectUnref(tmp_secrets[i]);
VIR_FREE(tmp_secrets);
}
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index cd04b20..c7a51bb 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -700,10 +700,8 @@ secretConnectListAllSecrets(virConnectPtr conn,
cleanup:
secretDriverUnlock(driver);
if (tmp_secrets) {
- for (i = 0; i < ret_nsecrets; i ++) {
- if (tmp_secrets[i])
- virSecretFree(tmp_secrets[i]);
- }
+ for (i = 0; i < ret_nsecrets; i ++)
+ virObjectUnref(tmp_secrets[i]);
}
VIR_FREE(tmp_secrets);
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 98720f6..b990a82 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -506,7 +506,7 @@ virStorageGenerateSecretUUID(virConnectPtr conn,
if (tmp == NULL)
return 0;
- virSecretFree(tmp);
+ virObjectUnref(tmp);
}
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -589,7 +589,7 @@ virStorageGenerateQcowEncryption(virConnectPtr conn,
if (ret != 0 &&
conn->secretDriver->secretUndefine != NULL)
conn->secretDriver->secretUndefine(secret);
- virSecretFree(secret);
+ virObjectUnref(secret);
}
virBufferFreeAndReset(&buf);
virSecretDefFree(def);
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index f4bf5d6..0ee1d09 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1201,7 +1201,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 ||
VIR_ALLOC(encsec) < 0) {
VIR_FREE(vol->target.encryption->secrets);
- virSecretFree(sec);
+ virObjectUnref(sec);
return -1;
}
@@ -1210,7 +1210,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
encsec->type = VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE;
virSecretGetUUID(sec, encsec->uuid);
- virSecretFree(sec);
+ virObjectUnref(sec);
}
}
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 5a16eff..57182de 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -225,8 +225,7 @@ static int
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
VIR_FREE(secret_value);
VIR_FREE(rados_key);
- if (secret != NULL)
- virSecretFree(secret);
+ virObjectUnref(secret);
virBufferFreeAndReset(&mon_host);
VIR_FREE(mon_buff);
--
1.9.3