[PATCH 1/3] virtpm: Use corresponding type for argument for virTPM*CapsGet()

Michal Privoznik posted 3 patches 3 years, 6 months ago
There is a newer version of this series
[PATCH 1/3] virtpm: Use corresponding type for argument for virTPM*CapsGet()
Posted by Michal Privoznik 3 years, 6 months ago
In virtpm.h there are two functions exposed for querying swtpm
and swtpm_setup capabilieis: virTPMSwtpmCapsGet() and
virTPMSwtpmSetupCapsGet(), respectively. The capabilities we are
interested in are defined in two separate enums
(virTPMSwtpmFeature and virTPMSwtpmSetupFeature), but these
functions accept capability as an unsigned int rather than their
respective enum. While this makes sense for
virTPMBinaryGetCaps(), which is a module internal helper that
both exposed functions call, there's no need for the functions
themselves to accept unsigned int.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/util/virtpm.c | 4 ++--
 src/util/virtpm.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/util/virtpm.c b/src/util/virtpm.c
index 3c961c11cb..2f2b061fee 100644
--- a/src/util/virtpm.c
+++ b/src/util/virtpm.c
@@ -345,13 +345,13 @@ virTPMBinaryGetCaps(virTPMBinary binary,
 }
 
 bool
-virTPMSwtpmCapsGet(unsigned int cap)
+virTPMSwtpmCapsGet(virTPMSwtpmFeature cap)
 {
     return virTPMBinaryGetCaps(VIR_TPM_BINARY_SWTPM, cap);
 }
 
 bool
-virTPMSwtpmSetupCapsGet(unsigned int cap)
+virTPMSwtpmSetupCapsGet(virTPMSwtpmSetupFeature cap)
 {
     return virTPMBinaryGetCaps(VIR_TPM_BINARY_SWTPM_SETUP, cap);
 }
diff --git a/src/util/virtpm.h b/src/util/virtpm.h
index 89adbdf720..a873881b23 100644
--- a/src/util/virtpm.h
+++ b/src/util/virtpm.h
@@ -28,9 +28,6 @@ char *virTPMGetSwtpmIoctl(void);
 
 bool virTPMHasSwtpm(void);
 
-bool virTPMSwtpmCapsGet(unsigned int cap);
-bool virTPMSwtpmSetupCapsGet(unsigned int cap);
-
 typedef enum {
     VIR_TPM_SWTPM_FEATURE_CMDARG_PWD_FD,
 
@@ -50,3 +47,6 @@ typedef enum {
 
 VIR_ENUM_DECL(virTPMSwtpmFeature);
 VIR_ENUM_DECL(virTPMSwtpmSetupFeature);
+
+bool virTPMSwtpmCapsGet(virTPMSwtpmFeature cap);
+bool virTPMSwtpmSetupCapsGet(virTPMSwtpmSetupFeature cap);
-- 
2.35.1
Re: [PATCH 1/3] virtpm: Use corresponding type for argument for virTPM*CapsGet()
Posted by Andrea Bolognani 3 years, 6 months ago
On Fri, Jul 29, 2022 at 09:42:11AM +0200, Michal Privoznik wrote:
> In virtpm.h there are two functions exposed for querying swtpm
> and swtpm_setup capabilieis: virTPMSwtpmCapsGet() and

*capabilities

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization