On 05/02/2017 03:29 PM, Marc-André Lureau wrote:
On Tue, May 2, 2017 at 3:52 PM Amarnath Valluri
<amarnath.vall...@intel.com <mailto:amarnath.vall...@intel.com>> wrote:
This allows backend implementations left optional interface methods.
For mandatory methods assertion checks added.
Signed-off-by: Amarnath Valluri <amarnath.vall...@intel.com
<mailto:amarnath.vall...@intel.com>>
---
backends/tpm.c | 24 ++++++++++++++++++------
hw/tpm/tpm_passthrough.c | 16 ----------------
2 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/backends/tpm.c b/backends/tpm.c
index cf5abf1..8245426 100644
--- a/backends/tpm.c
+++ b/backends/tpm.c
@@ -48,7 +48,7 @@ const char *tpm_backend_get_desc(TPMBackend *s)
{
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
- return k->ops->desc();
+ return k->ops->desc ? k->ops->desc() : "";
}
If it only need to returns const, we may consider using a class field,
defaulting to null.
Yes, it makes more sense being a const member than a function pointer.
Who is using it? tpm_backend_get_desc() not being called anywhere.
Let's remove it?
Frankly no one using this API, rather it's been accessed
directly(be_drivers[i]->desc()) in tpm.c. It can be removed.
- Amarnath