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

Replace virSecretFree with virObjectUnref

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.
上级 1725a468
...@@ -992,7 +992,7 @@ sc_prohibit_system_error_with_vir_err: ...@@ -992,7 +992,7 @@ sc_prohibit_system_error_with_vir_err:
# functions. There's a corresponding exclude to allow usage within tests, # functions. There's a corresponding exclude to allow usage within tests,
# docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h # docs, examples, tools, src/libvirt-*.c, and include/libvirt/libvirt-*.h
sc_prohibit_virXXXFree: 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' \ exclude='sc_prohibit_virXXXFree' \
halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \ halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
$(_sc_search_regexp) $(_sc_search_regexp)
...@@ -1186,4 +1186,4 @@ exclude_file_name_regexp--sc_prohibit_devname = \ ...@@ -1186,4 +1186,4 @@ exclude_file_name_regexp--sc_prohibit_devname = \
^(tools/virsh.pod|cfg.mk|docs/.*)$$ ^(tools/virsh.pod|cfg.mk|docs/.*)$$
exclude_file_name_regexp--sc_prohibit_virXXXFree = \ 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$$)
...@@ -3565,8 +3565,7 @@ remoteDispatchSecretGetValue(virNetServerPtr server ATTRIBUTE_UNUSED, ...@@ -3565,8 +3565,7 @@ remoteDispatchSecretGetValue(virNetServerPtr server ATTRIBUTE_UNUSED,
cleanup: cleanup:
if (rv < 0) if (rv < 0)
virNetMessageSaveError(rerr); virNetMessageSaveError(rerr);
if (secret) virObjectUnref(secret);
virSecretFree(secret);
return rv; return rv;
} }
...@@ -5024,7 +5023,7 @@ remoteDispatchConnectListAllSecrets(virNetServerPtr server ATTRIBUTE_UNUSED, ...@@ -5024,7 +5023,7 @@ remoteDispatchConnectListAllSecrets(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetMessageSaveError(rerr); virNetMessageSaveError(rerr);
if (secrets && nsecrets > 0) { if (secrets && nsecrets > 0) {
for (i = 0; i < nsecrets; i++) for (i = 0; i < nsecrets; i++)
virSecretFree(secrets[i]); virObjectUnref(secrets[i]);
VIR_FREE(secrets); VIR_FREE(secrets);
} }
return rv; return rv;
......
...@@ -3518,8 +3518,7 @@ remoteConnectListAllSecrets(virConnectPtr conn, ...@@ -3518,8 +3518,7 @@ remoteConnectListAllSecrets(virConnectPtr conn,
cleanup: cleanup:
if (tmp_secrets) { if (tmp_secrets) {
for (i = 0; i < ret.secrets.secrets_len; i++) for (i = 0; i < ret.secrets.secrets_len; i++)
if (tmp_secrets[i]) virObjectUnref(tmp_secrets[i]);
virSecretFree(tmp_secrets[i]);
VIR_FREE(tmp_secrets); VIR_FREE(tmp_secrets);
} }
......
...@@ -700,10 +700,8 @@ secretConnectListAllSecrets(virConnectPtr conn, ...@@ -700,10 +700,8 @@ secretConnectListAllSecrets(virConnectPtr conn,
cleanup: cleanup:
secretDriverUnlock(driver); secretDriverUnlock(driver);
if (tmp_secrets) { if (tmp_secrets) {
for (i = 0; i < ret_nsecrets; i ++) { for (i = 0; i < ret_nsecrets; i ++)
if (tmp_secrets[i]) virObjectUnref(tmp_secrets[i]);
virSecretFree(tmp_secrets[i]);
}
} }
VIR_FREE(tmp_secrets); VIR_FREE(tmp_secrets);
......
...@@ -506,7 +506,7 @@ virStorageGenerateSecretUUID(virConnectPtr conn, ...@@ -506,7 +506,7 @@ virStorageGenerateSecretUUID(virConnectPtr conn,
if (tmp == NULL) if (tmp == NULL)
return 0; return 0;
virSecretFree(tmp); virObjectUnref(tmp);
} }
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
...@@ -589,7 +589,7 @@ virStorageGenerateQcowEncryption(virConnectPtr conn, ...@@ -589,7 +589,7 @@ virStorageGenerateQcowEncryption(virConnectPtr conn,
if (ret != 0 && if (ret != 0 &&
conn->secretDriver->secretUndefine != NULL) conn->secretDriver->secretUndefine != NULL)
conn->secretDriver->secretUndefine(secret); conn->secretDriver->secretUndefine(secret);
virSecretFree(secret); virObjectUnref(secret);
} }
virBufferFreeAndReset(&buf); virBufferFreeAndReset(&buf);
virSecretDefFree(def); virSecretDefFree(def);
......
...@@ -1201,7 +1201,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn, ...@@ -1201,7 +1201,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 || if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 ||
VIR_ALLOC(encsec) < 0) { VIR_ALLOC(encsec) < 0) {
VIR_FREE(vol->target.encryption->secrets); VIR_FREE(vol->target.encryption->secrets);
virSecretFree(sec); virObjectUnref(sec);
return -1; return -1;
} }
...@@ -1210,7 +1210,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn, ...@@ -1210,7 +1210,7 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
encsec->type = VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE; encsec->type = VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE;
virSecretGetUUID(sec, encsec->uuid); virSecretGetUUID(sec, encsec->uuid);
virSecretFree(sec); virObjectUnref(sec);
} }
} }
......
...@@ -225,8 +225,7 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr, ...@@ -225,8 +225,7 @@ static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr,
VIR_FREE(secret_value); VIR_FREE(secret_value);
VIR_FREE(rados_key); VIR_FREE(rados_key);
if (secret != NULL) virObjectUnref(secret);
virSecretFree(secret);
virBufferFreeAndReset(&mon_host); virBufferFreeAndReset(&mon_host);
VIR_FREE(mon_buff); VIR_FREE(mon_buff);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册